jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r596432 - in /jackrabbit/sandbox/jackrabbit-jcr-mapping/spring: ./ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/ocm/ src/main/java/org/apache/...
Date Mon, 19 Nov 2007 20:26:03 GMT
Author: clombart
Date: Mon Nov 19 12:25:59 2007
New Revision: 596432

URL: http://svn.apache.org/viewvc?rev=596432&view=rev
Log:
apply patch procided by Padraic Hannon for issue JCR-1043

Added:
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/pom.xml
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JackrabbitSessionFactory.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingCallback.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingOperations.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingTemplate.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/MappingDescriptorFactoryBean.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/RepositoryUtil.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jackrabbit-ocm.dtd
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/SimpleTest.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/ArticleService.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/NewsService.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/ArticleServiceImpl.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/NewsServiceImpl.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/Article.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/News.java
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/resources/
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/resources/log4j.properties
Removed:
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/locator.ent
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/locator.path
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/maven.xml
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/project.properties
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/project.xml
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/graffito-jcr-mapping.dtd
Modified:
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/spring-config/applicationContext-repository.xml
    jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jcrmapping.xml

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/pom.xml?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/pom.xml (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/pom.xml Mon Nov 19 12:25:59 2007
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+	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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+                             http://maven.apache.org/maven-v4_0_0.xsd ">
+	<modelVersion>4.0.0</modelVersion>
+
+	<!-- ====================================================================== -->
+	<!-- P R O J E C T  D E S C R I P T I O N                                   -->
+	<!-- ====================================================================== -->
+	<parent>
+		<groupId>org.apache.jackrabbit</groupId>
+		<artifactId>jackrabbit</artifactId>
+		<version>1.4-SNAPSHOT</version>
+	</parent>
+	<artifactId>jackrabbit-ocm-spring</artifactId>
+	<packaging>jar</packaging>
+	<name>Jackrabbit Object Content Mapping Spring Integration</name>
+	<description>
+		This Jackrabbit subproject is an object/JCR persistence and
+		query service. This tools provides the ability to configure
+        Jackrabbit OCM services via Spring.
+	</description>
+	<inceptionYear>2007</inceptionYear>
+
+	<!-- ====================================================================== -->
+	<!-- B U I L D                                                              -->
+	<!-- ====================================================================== -->
+	<build>
+		<plugins>
+			<plugin>
+				<inherited>true</inherited>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<target>1.5</target>
+					<source>1.5</source>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
+				<configuration>
+					<argLine>-Xmx256m</argLine>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+
+	<!-- ====================================================================== -->
+	<!-- P R O F I L E S                                                        -->
+	<!-- ====================================================================== -->
+    <profiles>
+        <profile>
+            <id>jdk1.4</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <inherited>true</inherited>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <configuration>                            
+                            <target>1.4</target>
+                            <source>1.4</source>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-jar-plugin</artifactId>
+                        <configuration>
+                            <classifier>jdk1.4</classifier>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+	<!-- ====================================================================== -->
+	<!-- D E P E N D E N C I E S                                                -->
+	<!-- ====================================================================== -->
+	<dependencies>
+		<dependency>
+			<groupId>javax.jcr</groupId>
+			<artifactId>jcr</artifactId>
+			<version>1.0</version>
+		</dependency>
+        <dependency>
+			<groupId>org.apache.jackrabbit</groupId>
+			<artifactId>jackrabbit-ocm</artifactId>
+			<version>1.4-SNAPSHOT</version>
+	</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring</artifactId>
+            <version>2.0.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springmodules</groupId>
+            <artifactId>spring-modules-jcr</artifactId>
+            <version>0.8</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.1</version>
+        </dependency>
+
+
+		<!-- Test -->
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+
+	<scm>
+		<connection>
+			scm:svn:http://svn.apache.org/repos/asf/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring
+		</connection>
+		<developerConnection>
+			scm:svn:https://svn.apache.org/repos/asf/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring
+		</developerConnection>
+		<url>
+			http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring
+		</url>
+	</scm>
+</project>

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JackrabbitSessionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JackrabbitSessionFactory.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JackrabbitSessionFactory.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JackrabbitSessionFactory.java Mon Nov 19 12:25:59 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.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 <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+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();
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingCallback.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingCallback.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingCallback.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingCallback.java Mon Nov 19 12:25:59 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 <code>Session</code> 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;
+}

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingOperations.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingOperations.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingOperations.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingOperations.java Mon Nov 19 12:25:59 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.
+ * 
+ * <p>
+ * 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

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingTemplate.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingTemplate.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingTemplate.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/JcrMappingTemplate.java Mon Nov 19 12:25:59 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.
+ * <p/>
+ * 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 <code>org.springframework.dao</code> hierarchy.
+     * <p>
+     * Note that because we have no base specific exception we have to catch
+     * the generic Exception and translate it into JcrSystemException.
+     * <p>
+     * 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;
+    }    
+}

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/MappingDescriptorFactoryBean.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/MappingDescriptorFactoryBean.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/MappingDescriptorFactoryBean.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/MappingDescriptorFactoryBean.java Mon Nov 19 12:25:59 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;
+    }
+
+}

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/RepositoryUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/RepositoryUtil.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/RepositoryUtil.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/main/java/org/apache/jackrabbit/ocm/spring/RepositoryUtil.java Mon Nov 19 12:25:59 2007
@@ -0,0 +1,225 @@
+/*
+ * 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.Hashtable;
+
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.core.jndi.RegistryHelper;
+import org.apache.jackrabbit.ocm.exception.RepositoryException;
+import org.apache.jackrabbit.util.ISO9075;
+import org.apache.jackrabbit.util.Text;
+
+/**
+* Utility class for managing JCR repositories.
+* <b>Note</b>: most of the utility methods in this class can be used only with Jackrabbit.
+*
+* @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+* @version $Id: Exp $
+*/
+public class RepositoryUtil
+{
+    
+    /** namespace prefix constant */
+    public static final String OCM_NAMESPACE_PREFIX   = "ocm";
+
+    /** namespace constant */
+    public static final String OCM_NAMESPACE          = "http://jackrabbit.apache.org/ocm";    
+    
+    /** Item path separator */
+    public static final String PATH_SEPARATOR = "/";
+    
+    private final static Log log = LogFactory.getLog(RepositoryUtil.class);
+    
+    /**
+     * Register a new repository 
+     * 
+     * @param repositoryName The repository unique name
+     * @param configFile The JCR config file
+     * @param homeDir The directory containing the complete repository settings (workspace, node types, ...)
+     * 
+     * @throws RepositoryException when it is not possible to register the repository
+     */
+    public static void registerRepository(String repositoryName, String configFile, String homeDir) throws RepositoryException
+    {
+        try
+        {
+            Hashtable env = new Hashtable();
+            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
+            env.put(Context.PROVIDER_URL, "localhost");
+            InitialContext ctx = new InitialContext(env);
+
+            RegistryHelper.registerRepository(ctx, repositoryName, configFile, homeDir, true);
+        }
+        catch (Exception e)
+        {        
+            throw new RepositoryException("Impossible to register the respository : " + 
+                                           repositoryName + " - config file : " + configFile, e);
+        }        
+        
+    }
+    
+    
+    /**
+     * Unregister a repository 
+     * 
+     * @param repositoryName The repository unique name
+     * 
+     * @throws RepositoryException when it is not possible to unregister the repository
+     */
+    public static void unRegisterRepository(String repositoryName) throws RepositoryException
+    {
+        try
+        {
+        	Hashtable env = new Hashtable();
+            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
+            env.put(Context.PROVIDER_URL, "localhost");
+            InitialContext ctx = new InitialContext(env);
+
+            RegistryHelper.unregisterRepository(ctx, repositoryName);
+        }
+        catch (Exception e)
+        {
+            throw new RepositoryException("Impossible to unregister the respository : " + 
+                                           repositoryName , e);
+        }        
+        
+    }
+    
+    /**
+     * Get a repository
+     * 
+     * @param repositoryName The repository name
+     * @return a JCR repository reference
+     * 
+     * @throws RepositoryException when it is not possible to get the repository. 
+     *         Before calling this method, the repository has to be registered (@see RepositoryUtil#registerRepository(String, String, String)
+     */
+    public static Repository getRepository(String repositoryName) throws RepositoryException
+    {
+        try
+        {
+            Hashtable env = new Hashtable();
+            env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
+            env.put(Context.PROVIDER_URL, "localhost");
+            InitialContext ctx = new InitialContext(env);
+            
+            Repository repository = (Repository) ctx.lookup(repositoryName);
+            return repository;
+        }
+        catch (Exception e)
+        {
+            throw new RepositoryException("Impossible to get the repository : " + repositoryName, e);
+        }        
+    }
+    
+    /**
+     * Connect to a JCR repository
+     * 
+     * @param repository The JCR repository 
+     * @param user The user name
+     * @param password The password
+     * @return a valid JCR session 
+     * 
+     * @throws RepositoryException when it is not possible to connect to the JCR repository 
+     */
+    public static Session login(Repository repository, String user, String password) throws RepositoryException
+    {
+        try
+        {
+            Session session = repository.login(new SimpleCredentials(user, password.toCharArray()), null);
+            
+           
+            return session; 
+        }
+        catch (Exception e)
+        {
+            throw new RepositoryException("Impossible to login ", e);
+        }
+    }
+      
+    
+  
+
+    
+    /**
+     * Setup the session. 
+     * Until now, we check only if the namespace prefix exist in the repository
+     * 
+     */
+    public static void setupSession(Session session) throws RepositoryException
+    {
+         try
+         {
+        	log.info("Setup Jcr session setup ...");
+        	
+            String[] jcrNamespaces = session.getWorkspace().getNamespaceRegistry().getPrefixes();
+            boolean createNamespace = true;
+            for (int i = 0; i < jcrNamespaces.length; i++)
+            {
+                if (jcrNamespaces[i].equals(OCM_NAMESPACE_PREFIX))
+                {
+                    createNamespace = false;
+                    log.debug("Jackrabbit OCM namespace exists.");
+                }
+            }
+             
+            if (createNamespace)
+            {
+                session.getWorkspace().getNamespaceRegistry().registerNamespace(OCM_NAMESPACE_PREFIX, OCM_NAMESPACE);
+                log.info("Successfully created Jackrabbit OCM namespace.");
+            }
+            
+            if (session.getRootNode() != null)
+            {
+                log.info("Jcr session setup successfull.");
+            }
+            
+
+        }
+        catch (Exception e)
+        {
+            log.error("Error while setting up the jcr session.", e);
+            throw new RepositoryException(e.getMessage());
+        }
+    }
+
+    /**
+     * Encode a path 
+     * @TODO : drop Jackrabbit dependency
+     * 
+     * @param path the path to encode
+     * @return the encoded path 
+     * 
+     */
+    public static String encodePath(String path)
+    {
+    	String[] pathElements = Text.explode(path, '/');
+    	for (int i=0;i<pathElements.length;i++)
+    	{
+    		pathElements[i] = ISO9075.encode(pathElements[i]);
+    	}
+    	return "/" + Text.implode(pathElements, "/");
+    }
+}

Modified: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/spring-config/applicationContext-repository.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/spring-config/applicationContext-repository.xml?rev=596432&r1=596431&r2=596432&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/spring-config/applicationContext-repository.xml (original)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/spring-config/applicationContext-repository.xml Mon Nov 19 12:25:59 2007
@@ -12,7 +12,7 @@
 	<import resource="applicationContext-jr-local.xml"/>
 
 	
-	<bean id="jcrSessionFactory" class="org.apache.portals.graffito.jcr.spring.JackrabbitSessionFactory">
+	<bean id="jcrSessionFactory" class="org.apache.jackrabbit.ocm.spring.JackrabbitSessionFactory">
 		<property name="repository" ref="repository"/>
 		<property name="credentials">
 			<bean class="javax.jcr.SimpleCredentials">
@@ -34,11 +34,11 @@
 	</bean>
 	
 	
-	<bean id="jcrMappingDescriptor" class="org.apache.portals.graffito.jcr.mapper.impl.DigesterMapperImpl">
+	<bean id="jcrMappingDescriptor" class="org.apache.jackrabbit.ocm.mapper.impl.digester.DigesterMapperImpl">
 		<constructor-arg index="0" value="./src/test-config/jcrmapping.xml"/>
 	</bean>
 	
-	<bean id="jcrMappingTemplate" class="org.apache.portals.graffito.jcr.spring.JcrMappingTemplate">
+	<bean id="jcrMappingTemplate" class="org.apache.jackrabbit.ocm.spring.JcrMappingTemplate">
 		<constructor-arg index="0" ref="jcrSessionFactory"/>
 		<constructor-arg index="1" ref="jcrMappingDescriptor"/>
 	</bean>
@@ -56,18 +56,17 @@
 	</bean>	
 	
 	
-	<bean id="org.apache.portals.graffito.jcr.spring.test.components.impl.NewsServiceImpl" 
-	      class="org.apache.portals.graffito.jcr.spring.test.components.impl.NewsServiceImpl" >
+	<bean id="org.apache.jackrabbit.ocm.spring.test.components.impl.NewsServiceImpl"
+	      class="org.apache.jackrabbit.ocm.spring.test.components.impl.NewsServiceImpl" >
 		<property name="jcrMappingTemplate" ref="jcrMappingTemplate"/>					
 	</bean>		
 	
-	<bean id="org.apache.portals.graffito.jcr.spring.test.components.NewsService" parent="baseTransactionProxy" 
-	      name="org.apache.portals.graffito.jcr.spring.test.components.NewsService" >
+	<bean id="org.apache.jackrabbit.ocm.spring.test.components.NewsService" parent="baseTransactionProxy">
 		<property name="proxyInterfaces">
-			<value>org.apache.portals.graffito.jcr.spring.test.components.NewsService</value>
+			<value>org.apache.jackrabbit.ocm.spring.test.components.NewsService</value>
 		</property>
 		<property name="target">
-			<ref bean="org.apache.portals.graffito.jcr.spring.test.components.impl.NewsServiceImpl"/>
+			<ref bean="org.apache.jackrabbit.ocm.spring.test.components.impl.NewsServiceImpl"/>
 		</property>
 		<property name="transactionAttributes">
 			<props>
@@ -77,19 +76,18 @@
 		</property>
 	</bean>	   	
 
-	<bean id="org.apache.portals.graffito.jcr.spring.test.components.impl.ArticleServiceImpl" 
-	      class="org.apache.portals.graffito.jcr.spring.test.components.impl.ArticleServiceImpl" >
+	<bean id="org.apache.jackrabbit.ocm.spring.test.components.impl.ArticleServiceImpl"
+	      class="org.apache.jackrabbit.ocm.spring.test.components.impl.ArticleServiceImpl" >
 		<property name="jcrMappingTemplate" ref="jcrMappingTemplate"/>			
-		<property name="newsService" ref="org.apache.portals.graffito.jcr.spring.test.components.NewsService"/>			
+		<property name="newsService" ref="org.apache.jackrabbit.ocm.spring.test.components.NewsService"/>
 	</bean>		
 	
-	<bean id="org.apache.portals.graffito.jcr.spring.test.components.ArticleService" parent="baseTransactionProxy" 
-	      name="org.apache.portals.graffito.jcr.spring.test.components.ArticleService" >
+	<bean id="org.apache.jackrabbit.ocm.spring.test.components.ArticleService" parent="baseTransactionProxy">
 		<property name="proxyInterfaces">
-			<value>org.apache.portals.graffito.jcr.spring.test.components.ArticleService</value>
+			<value>org.apache.jackrabbit.ocm.spring.test.components.ArticleService</value>
 		</property>
 		<property name="target">
-			<ref bean="org.apache.portals.graffito.jcr.spring.test.components.impl.ArticleServiceImpl"/>
+			<ref bean="org.apache.jackrabbit.ocm.spring.test.components.impl.ArticleServiceImpl"/>
 		</property>
 		<property name="transactionAttributes">
 			<props>

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jackrabbit-ocm.dtd
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jackrabbit-ocm.dtd?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jackrabbit-ocm.dtd (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jackrabbit-ocm.dtd Mon Nov 19 12:25:59 2007
@@ -0,0 +1,165 @@
+<!--
+/*
+ * 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.
+ */
+-->
+
+<!ELEMENT jackrabbit-ocm (class-descriptor*)>
+
+<!ATTLIST jackrabbit-ocm package CDATA #IMPLIED>
+
+<!--
+    Class descriptor - Each class descriptor describes the mapping strategy used for one a java class
+    * className : the class name
+    * jcrType : the primary jcr node type, optional, default is nt:unstructured
+    * jcrSuperTypes : the jcr super types, optional
+    * jcrMixinTypes: the jcr mixin types (comma separated list) (optional)
+    * extends: name of super class (optional)
+    * abstract: true if this class is abstract and it is used in hierarchy mappings
+    * discriminator true if the mapped node  requires  an ocm:discriminator node type. This type contains a classname property.
+-->
+<!ELEMENT class-descriptor (implement-descriptor*, field-descriptor*, bean-descriptor*, collection-descriptor*)>
+
+<!ATTLIST class-descriptor
+	className CDATA #REQUIRED
+	jcrType CDATA #IMPLIED
+    jcrSuperTypes CDATA #IMPLIED
+    jcrMixinTypes CDATA #IMPLIED
+    extend CDATA #IMPLIED
+	abstract (true|false) "false"
+	interface (true|false) "false"
+	discriminator (true|false) "true"
+>
+
+<!--
+   Implement descriptor - This descriptor matches to one java  interface implemented by the class descriptor
+   interfaceName : the full interface name
+-->
+<!ELEMENT implement-descriptor EMPTY>
+
+<!ATTLIST implement-descriptor
+	interfaceName CDATA #REQUIRED
+>
+
+<!--
+    Field descriptor - A field descriptor maps one atomic object attribute (primitive types, String, Long, ...)  into a JCR property
+    * fieldName : the field/attribute name
+    * jcrName : the jcr property name (optional). If it is not defined, fieldname is used to specify the jcr property name
+    * id : specifies if the field is an id. Id is optional. If the class contains an id field, some process can run faster
+    * path : specified if the field is the object path
+    * uuid : specified if the field is the object uuid
+    * converter : AtomicTypeConverter class name to used for this field descriptor. If not defined, a default one is provided by default in function of the field type
+    * jcrDefaultValue : if the field is null, this default value will be used, optional
+    * jcrValueConstraints : a comma separated list of acceptable values, optional
+    * jcrType: specifies the JCR property type (supported jcr property types: String , Date , Long , Doube , Boolean , Binary), optional
+    * jcrAutoCreated: specifies if this JCR property will be autocreated (true/false / default is false), optional
+    * jcrMandatory: specifies if this JCR property is mandatory (true/false / default is false), optional
+    * jcrOnParentVersion: specifies how this JCR property acts on inherited versioned node properties (default is COPY), optional
+    * jcrProtected: specifies if this JCR node property is protected (true/false / default is false), optional
+    * jcrMultiple: specifies if this JCR node property is a multivalued property (true/false / default is false), optional
+-->
+
+<!ELEMENT field-descriptor EMPTY>
+<!ATTLIST field-descriptor
+	fieldName CDATA #REQUIRED
+	jcrName CDATA #IMPLIED 
+	id (true | false) "false"
+	path (true | false) "false"
+	uuid (true | false) "false"
+	converter CDATA #IMPLIED
+	jcrDefaultValue CDATA #IMPLIED
+	jcrValueConstraints CDATA #IMPLIED 
+    jcrType (String | Date | Long | Doube | Boolean | Binary) #IMPLIED
+    jcrAutoCreated (true | false) "false"
+    jcrMandatory (true | false) "false"
+    jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
+    jcrProtected (true | false) "false"
+    jcrMultiple (true | false) "false"
+>
+
+<!--
+    Bean descriptor - A bean descriptor maps one "complex" object attribute into a JCR node.
+    * fieldName : the field/attribute name
+    * jcrName : the jcr node name (optional). If it is not defined, fieldname is used to specify the jcr node name
+    * proxy : Use lazy loading or not. if true, this attributes is not loaded when the main object is retrieved. it will be loaded when the get method is called.
+    * autoRetrieve : If false, the bean associated to this descriptor is not retrieved when the main ojbect is retrieved
+    * autoUpdate : If false, the bean associated to this descriptor is not updated when the main ojbect is updated
+    * autoInsert : If false, the bean associated to this descriptor is not inserted  when the main ojbect is inserted    
+    * converter: fully qualified name of the converter class to be used (default is ObjectConverterImpl)
+    * jcrType: defines the node type, optional, nt:unstructured by default
+    * jcrAutoCreated (boolean) default is "false"
+    * jcrMandatory (boolean) default is "false"
+    * jcrOnParentVersion default is "COPY"
+    * jcrProtected (boolean) default is "false"
+    * jcrSameNameSiblings (boolean) default is "false"   
+-->
+<!ELEMENT bean-descriptor EMPTY>
+<!ATTLIST bean-descriptor
+	fieldName CDATA #REQUIRED
+	jcrName CDATA #IMPLIED 
+	proxy (true | false) "false" 
+	autoRetrieve (true|false) "true"
+	autoUpdate (true|false) "true"
+	autoInsert (true|false) "true"	
+	converter CDATA #IMPLIED
+	jcrType CDATA #IMPLIED
+    jcrAutoCreated (true | false) "false"   
+    jcrMandatory (true | false) "false"
+    jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
+    jcrProtected (true | false) "false"
+    jcrSameNameSiblings (true | false) "false"         
+>
+
+<!--
+    Collection descriptor - A collection descriptor maps one object attribute based on a collection (or a map) into a series of JCR nodes.
+    * fieldName : the field/attribute name (matching to the collection attribute), this attribute is used only with some collection converters.
+    * jcrName : the jcr property name (optional). If it is not defined, fieldname is used to specify the jcr node name
+    * proxy : Use lazy loading or not. if true, this attributes is not loaded when the main object is retrieve. it will be loaded when the get method is called.
+    * autoRetrieve : If false, the collection associated to this descriptor is not retrieved when the main ojbect is retrieved
+    * autoUpdate : If false, the collection associated to this descriptor is not updated when the main ojbect is updated
+    * autoInsert : If false, the collection associated to this descriptor is not inserted  when the main ojbect is inserted    
+    * elementClassName : contains a fully qualified class name.	This class is the Object type of the persistent collection elements.
+    * collectionClassName : contains a fully qualified class name. This class must be the Java type of the Collection attribute. 	
+                            This attribute must only specified if the attribute type is not a java.util.Collection (or subclass). 
+                            The declared class must implement ManageableCollection to let the ocm engine handles this type of collection.
+    * collectionConverter : The class name converter. This is the collection mapping strategy to used. 
+                            If this attribute is not specify, the default collection mapping strategy is used (DefaultCollectionConverterImpl)                            
+    * jcrType: defines the node type used for the collection elements, optional
+    * jcrAutoCreated (boolean) default is "false"
+    * jcrMandatory (boolean) default is "false"
+    * jcrOnParentVersion default is "COPY"
+    * jcrProtected (boolean) default is "false"
+    * jcrSameNameSiblings (boolean) default is "false"
+-->
+
+<!ELEMENT collection-descriptor EMPTY>
+<!ATTLIST collection-descriptor
+	fieldName CDATA #REQUIRED
+	jcrName CDATA #IMPLIED 
+	proxy (true | false) "false"
+	autoRetrieve (true|false) "true"
+	autoUpdate (true|false) "true"
+	autoInsert (true|false) "true"	
+	elementClassName CDATA #IMPLIED
+	collectionClassName CDATA #IMPLIED
+	collectionConverter CDATA #IMPLIED
+	jcrType CDATA #IMPLIED
+    jcrAutoCreated (true | false) "false"   
+    jcrMandatory (true | false) "false"
+    jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
+    jcrProtected (true | false) "false"
+    jcrSameNameSiblings (true | false) "false"	
+>

Modified: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jcrmapping.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jcrmapping.xml?rev=596432&r1=596431&r2=596432&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jcrmapping.xml (original)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test-config/jcrmapping.xml Mon Nov 19 12:25:59 2007
@@ -1,23 +1,21 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE graffito-jcr PUBLIC "-//The Apache Software Foundation//DTD Repository//EN" "./src/test-config/graffito-jcr-mapping.dtd">
-<graffito-jcr>
-    
-  
-	<class-descriptor className="org.apache.portals.graffito.jcr.spring.test.model.News"   discriminator="true">
-		<field-descriptor fieldName="path" path="true" />
-		<field-descriptor fieldName="creationDate" jcrName="graffito:creationDate" />
-		<field-descriptor fieldName="content" jcrName="graffito:content" />
-	</class-descriptor>
+<?xml version="1.0" encoding="UTF-8"?>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.spring.test.model.Article"  discriminator="true">		
+<!DOCTYPE graffito-jcr PUBLIC "-//The Apache Software Foundation//DTD Repository//EN" "./src/test-config/jackrabbit-ocm.dtd">
+<jackrabbit-ocm>
+	<class-descriptor className="org.apache.jackrabbit.ocm.spring.test.model.News"   discriminator="true">
 		<field-descriptor fieldName="path" path="true" />
-		<field-descriptor fieldName="title" jcrName="graffito:title" />
-		<field-descriptor fieldName="description" jcrName="graffito:description" />		
-		<field-descriptor fieldName="author" jcrName="graffito:author" />
-		<field-descriptor fieldName="creationDate" jcrName="graffito:creationDate" />
-		<field-descriptor fieldName="content" jcrName="graffito:content" />						
+		<field-descriptor fieldName="creationDate" jcrName="creationDate" />
+		<field-descriptor fieldName="content" jcrName="content" />
 	</class-descriptor>
-
-</graffito-jcr>
+
+	<class-descriptor className="org.apache.jackrabbit.ocm.spring.test.model.Article"  discriminator="true">		
+		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="title" jcrName="title" />
+		<field-descriptor fieldName="description" jcrName="description" />		
+		<field-descriptor fieldName="author" jcrName="author" />
+		<field-descriptor fieldName="creationDate" jcrName="creationDate" />
+		<field-descriptor fieldName="content" jcrName="content" />						
+	</class-descriptor>
+
+</jackrabbit-ocm>
  

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/SimpleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/SimpleTest.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/SimpleTest.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/SimpleTest.java Mon Nov 19 12:25:59 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 <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class SimpleTest extends TestCase
+{
+
+    
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @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

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/ArticleService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/ArticleService.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/ArticleService.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/ArticleService.java Mon Nov 19 12:25:59 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 <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ *
+ */
+public interface ArticleService
+{
+	public void createArticle(Article article);
+
+	public Collection getArticles();
+}

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/NewsService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/NewsService.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/NewsService.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/NewsService.java Mon Nov 19 12:25:59 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 <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ *
+ */
+public interface NewsService
+{
+	public void createNews(News news);
+
+	public Collection getNews();
+}

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/ArticleServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/ArticleServiceImpl.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/ArticleServiceImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/ArticleServiceImpl.java Mon Nov 19 12:25:59 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 <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ *
+ */
+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;
+    }
+    
+    
+    
+}

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/NewsServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/NewsServiceImpl.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/NewsServiceImpl.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/components/impl/NewsServiceImpl.java Mon Nov 19 12:25:59 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 <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ *
+ */
+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;
+    }
+    
+    
+    
+}

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/Article.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/Article.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/Article.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/Article.java Mon Nov 19 12:25:59 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 <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ */
+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;
+	}
+
+
+}
+

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/News.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/News.java?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/News.java (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/java/org/apache/jackrabbit/ocm/spring/test/model/News.java Mon Nov 19 12:25:59 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 <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ */
+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;
+	}
+
+}
+

Added: jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/resources/log4j.properties?rev=596432&view=auto
==============================================================================
--- jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/resources/log4j.properties (added)
+++ jackrabbit/sandbox/jackrabbit-jcr-mapping/spring/src/test/resources/log4j.properties Mon Nov 19 12:25:59 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



Mime
View raw message