Index: spring/src/test-config/jcrmapping.xml =================================================================== --- spring/src/test-config/jcrmapping.xml (revision 595354) +++ spring/src/test-config/jcrmapping.xml Thu Nov 15 09:11:03 PST 2007 @@ -4,13 +4,13 @@ - + - + Index: spring/src/test/java/org/apache/portals/graffito/jcr/spring/SimpleTest.java =================================================================== --- spring/src/test/java/org/apache/portals/graffito/jcr/spring/SimpleTest.java (revision 595354) +++ spring/src/test/java/org/apache/portals/graffito/jcr/spring/SimpleTest.java (revision 595354) @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring; - -import java.util.Date; -import java.util.Iterator; - -import org.apache.portals.graffito.jcr.spring.test.components.ArticleService; -import org.apache.portals.graffito.jcr.spring.test.components.NewsService; -import org.apache.portals.graffito.jcr.spring.test.model.Article; -import org.apache.portals.graffito.jcr.spring.test.model.News; -import org.springframework.beans.BeansException; -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.context.support.FileSystemXmlApplicationContext; -import org.springframework.core.io.DefaultResourceLoader; -import org.springframework.core.io.ResourceLoader; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Test Mapper - * - * @author Christophe Lombart - */ -public class SimpleTest extends TestCase -{ - - - /** - *

Defines the test case name for junit.

- * @param testName The test case name. - */ - public SimpleTest(String testName) - { - super(testName); - } - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception - { - super.setUp(); - } - - /** - * @see junit.framework.TestCase#tearDown() - */ - public void tearDown() throws Exception - { - super.tearDown(); - } - - public static Test suite() - { - // All methods starting with "test" will be executed in the test suite. - return new TestSuite(SimpleTest.class); - } - - public void testComponents() - { - try { - System.out.println("Init Spring"); - AbstractApplicationContext context = new FileSystemXmlApplicationContext("src/spring-config/applicationContext-repository.xml"); - //ResourceLoader loader = new DefaultResourceLoader(); - - System.out.println("Add article"); - ArticleService service = (ArticleService) context .getBean("org.apache.portals.graffito.jcr.spring.test.components.ArticleService"); - Article article = new Article(); - article.setPath("/article"); - article.setAuthor("Christophe"); - article.setContent("This is an interesting content"); - article.setCreationDate(new Date()); - article.setDescription("This is the article description"); - article.setTitle("Article Title"); - - service.createArticle(article); - - System.out.println("Check News"); - NewsService newsService = (NewsService) context .getBean("org.apache.portals.graffito.jcr.spring.test.components.NewsService"); - Iterator news = newsService.getNews().iterator(); - while (news.hasNext()) - { - News newsFound = (News) news.next(); - System.out.println("News found : " + newsFound.getContent()); - } - context.close(); - } catch (Exception e) { - - e.printStackTrace(); - } - - } - -} \ No newline at end of file Index: spring/src/test/java/org/apache/jackrabbit/ocm/spring/SimpleTest.java =================================================================== --- spring/src/test/java/org/apache/jackrabbit/ocm/spring/SimpleTest.java Thu Nov 15 09:11:03 PST 2007 +++ spring/src/test/java/org/apache/jackrabbit/ocm/spring/SimpleTest.java Thu Nov 15 09:11:03 PST 2007 @@ -0,0 +1,108 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring; + +import java.util.Date; +import java.util.Iterator; + +import org.apache.jackrabbit.ocm.spring.test.components.ArticleService; +import org.apache.jackrabbit.ocm.spring.test.components.NewsService; +import org.apache.jackrabbit.ocm.spring.test.model.Article; +import org.apache.jackrabbit.ocm.spring.test.model.News; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.FileSystemXmlApplicationContext; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Test Mapper + * + * @author Christophe Lombart + */ +public class SimpleTest extends TestCase +{ + + + /** + *

Defines the test case name for junit.

+ * @param testName The test case name. + */ + public SimpleTest(String testName) + { + super(testName); + } + + /** + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + } + + /** + * @see junit.framework.TestCase#tearDown() + */ + public void tearDown() throws Exception + { + super.tearDown(); + } + + public static Test suite() + { + // All methods starting with "test" will be executed in the test suite. + return new TestSuite(SimpleTest.class); + } + + public void testComponents() + { + try { + System.out.println("Init Spring"); + AbstractApplicationContext context = new FileSystemXmlApplicationContext("src/spring-config/applicationContext-repository.xml"); + //ResourceLoader loader = new DefaultResourceLoader(); + + System.out.println("Add article"); + ArticleService service = (ArticleService) context .getBean("org.apache.jackrabbit.ocm.spring.test.components.ArticleService"); + Article article = new Article(); + article.setPath("/article"); + article.setAuthor("Christophe"); + article.setContent("This is an interesting content"); + article.setCreationDate(new Date()); + article.setDescription("This is the article description"); + article.setTitle("Article Title"); + + service.createArticle(article); + + System.out.println("Check News"); + NewsService newsService = (NewsService) context .getBean("org.apache.jackrabbit.ocm.spring.test.components.NewsService"); + Iterator news = newsService.getNews().iterator(); + while (news.hasNext()) + { + News newsFound = (News) news.next(); + System.out.println("News found : " + newsFound.getContent()); + } + context.close(); + } catch (Exception e) { + + e.printStackTrace(); + } + + } + +} \ No newline at end of file Index: spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/impl/NewsServiceImpl.java =================================================================== --- spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/impl/NewsServiceImpl.java (revision 595354) +++ spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/impl/NewsServiceImpl.java (revision 595354) @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring.test.components.impl; - -import java.util.Collection; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.portals.graffito.jcr.query.Filter; -import org.apache.portals.graffito.jcr.query.Query; -import org.apache.portals.graffito.jcr.query.QueryManager; -import org.apache.portals.graffito.jcr.spring.JcrMappingTemplate; -import org.apache.portals.graffito.jcr.spring.test.components.NewsService; -import org.apache.portals.graffito.jcr.spring.test.model.News; - -/** - * Default implementation for {@link org.apache.portals.graffito.jcr.spring.test.components.ArticleService} - * - * @author Lombart Christophe - * - */ -public class NewsServiceImpl implements NewsService { - private static final Log log = LogFactory.getLog(NewsServiceImpl.class); - - private JcrMappingTemplate jcrMappingtemplate; - - public void createNews(News news) - { - jcrMappingtemplate.insert(news); - jcrMappingtemplate.save(); - - } - - public Collection getNews() - { - - QueryManager queryManager = jcrMappingtemplate.createQueryManager(); - Filter filter = queryManager.createFilter(News.class); - - Query query = queryManager.createQuery(filter); - return jcrMappingtemplate.getObjects(query); - } - - - /** - * @return Returns the template. - */ - public JcrMappingTemplate getJcrMappingTemplate() { - return jcrMappingtemplate; - } - - /** - * @param template The template to set. - */ - public void setJcrMappingTemplate(JcrMappingTemplate template) { - this.jcrMappingtemplate = template; - } - - - -} Index: spring/src/test/resources/log4j.properties =================================================================== --- spring/src/test/resources/log4j.properties Thu Nov 15 08:57:09 PST 2007 +++ spring/src/test/resources/log4j.properties Thu Nov 15 08:57:09 PST 2007 @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +# ------------------------------------------------------------------------ +# +# Logging Configuration +# +# $Id: Log4j.properties,v 1.3 2004/12/22 20:37:04 christophe Exp $ +# +# ------------------------------------------------------------------------ + +log4j.rootLogger = WARN, console + +log4j.category.org.apache.portals.graffito.jcr= DEBUG, console +log4j.additivity.org.apache.portals.graffito.jcr=false + +# +# Console +# +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.layout=org.apache.log4j.PatternLayout + +# Pattern to output the caller's file name and line number. +log4j.appender.console.layout.ConversionPattern=%5p: %m%n \ No newline at end of file Index: spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingTemplate.java =================================================================== --- spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingTemplate.java (revision 595354) +++ spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingTemplate.java (revision 595354) @@ -1,277 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring; - -import java.io.InputStream; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.jcr.RepositoryException; -import javax.jcr.Session; - -import org.apache.portals.graffito.jcr.exception.JcrMappingException; -import org.apache.portals.graffito.jcr.mapper.Mapper; -import org.apache.portals.graffito.jcr.persistence.PersistenceManager; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.BinaryTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.BooleanTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.ByteArrayTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.CalendarTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.DoubleTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.IntTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.LongTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.StringTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.TimestampTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.UtilDateTypeConverterImpl; -import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl; -import org.apache.portals.graffito.jcr.query.Query; -import org.apache.portals.graffito.jcr.query.QueryManager; -import org.apache.portals.graffito.jcr.query.impl.QueryManagerImpl; -import org.springframework.dao.DataAccessException; -import org.springmodules.jcr.JcrCallback; -import org.springmodules.jcr.JcrSystemException; -import org.springmodules.jcr.JcrTemplate; -import org.springmodules.jcr.SessionFactory; - -/** - * Template whichs adds mapping support for the Java Content Repository. - *

- * For PersistenceManagers the template creates internally the set of default converters. - * - * - * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager - * @author Costin Leau - * - */ -public class JcrMappingTemplate extends JcrTemplate implements JcrMappingOperations { - - private Mapper mapper; - - - /** - * Default constructor for JcrTemplate - */ - public JcrMappingTemplate() { - super(); - - } - - /** - * @param sessionFactory - */ - public JcrMappingTemplate(SessionFactory sessionFactory, Mapper mapper) { - setSessionFactory(sessionFactory); - setMapper(mapper); - - afterPropertiesSet(); - } - - /** - * Add rule for checking the mapper. - * - * @see org.springmodules.jcr.JcrAccessor#afterPropertiesSet() - */ - public void afterPropertiesSet() { - super.afterPropertiesSet(); - if (mapper == null) - throw new IllegalArgumentException("mapper can NOT be null"); - } - - /** - * Method for creating a query manager. It's unclear where this entity is stateless or not. - * - * @return - */ - public QueryManager createQueryManager() { - try - { - Map atomicTypeConverters = this.createDefaultConverters(this.getSession()); - return new QueryManagerImpl (mapper, atomicTypeConverters); - } - catch (RepositoryException e) - { - throw new JcrSystemException(e); - } - } - - /** - * Creates a persistence manager. It's unclear if this object is stateless/thread-safe or not. - * However because it depends on session it has to be created per session and it's not per repository. - * - * - * @param session - * @return - * @throws JcrMappingException - */ - protected PersistenceManager createPersistenceManager(Session session) throws RepositoryException, JcrMappingException { - return new PersistenceManagerImpl(mapper, createQueryManager(), session); - } - - /** - * Due to the way the actual jcr-mapping is made we have to create the converters for - * each session. - * - * @param session - * @return - */ - protected Map createDefaultConverters(Session session) throws RepositoryException { - Map map = new HashMap(14); - - map.put(String.class, new StringTypeConverterImpl()); - map.put(InputStream.class, new BinaryTypeConverterImpl()); - map.put(long.class, new LongTypeConverterImpl()); - map.put(Long.class, new LongTypeConverterImpl()); - map.put(int.class, new IntTypeConverterImpl()); - map.put(Integer.class, new IntTypeConverterImpl()); - map.put(double.class, new DoubleTypeConverterImpl()); - map.put(Double.class, new DoubleTypeConverterImpl()); - map.put(boolean.class, new BooleanTypeConverterImpl()); - map.put(Boolean.class, new BooleanTypeConverterImpl()); - map.put(Calendar.class, new CalendarTypeConverterImpl()); - map.put(Date.class, new UtilDateTypeConverterImpl()); - map.put(byte[].class, new ByteArrayTypeConverterImpl()); - map.put(Timestamp.class, new TimestampTypeConverterImpl()); - - return map; - } - - /** - * @see org.springmodules.jcr.mapping.JcrMappingOperations#execute(org.springmodules.jcr.mapping.JcrMappingCallback, boolean) - */ - public Object execute(final JcrMappingCallback action, boolean exposeNativeSession) throws DataAccessException { - return execute(new JcrCallback() { - /** - * @see org.springmodules.jcr.JcrCallback#doInJcr(javax.jcr.Session) - */ - public Object doInJcr(Session session) throws RepositoryException { - try { - return action.doInJcrMapping(createPersistenceManager(session)); - } catch (JcrMappingException e) { - throw convertMappingAccessException(e); - } - } - - }, exposeNativeSession); - } - - /** - * @see org.springmodules.jcr.mapping.JcrMappingOperations#execute(org.springmodules.jcr.mapping.JcrMappingCallback) - */ - public Object execute(JcrMappingCallback callback) throws DataAccessException { - return execute(callback, isExposeNativeSession()); - } - - // ---------------- - // Delegate methods - // ---------------- - - /** - * @see org.springmodules.jcr.mapping.JcrMappingOperations#insert(java.lang.String, java.lang.Object) - */ - public void insert(final java.lang.Object object) { - execute(new JcrMappingCallback() { - public Object doInJcrMapping(PersistenceManager manager) throws JcrMappingException { - manager.insert(object); - return null; - } - }, true); - } - - /** - * @see org.springmodules.jcr.mapping.JcrMappingOperations#update(java.lang.String, java.lang.Object) - */ - public void update( final java.lang.Object object) { - execute(new JcrMappingCallback() { - public Object doInJcrMapping(PersistenceManager manager) throws JcrMappingException { - manager.update( object); - return null; - } - }, true); - } - - /** - * @see org.springmodules.jcr.mapping.JcrMappingOperations#remove(java.lang.String) - */ - public void remove(final java.lang.String path) { - execute(new JcrMappingCallback() { - public Object doInJcrMapping(PersistenceManager manager) throws JcrMappingException { - manager.remove(path); - return null; - } - }, true); - } - - /** - * @see org.springmodules.jcr.mapping.JcrMappingOperations#getObject(java.lang.Class, java.lang.String) - */ - public Object getObject(final java.lang.String path) { - return execute(new JcrMappingCallback() { - public Object doInJcrMapping(PersistenceManager manager) throws JcrMappingException { - return manager.getObject(path); - } - }, true); - } - - /** - * @see org.springmodules.jcr.mapping.JcrMappingOperations#getObjects(org.apache.portals.graffito.jcr.query.Query) - */ - public Collection getObjects(final Query query) { - return (Collection) execute(new JcrMappingCallback() { - public Object doInJcrMapping(PersistenceManager manager) throws JcrMappingException { - return manager.getObjects(query); - } - }, true); - } - - /** - * Convert the given MappingException to an appropriate exception from - * the org.springframework.dao hierarchy. - *

- * Note that because we have no base specific exception we have to catch - * the generic Exception and translate it into JcrSystemException. - *

- * May be overridden in subclasses. - * - * @param ex Exception that occured - * @return the corresponding DataAccessException instance - */ - public DataAccessException convertMappingAccessException(Exception ex) { - // repository exception - if (ex instanceof RepositoryException) - return super.convertJcrAccessException((RepositoryException) ex); - return new JcrSystemException(ex); - } - - /** - * @return Returns the mapper. - */ - public Mapper getMapper() { - return mapper; - } - - /** - * @param mapper The mapper to set. - */ - public void setMapper(Mapper mapper) { - this.mapper = mapper; - } - - -} Index: spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingTemplate.java =================================================================== --- spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingTemplate.java Thu Nov 15 09:32:53 PST 2007 +++ spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingTemplate.java Thu Nov 15 09:32:53 PST 2007 @@ -0,0 +1,251 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring; + +import java.io.InputStream; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import javax.jcr.RepositoryException; +import javax.jcr.Session; + +import org.apache.jackrabbit.ocm.exception.JcrMappingException; +import org.apache.jackrabbit.ocm.mapper.Mapper; +import org.apache.jackrabbit.ocm.manager.ObjectContentManager; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.BinaryTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.BooleanTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.ByteArrayTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.CalendarTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.DoubleTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.IntTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.LongTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.StringTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.TimestampTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl.UtilDateTypeConverterImpl; +import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl; +import org.apache.jackrabbit.ocm.query.Query; +import org.apache.jackrabbit.ocm.query.QueryManager; +import org.apache.jackrabbit.ocm.query.impl.QueryManagerImpl; +import org.springframework.dao.DataAccessException; +import org.springmodules.jcr.JcrCallback; +import org.springmodules.jcr.JcrSystemException; +import org.springmodules.jcr.JcrTemplate; +import org.springmodules.jcr.SessionFactory; + +/** + * Template whichs adds mapping support for the Java Content Repository. + *

+ * For PersistenceManagers the template creates internally the set of default converters. + * + * + * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager + * @author Costin Leau + * + */ +public class JcrMappingTemplate extends JcrTemplate implements JcrMappingOperations { + + private Mapper mapper; + + + /** + * Default constructor for JcrTemplate + */ + public JcrMappingTemplate() { + super(); + + } + + /** + * @param sessionFactory + */ + public JcrMappingTemplate(SessionFactory sessionFactory, Mapper mapper) { + setSessionFactory(sessionFactory); + setMapper(mapper); + + afterPropertiesSet(); + } + + /** + * Add rule for checking the mapper. + * + * @see org.springmodules.jcr.JcrAccessor#afterPropertiesSet() + */ + public void afterPropertiesSet() { + super.afterPropertiesSet(); + if (mapper == null) + throw new IllegalArgumentException("mapper can NOT be null"); + } + + /** + * Method for creating a query manager. It's unclear where this entity is stateless or not. + * + * @return + */ + public QueryManager createQueryManager() { + try { + Map atomicTypeConverters = this.createDefaultConverters(this.getSession()); + return new QueryManagerImpl(mapper, atomicTypeConverters, this.getSession().getValueFactory()); + } catch (RepositoryException e) { + throw new JcrSystemException(e); + } + } + + /** + * Creates a persistence manager. It's unclear if this object is stateless/thread-safe or not. + * However because it depends on session it has to be created per session and it's not per repository. + * + * + * @param session + * @return + * @throws JcrMappingException + */ + protected ObjectContentManager createPersistenceManager(Session session) throws RepositoryException, JcrMappingException { + return new ObjectContentManagerImpl(session, mapper); + } + + /** + * Due to the way the actual jcr-mapping is made we have to create the converters for + * each session. + * + * @param session + * @return + */ + protected Map createDefaultConverters(Session session) throws RepositoryException { + Map map = new HashMap(14); + + map.put(String.class, new StringTypeConverterImpl()); + map.put(InputStream.class, new BinaryTypeConverterImpl()); + map.put(long.class, new LongTypeConverterImpl()); + map.put(Long.class, new LongTypeConverterImpl()); + map.put(int.class, new IntTypeConverterImpl()); + map.put(Integer.class, new IntTypeConverterImpl()); + map.put(double.class, new DoubleTypeConverterImpl()); + map.put(Double.class, new DoubleTypeConverterImpl()); + map.put(boolean.class, new BooleanTypeConverterImpl()); + map.put(Boolean.class, new BooleanTypeConverterImpl()); + map.put(Calendar.class, new CalendarTypeConverterImpl()); + map.put(Date.class, new UtilDateTypeConverterImpl()); + map.put(byte[].class, new ByteArrayTypeConverterImpl()); + map.put(Timestamp.class, new TimestampTypeConverterImpl()); + + return map; + } + + public Object execute(final JcrMappingCallback action, boolean exposeNativeSession) throws DataAccessException { + return execute(new JcrCallback() { + /** + * @see org.springmodules.jcr.JcrCallback#doInJcr(javax.jcr.Session) + */ + public Object doInJcr(Session session) throws RepositoryException { + try { + return action.doInJcrMapping(createPersistenceManager(session)); + } catch (JcrMappingException e) { + throw convertMappingAccessException(e); + } + } + + }, exposeNativeSession); + } + + public Object execute(JcrMappingCallback callback) throws DataAccessException { + return execute(callback, isExposeNativeSession()); + } + + // ---------------- + // Delegate methods + // ---------------- + + public void insert(final java.lang.Object object) { + execute(new JcrMappingCallback() { + public Object doInJcrMapping(ObjectContentManager manager) throws JcrMappingException { + manager.insert(object); + return null; + } + }, true); + } + + public void update( final java.lang.Object object) { + execute(new JcrMappingCallback() { + public Object doInJcrMapping(ObjectContentManager manager) throws JcrMappingException { + manager.update( object); + return null; + } + }, true); + } + + public void remove(final java.lang.String path) { + execute(new JcrMappingCallback() { + public Object doInJcrMapping(ObjectContentManager manager) throws JcrMappingException { + manager.remove(path); + return null; + } + }, true); + } + + public Object getObject(final java.lang.String path) { + return execute(new JcrMappingCallback() { + public Object doInJcrMapping(ObjectContentManager manager) throws JcrMappingException { + return manager.getObject(path); + } + }, true); + } + + public Collection getObjects(final Query query) { + return (Collection) execute(new JcrMappingCallback() { + public Object doInJcrMapping(ObjectContentManager manager) throws JcrMappingException { + return manager.getObjects(query); + } + }, true); + } + + /** + * Convert the given MappingException to an appropriate exception from + * the org.springframework.dao hierarchy. + *

+ * Note that because we have no base specific exception we have to catch + * the generic Exception and translate it into JcrSystemException. + *

+ * May be overridden in subclasses. + * + * @param ex Exception that occured + * @return the corresponding DataAccessException instance + */ + public DataAccessException convertMappingAccessException(Exception ex) { + // repository exception + if (ex instanceof RepositoryException) + return super.convertJcrAccessException((RepositoryException) ex); + return new JcrSystemException(ex); + } + + /** + * @return Returns the mapper. + */ + public Mapper getMapper() { + return mapper; + } + + /** + * @param mapper The mapper to set. + */ + public void setMapper(Mapper mapper) { + this.mapper = mapper; + } +} Index: spring/src/main/java/org/apache/portals/graffito/jcr/spring/MappingDescriptorFactoryBean.java =================================================================== --- spring/src/main/java/org/apache/portals/graffito/jcr/spring/MappingDescriptorFactoryBean.java (revision 595354) +++ spring/src/main/java/org/apache/portals/graffito/jcr/spring/MappingDescriptorFactoryBean.java (revision 595354) @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring; - -import java.io.IOException; -import java.util.Iterator; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.portals.graffito.jcr.exception.JcrMappingException; -import org.apache.portals.graffito.jcr.mapper.impl.DigesterDescriptorReader; -import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor; -import org.apache.portals.graffito.jcr.mapper.model.MappingDescriptor; -import org.springframework.beans.factory.FactoryBean; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.core.io.Resource; - -/** - * Factory bean for loading mapping files. This factory beans can load several file descriptors - * and assembles them into an overall class descriptor. - * - * @author Costin Leau - * - */ -public class MappingDescriptorFactoryBean implements FactoryBean, InitializingBean { - - private static final Log log = LogFactory.getLog(MappingDescriptorFactoryBean.class); - - private MappingDescriptor mappingDescriptor; - - private Resource[] mappings; - - /** - * @see org.springframework.beans.factory.FactoryBean#getObject() - */ - public Object getObject() throws Exception { - return mappingDescriptor; - } - - /** - * @see org.springframework.beans.factory.FactoryBean#getObjectType() - */ - public Class getObjectType() { - return (this.mappingDescriptor != null) ? this.mappingDescriptor.getClass() : ClassDescriptor.class; - } - - /** - * @see org.springframework.beans.factory.FactoryBean#isSingleton() - */ - public boolean isSingleton() { - return true; - } - - /** - * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() - */ - public void afterPropertiesSet() throws Exception { - if (mappings == null || mappings.length == 0) - throw new IllegalArgumentException("at least one mapping file is needed"); - - createMappingDescriptor(); - } - - /** - * Subclasses can extend this method to provide custom behavior when creating - * the mapping descriptor - */ - protected void createMappingDescriptor() throws IOException, JcrMappingException { - // load the descriptors step by step and concatenate everything in an over-all - // descriptor - DigesterDescriptorReader reader = new DigesterDescriptorReader(); - mappingDescriptor = reader.loadClassDescriptors(mappings[0].getInputStream()); - boolean debug = log.isDebugEnabled(); - - for (int i = 1; i < mappings.length; i++) { - if (mappings[i] != null) { - MappingDescriptor descriptor = reader.loadClassDescriptors(mappings[i].getInputStream()); - for (Iterator iter = descriptor.getClassDescriptorsByClassName().values().iterator(); iter.hasNext();) { - mappingDescriptor.addClassDescriptor((ClassDescriptor) iter.next()); - } - } - } - } - - /** - * @return Returns the descriptors. - */ - public Resource[] getMappings() { - return mappings; - } - - /** - * @param descriptors The descriptors to set. - */ - public void setMappings(Resource[] descriptors) { - this.mappings = descriptors; - } - -} Index: spring/src/main/java/org/apache/jackrabbit/ocm/spring/MappingDescriptorFactoryBean.java =================================================================== --- spring/src/main/java/org/apache/jackrabbit/ocm/spring/MappingDescriptorFactoryBean.java Thu Nov 15 09:45:47 PST 2007 +++ spring/src/main/java/org/apache/jackrabbit/ocm/spring/MappingDescriptorFactoryBean.java Thu Nov 15 09:45:47 PST 2007 @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.jackrabbit.ocm.exception.JcrMappingException; +import org.apache.jackrabbit.ocm.mapper.impl.digester.DigesterDescriptorReader; +import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor; +import org.apache.jackrabbit.ocm.mapper.model.MappingDescriptor; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.io.Resource; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; + +/** + * Factory bean for loading mapping files. This factory beans can load several file descriptors + * and assembles them into an overall class descriptor. + * + * @author Costin Leau + * + */ +public class MappingDescriptorFactoryBean implements FactoryBean, InitializingBean { + + private static final Log log = LogFactory.getLog(MappingDescriptorFactoryBean.class); + + private MappingDescriptor mappingDescriptor; + + private Resource[] mappings; + + /** + * @see org.springframework.beans.factory.FactoryBean#getObject() + */ + public Object getObject() throws Exception { + return mappingDescriptor; + } + + /** + * @see org.springframework.beans.factory.FactoryBean#getObjectType() + */ + public Class getObjectType() { + return (this.mappingDescriptor != null) ? this.mappingDescriptor.getClass() : ClassDescriptor.class; + } + + /** + * @see org.springframework.beans.factory.FactoryBean#isSingleton() + */ + public boolean isSingleton() { + return true; + } + + /** + * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() + */ + public void afterPropertiesSet() throws Exception { + if (mappings == null || mappings.length == 0) + throw new IllegalArgumentException("at least one mapping file is needed"); + + createMappingDescriptor(); + } + + /** + * Subclasses can extend this method to provide custom behavior when creating + * the mapping descriptor + */ + protected void createMappingDescriptor() throws IOException, JcrMappingException { + // load the descriptors step by step and concatenate everything in an over-all + // descriptor + InputStream[] streams = new InputStream[mappings.length]; + for (int i = 0; i < streams.length; i++) { + if (mappings[i] != null) { + streams[i] = mappings[i].getInputStream(); + } + } + DigesterDescriptorReader reader = new DigesterDescriptorReader(streams); + mappingDescriptor = reader.loadClassDescriptors(); + } + + /** + * @return Returns the descriptors. + */ + public Resource[] getMappings() { + return mappings; + } + + /** + * @param descriptors The descriptors to set. + */ + public void setMappings(Resource[] descriptors) { + this.mappings = descriptors; + } + +} Index: spring/pom.xml =================================================================== --- spring/pom.xml Fri Nov 16 16:23:26 PST 2007 +++ spring/pom.xml Fri Nov 16 16:23:26 PST 2007 @@ -0,0 +1,146 @@ + + + + + + 4.0.0 + + + + + + org.apache.jackrabbit + jackrabbit + 1.4-SNAPSHOT + + jackrabbit-ocm-spring + jar + Jackrabbit Object Content Mapping Spring Integration + + This Jackrabbit subproject is an object/JCR persistence and + query service. This tools provides the ability to configure + Jackrabbit OCM services via Spring. + + 2007 + + + + + + + + true + maven-compiler-plugin + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-surefire-plugin + + -Xmx256m + + + + + + + + + + + jdk1.4 + + + + true + maven-compiler-plugin + + 1.4 + 1.4 + + + + org.apache.maven.plugins + maven-jar-plugin + + jdk1.4 + + + + + + + + + + + + + javax.jcr + jcr + 1.0 + + + org.apache.jackrabbit + jackrabbit-ocm + 1.4-SNAPSHOT + + + org.springframework + spring + 2.0.7 + + + org.springmodules + spring-modules-jcr + 0.8 + + + commons-logging + commons-logging + 1.1 + + + + + + junit + junit + 3.8.1 + test + + + + + + scm:svn:http://svn.apache.org/repos/asf/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring + + + scm:svn:https://svn.apache.org/repos/asf/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring + + + http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring + + + Index: spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/ArticleServiceImpl.java =================================================================== --- spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/ArticleServiceImpl.java Thu Nov 15 09:33:40 PST 2007 +++ spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/ArticleServiceImpl.java Thu Nov 15 09:33:40 PST 2007 @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring.test.components.impl; + +import java.util.Collection; +import java.util.Date; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.jackrabbit.ocm.query.Filter; +import org.apache.jackrabbit.ocm.query.Query; +import org.apache.jackrabbit.ocm.query.QueryManager; +import org.apache.jackrabbit.ocm.spring.JcrMappingTemplate; +import org.apache.jackrabbit.ocm.spring.test.components.ArticleService; +import org.apache.jackrabbit.ocm.spring.test.components.NewsService; +import org.apache.jackrabbit.ocm.spring.test.model.Article; +import org.apache.jackrabbit.ocm.spring.test.model.News; + +/** + * Default implementation for {@link org.apache.jackrabbit.ocm.spring.test.components.ArticleService} + * + * @author Lombart Christophe + * + */ +public class ArticleServiceImpl implements ArticleService { + private static final Log log = LogFactory.getLog(ArticleServiceImpl.class); + + private JcrMappingTemplate jcrMappingtemplate; + private NewsService newsService; + + + public void createArticle(Article article) + { + + jcrMappingtemplate.insert(article); + jcrMappingtemplate.save(); + + + News news = new News(); + news.setContent("A new article has been created by " + article.getAuthor()); + news.setCreationDate(new Date()); + news.setPath("/news-" + System.currentTimeMillis()); + newsService.createNews(news); + } + + public Collection getArticles() + { + + QueryManager queryManager = jcrMappingtemplate.createQueryManager(); + Filter filter = queryManager.createFilter(Article.class); + + Query query = queryManager.createQuery(filter); + return jcrMappingtemplate.getObjects(query); + } + + + public NewsService getNewsService() + { + return newsService; + } + + public void setNewsService(NewsService newsService) + { + this.newsService = newsService; + } + + /** + * @return Returns the template. + */ + public JcrMappingTemplate getJcrMappingTemplate() { + return jcrMappingtemplate; + } + + /** + * @param template The template to set. + */ + public void setJcrMappingTemplate(JcrMappingTemplate template) { + this.jcrMappingtemplate = template; + } + + + +} Index: spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingOperations.java =================================================================== --- spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingOperations.java (revision 595354) +++ spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingOperations.java (revision 595354) @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring; - -import java.util.Collection; - -import org.apache.portals.graffito.jcr.query.Query; -import org.springframework.dao.DataAccessException; - -/** - * Interface that specifies a basic set of JCR mapping operations. Not often used, but - * a useful option to enhance testability, as it can easily be mocked or stubbed. - * - *

- * Provides JcrMappingTemplate's data access methods that mirror various PersistenceManager - * methods. See the required javadocs for details on those methods. - * - * @author Costin Leau - * - */ -public interface JcrMappingOperations { - - /** - * Execute a JcrMappingCallback. - * - * @param callback callback to execute - * @return the callback result - * @throws DataAccessException - */ - public Object execute(JcrMappingCallback callback) throws DataAccessException; - - /** - * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#insert(java.lang.String, java.lang.Object) - */ - public void insert( final java.lang.Object object); - - /** - * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#update(java.lang.String, java.lang.Object) - */ - public void update( final java.lang.Object object); - - /** - * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#remove(java.lang.String) - */ - public void remove(final java.lang.String path); - - /** - * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObject(java.lang.Class, java.lang.String) - */ - public Object getObject( final java.lang.String path); - - /** - * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObjects(org.apache.portals.graffito.jcr.query.Query) - */ - public Collection getObjects(final Query query); - -} \ No newline at end of file Index: spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingOperations.java =================================================================== --- spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingOperations.java Thu Nov 15 09:22:34 PST 2007 +++ spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingOperations.java Thu Nov 15 09:22:34 PST 2007 @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring; + +import java.util.Collection; + +import org.apache.jackrabbit.ocm.query.Query; +import org.springframework.dao.DataAccessException; + +/** + * Interface that specifies a basic set of JCR mapping operations. Not often used, but + * a useful option to enhance testability, as it can easily be mocked or stubbed. + * + *

+ * Provides JcrMappingTemplate's data access methods that mirror various PersistenceManager + * methods. See the required javadocs for details on those methods. + * + * @author Costin Leau + * + */ +public interface JcrMappingOperations { + + /** + * Execute a JcrMappingCallback. + * + * @param callback callback to execute + * @return the callback result + * @throws DataAccessException + */ + public Object execute(JcrMappingCallback callback) throws DataAccessException; + + /** + * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager#insert(java.lang.Object) + */ + public void insert( final java.lang.Object object); + + /** + * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager#update(java.lang.Object) + */ + public void update( final java.lang.Object object); + + /** + * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager#remove(java.lang.String) + */ + public void remove(final java.lang.String path); + + /** + * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager#getObject(java.lang.String) + */ + public Object getObject( final java.lang.String path); + + /** + * @see org.apache.jackrabbit.ocm.manager.ObjectContentManager#getObjects(org.apache.jackrabbit.ocm.query.Query) + */ + public Collection getObjects(final Query query); + +} \ No newline at end of file Index: spring/src/main/java/org/apache/jackrabbit/ocm/spring/JackrabbitSessionFactory.java =================================================================== --- spring/src/main/java/org/apache/jackrabbit/ocm/spring/JackrabbitSessionFactory.java Fri Nov 16 16:35:05 PST 2007 +++ spring/src/main/java/org/apache/jackrabbit/ocm/spring/JackrabbitSessionFactory.java Fri Nov 16 16:35:05 PST 2007 @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring; + +import javax.jcr.NamespaceException; +import javax.jcr.NamespaceRegistry; +import javax.jcr.RepositoryException; + +import org.apache.jackrabbit.ocm.repository.RepositoryUtil; +import org.springmodules.jcr.JcrSessionFactory; + +/** + * JCR session factory specific to Jaclrabbit for Graffito. Until now, Jackrabbit cannot unregister a namespace. + * So, the JcrSessionFactory provided by the spring module is not usefull when namespace management are needed. + * This class extends the JcrSessionFactory in order to add the namespace graffito + * + * @author Christophe Lombart + */ +public class JackrabbitSessionFactory extends JcrSessionFactory +{ + + /** + * Register the namespaces. + * @throws RepositoryException + */ + protected void registerNamespaces() throws Exception { + NamespaceRegistry registry = + getSession().getWorkspace().getNamespaceRegistry(); + + // Keep trying until the Graffito namespace has been registered + int n = 0; + String prefix = null; + while (prefix == null) { + try { + // Is the Graffito namespace registered? + prefix = registry.getPrefix(RepositoryUtil.OCM_NAMESPACE); + } catch (NamespaceException e1) { + // No, try to register it with the default prefix + prefix = RepositoryUtil.OCM_NAMESPACE_PREFIX; + // ... and a sequence number if the first attempt failed + if (n++ > 0) { + prefix = prefix + n; + } + try { + // Is this prefix registered to the Graffito namespace? + if (!RepositoryUtil.OCM_NAMESPACE.equals( + registry.getURI(prefix))) { + // No, but it *is* registered. Try the next prefix... + prefix = null; + } + } catch (NamespaceException e2) { + try { + // No, and it's not registered. Try registering it: + registry.registerNamespace( + prefix, RepositoryUtil.OCM_NAMESPACE); + } catch (NamespaceException e3) { + // Registration failed. Try the next prefix... + prefix = null; + } + } + } + } + + super.registerNamespaces(); + } + +} Index: spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/ArticleService.java =================================================================== --- spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/ArticleService.java Thu Nov 15 09:11:03 PST 2007 +++ spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/ArticleService.java Thu Nov 15 09:11:03 PST 2007 @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring.test.components; + +import java.util.Collection; + +import org.apache.jackrabbit.ocm.spring.test.model.Article; +/** + * + * VERY Simple article management + * + * @author Lombart Christophe + * + */ +public interface ArticleService +{ + public void createArticle(Article article); + + public Collection getArticles(); +} Index: spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/NewsService.java =================================================================== --- spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/NewsService.java (revision 595354) +++ spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/NewsService.java (revision 595354) @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring.test.components; - -import java.util.Collection; - -import org.apache.portals.graffito.jcr.spring.test.model.News; -/** - * - * VERY Simple news management - * - * @author Lombart Christophe - * - */ -public interface NewsService -{ - public void createNews(News news); - - public Collection getNews(); -} Index: spring/src/spring-config/applicationContext-repository.xml =================================================================== --- spring/src/spring-config/applicationContext-repository.xml (revision 595354) +++ spring/src/spring-config/applicationContext-repository.xml Thu Nov 15 09:14:11 PST 2007 @@ -12,7 +12,7 @@ - + @@ -34,11 +34,11 @@ - + - + @@ -56,18 +56,17 @@ - + - + - org.apache.portals.graffito.jcr.spring.test.components.NewsService + org.apache.jackrabbit.ocm.spring.test.components.NewsService - + @@ -77,19 +76,18 @@ - + - + - + - org.apache.portals.graffito.jcr.spring.test.components.ArticleService + org.apache.jackrabbit.ocm.spring.test.components.ArticleService - + Index: spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/News.java =================================================================== --- spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/News.java Thu Nov 15 09:11:03 PST 2007 +++ spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/News.java Thu Nov 15 09:11:03 PST 2007 @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring.test.model; + + +import java.util.*; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Simple New class + * + * @author Christophe Lombart + * + */ +public class News +{ + protected final static Log log = LogFactory.getLog(News.class); + + protected String path; + protected Date creationDate; + protected String content; + + + + public String getPath() + { + return path; + } + public void setPath(String path) + { + this.path = path; + } + public String getContent() + { + return content; + } + public void setContent(String content) + { + this.content = content; + } + public Date getCreationDate() + { + return creationDate; + } + public void setCreationDate(Date creationDate) + { + this.creationDate = creationDate; + } + +} + Index: spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/impl/ArticleServiceImpl.java =================================================================== --- spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/impl/ArticleServiceImpl.java (revision 595354) +++ spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/impl/ArticleServiceImpl.java (revision 595354) @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring.test.components.impl; - -import java.util.Collection; -import java.util.Date; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.portals.graffito.jcr.query.Filter; -import org.apache.portals.graffito.jcr.query.Query; -import org.apache.portals.graffito.jcr.query.QueryManager; -import org.apache.portals.graffito.jcr.spring.JcrMappingTemplate; -import org.apache.portals.graffito.jcr.spring.test.components.ArticleService; -import org.apache.portals.graffito.jcr.spring.test.components.NewsService; -import org.apache.portals.graffito.jcr.spring.test.model.Article; -import org.apache.portals.graffito.jcr.spring.test.model.News; - -/** - * Default implementation for {@link org.apache.portals.graffito.jcr.spring.test.components.ArticleService} - * - * @author Lombart Christophe - * - */ -public class ArticleServiceImpl implements ArticleService { - private static final Log log = LogFactory.getLog(ArticleServiceImpl.class); - - private JcrMappingTemplate jcrMappingtemplate; - private NewsService newsService; - - - public void createArticle(Article article) - { - - jcrMappingtemplate.insert(article); - jcrMappingtemplate.save(); - - - News news = new News(); - news.setContent("A new article has been created by " + article.getAuthor()); - news.setCreationDate(new Date()); - news.setPath("/news-" + System.currentTimeMillis()); - newsService.createNews(news); - } - - public Collection getArticles() - { - - QueryManager queryManager = jcrMappingtemplate.createQueryManager(); - Filter filter = queryManager.createFilter(Article.class); - - Query query = queryManager.createQuery(filter); - return jcrMappingtemplate.getObjects(query); - } - - - public NewsService getNewsService() - { - return newsService; - } - - public void setNewsService(NewsService newsService) - { - this.newsService = newsService; - } - - /** - * @return Returns the template. - */ - public JcrMappingTemplate getJcrMappingTemplate() { - return jcrMappingtemplate; - } - - /** - * @param template The template to set. - */ - public void setJcrMappingTemplate(JcrMappingTemplate template) { - this.jcrMappingtemplate = template; - } - - - -} Index: spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/model/Article.java =================================================================== --- spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/model/Article.java (revision 595354) +++ spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/model/Article.java (revision 595354) @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring.test.model; - - -import java.util.*; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Simple Article class - * - * @author Christophe Lombart - * - */ -public class Article -{ - protected final static Log log = LogFactory.getLog(Article.class); - - protected String path; - protected String title; - protected String description; - protected String author; - protected Date creationDate; - protected String content; - - - public String getPath() - { - return path; - } - public void setPath(String path) - { - this.path = path; - } - public String getAuthor() - { - return author; - } - public void setAuthor(String author) - { - this.author = author; - } - public String getContent() - { - return content; - } - public void setContent(String content) - { - this.content = content; - } - public Date getCreationDate() - { - return creationDate; - } - public void setCreationDate(Date creationDate) - { - this.creationDate = creationDate; - } - public String getDescription() - { - return description; - } - public void setDescription(String description) - { - this.description = description; - } - public String getTitle() - { - return title; - } - public void setTitle(String title) - { - this.title = title; - } - - -} - Index: spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/NewsService.java =================================================================== --- spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/NewsService.java Thu Nov 15 09:11:03 PST 2007 +++ spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/NewsService.java Thu Nov 15 09:11:03 PST 2007 @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring.test.components; + +import java.util.Collection; + +import org.apache.jackrabbit.ocm.spring.test.model.News; +/** + * + * VERY Simple news management + * + * @author Lombart Christophe + * + */ +public interface NewsService +{ + public void createNews(News news); + + public Collection getNews(); +} Index: spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingCallback.java =================================================================== --- spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingCallback.java (revision 595354) +++ spring/src/main/java/org/apache/portals/graffito/jcr/spring/JcrMappingCallback.java (revision 595354) @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring; - -import org.apache.portals.graffito.jcr.exception.JcrMappingException; -import org.apache.portals.graffito.jcr.persistence.PersistenceManager; - -/** - * Callback interface for Jcr mapping code. To be used with JcrMappingTemplate's execute method, - * assumably often as anonymous classes within a method implementation. The typical - * implementation will call PersistenceManager.get/insert/remove/update to perform some operations on - * the repository. - * - * @author Costin Leau - * - */ -public interface JcrMappingCallback { - - /** - * Called by {@link JcrMappingTemplate#execute} within an active PersistenceManager - * {@link org.apache.graffito.jcr.mapper.persistence.PersistenceManager}. - * It is not responsible for logging out of the Session or handling transactions. - * - * Allows for returning a result object created within the - * callback, i.e. a domain object or a collection of domain - * objects. A thrown {@link RuntimeException} is treated as an - * application exeception; it is propagated to the caller of the - * template. - */ - public Object doInJcrMapping(PersistenceManager manager) throws JcrMappingException; -} Index: spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingCallback.java =================================================================== --- spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingCallback.java Thu Nov 15 09:19:43 PST 2007 +++ spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingCallback.java Thu Nov 15 09:19:43 PST 2007 @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring; + +import org.apache.jackrabbit.ocm.manager.ObjectContentManager; +import org.apache.jackrabbit.ocm.exception.JcrMappingException; + +/** + * Callback interface for Jcr mapping code. To be used with JcrMappingTemplate's execute method, + * assumably often as anonymous classes within a method implementation. The typical + * implementation will call PersistenceManager.get/insert/remove/update to perform some operations on + * the repository. + * + * @author Costin Leau + * + */ +public interface JcrMappingCallback { + + /** + * Called by {@link JcrMappingTemplate#execute} within an active PersistenceManager + * {@link org.apache.jackrabbit.ocm.manager.ObjectContentManager}. + * It is not responsible for logging out of the Session or handling transactions. + * + * Allows for returning a result object created within the + * callback, i.e. a domain object or a collection of domain + * objects. A thrown {@link RuntimeException} is treated as an + * application exeception; it is propagated to the caller of the + * template. + */ + public Object doInJcrMapping(ObjectContentManager manager) throws JcrMappingException; +} Index: spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/model/News.java =================================================================== --- spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/model/News.java (revision 595354) +++ spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/model/News.java (revision 595354) @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring.test.model; - - -import java.util.*; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Simple New class - * - * @author Christophe Lombart - * - */ -public class News -{ - protected final static Log log = LogFactory.getLog(News.class); - - protected String path; - protected Date creationDate; - protected String content; - - - - public String getPath() - { - return path; - } - public void setPath(String path) - { - this.path = path; - } - public String getContent() - { - return content; - } - public void setContent(String content) - { - this.content = content; - } - public Date getCreationDate() - { - return creationDate; - } - public void setCreationDate(Date creationDate) - { - this.creationDate = creationDate; - } - -} - Index: spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/NewsServiceImpl.java =================================================================== --- spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/NewsServiceImpl.java Thu Nov 15 09:34:07 PST 2007 +++ spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/NewsServiceImpl.java Thu Nov 15 09:34:07 PST 2007 @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring.test.components.impl; + +import java.util.Collection; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.jackrabbit.ocm.query.Filter; +import org.apache.jackrabbit.ocm.query.Query; +import org.apache.jackrabbit.ocm.query.QueryManager; +import org.apache.jackrabbit.ocm.spring.JcrMappingTemplate; +import org.apache.jackrabbit.ocm.spring.test.components.NewsService; +import org.apache.jackrabbit.ocm.spring.test.model.News; + +/** + * Default implementation for {@link org.apache.jackrabbit.ocm.spring.test.components.ArticleService} + * + * @author Lombart Christophe + * + */ +public class NewsServiceImpl implements NewsService { + private static final Log log = LogFactory.getLog(NewsServiceImpl.class); + + private JcrMappingTemplate jcrMappingtemplate; + + public void createNews(News news) + { + jcrMappingtemplate.insert(news); + jcrMappingtemplate.save(); + + } + + public Collection getNews() + { + + QueryManager queryManager = jcrMappingtemplate.createQueryManager(); + Filter filter = queryManager.createFilter(News.class); + + Query query = queryManager.createQuery(filter); + return jcrMappingtemplate.getObjects(query); + } + + + /** + * @return Returns the template. + */ + public JcrMappingTemplate getJcrMappingTemplate() { + return jcrMappingtemplate; + } + + /** + * @param template The template to set. + */ + public void setJcrMappingTemplate(JcrMappingTemplate template) { + this.jcrMappingtemplate = template; + } + + + +} Index: spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/Article.java =================================================================== --- spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/Article.java Thu Nov 15 09:11:03 PST 2007 +++ spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/Article.java Thu Nov 15 09:11:03 PST 2007 @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.ocm.spring.test.model; + + +import java.util.*; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Simple Article class + * + * @author Christophe Lombart + * + */ +public class Article +{ + protected final static Log log = LogFactory.getLog(Article.class); + + protected String path; + protected String title; + protected String description; + protected String author; + protected Date creationDate; + protected String content; + + + public String getPath() + { + return path; + } + public void setPath(String path) + { + this.path = path; + } + public String getAuthor() + { + return author; + } + public void setAuthor(String author) + { + this.author = author; + } + public String getContent() + { + return content; + } + public void setContent(String content) + { + this.content = content; + } + public Date getCreationDate() + { + return creationDate; + } + public void setCreationDate(Date creationDate) + { + this.creationDate = creationDate; + } + public String getDescription() + { + return description; + } + public void setDescription(String description) + { + this.description = description; + } + public String getTitle() + { + return title; + } + public void setTitle(String title) + { + this.title = title; + } + + +} + Index: spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/ArticleService.java =================================================================== --- spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/ArticleService.java (revision 595354) +++ spring/src/test/java/org/apache/portals/graffito/jcr/spring/test/components/ArticleService.java (revision 595354) @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.portals.graffito.jcr.spring.test.components; - -import java.util.Collection; - -import org.apache.portals.graffito.jcr.spring.test.model.Article; -/** - * - * VERY Simple article management - * - * @author Lombart Christophe - * - */ -public interface ArticleService -{ - public void createArticle(Article article); - - public Collection getArticles(); -}