jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r551674 - in /jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src: main/java/org/apache/jackrabbit/ocm/manager/impl/ main/java/org/apache/jackrabbit/ocm/repository/ test/java/org/apache/jackrabbit/ocm/repository/
Date Thu, 28 Jun 2007 19:30:25 GMT
Author: clombart
Date: Thu Jun 28 12:30:24 2007
New Revision: 551674

URL: http://svn.apache.org/viewvc?view=rev&rev=551674
Log:
check and load the ocm namespace from the ObjectContentManagerImpl

Modified:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/repository/RepositoryUtil.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/repository/RepositoryUtilTest.java

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java?view=diff&rev=551674&r1=551673&r2=551674
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/impl/ObjectContentManagerImpl.java
Thu Jun 28 12:30:24 2007
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.ocm.manager.impl;
 
 
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -59,6 +60,7 @@
 import org.apache.jackrabbit.ocm.query.Query;
 import org.apache.jackrabbit.ocm.query.QueryManager;
 import org.apache.jackrabbit.ocm.query.impl.QueryManagerImpl;
+import org.apache.jackrabbit.ocm.repository.RepositoryUtil;
 import org.apache.jackrabbit.ocm.version.Version;
 import org.apache.jackrabbit.ocm.version.VersionIterator;
 import org.apache.jackrabbit.ocm.lock.Lock;
@@ -116,6 +118,8 @@
         this.requestObjectCache = new RequestObjectCacheImpl();        
         this.objectConverter = new ObjectConverterImpl(mapper, new DefaultAtomicTypeConverterProvider(),
new ProxyManagerImpl(), requestObjectCache);
         this.queryManager = queryManager;
+        
+        RepositoryUtil.setupSession(session);
 
     }
 
@@ -136,6 +140,8 @@
 			this.queryManager = new QueryManagerImpl(mapper, atomicTypeConverters, session.getValueFactory());
 			this.requestObjectCache = new RequestObjectCacheImpl();        
 			this.objectConverter = new ObjectConverterImpl(mapper, converterProvider, new ProxyManagerImpl(),
requestObjectCache);
+			
+			RepositoryUtil.setupSession(session);
 		} 
         catch (RepositoryException e) 
         {
@@ -146,6 +152,34 @@
         
     }
     
+    /**
+     * Creates a new <code>ObjectContentManager</code> based on a JCR session
and some xml mapping files. 
+     *
+     * @param session The JCR session
+     * @param xmlMappingFiles the JCR mapping files used mainly to create the <code>Mapper</code>
component
+     */
+    public ObjectContentManagerImpl(Session session,InputStream[] xmlMappingFiles ) 
+    {
+        try 
+        {
+			this.session = session;
+			this.mapper = new DigesterMapperImpl(xmlMappingFiles);
+			DefaultAtomicTypeConverterProvider converterProvider = new DefaultAtomicTypeConverterProvider();
+			Map atomicTypeConverters = converterProvider.getAtomicTypeConverters();
+			this.queryManager = new QueryManagerImpl(mapper, atomicTypeConverters, session.getValueFactory());
+			this.requestObjectCache = new RequestObjectCacheImpl();        
+			this.objectConverter = new ObjectConverterImpl(mapper, converterProvider, new ProxyManagerImpl(),
requestObjectCache);
+			
+			RepositoryUtil.setupSession(session);
+		} 
+        catch (RepositoryException e) 
+        {
+            throw new org.apache.jackrabbit.ocm.exception.RepositoryException(
+                    "Impossible to instantiate the object content manager", e);
+
+		}
+        
+    }
     
     /**
      * Full constructor.
@@ -165,6 +199,8 @@
         this.objectConverter = converter;
         this.queryManager = queryManager;
         this.requestObjectCache = requestObjectCache;
+        
+        RepositoryUtil.setupSession(session);
     }
     
     /**

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/repository/RepositoryUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/repository/RepositoryUtil.java?view=diff&rev=551674&r1=551673&r2=551674
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/repository/RepositoryUtil.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/repository/RepositoryUtil.java
Thu Jun 28 12:30:24 2007
@@ -151,7 +151,7 @@
         try
         {
             Session session = repository.login(new SimpleCredentials(user, password.toCharArray()),
null);
-            setupSession(session);
+            
            
             return session; 
         }
@@ -240,10 +240,12 @@
      * Until now, we check only if the namespace prefix exist in the repository
      * 
      */
-    private static void setupSession(Session session) throws RepositoryException
+    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++)
@@ -263,14 +265,14 @@
             
             if (session.getRootNode() != null)
             {
-                log.info("Jcr repository setup successfull.");
+                log.info("Jcr session setup successfull.");
             }
             
 
         }
         catch (Exception e)
         {
-            log.error("Error while setting up the jcr repository.", e);
+            log.error("Error while setting up the jcr session.", e);
             throw new RepositoryException(e.getMessage());
         }
     }

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/repository/RepositoryUtilTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/repository/RepositoryUtilTest.java?view=diff&rev=551674&r1=551673&r2=551674
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/repository/RepositoryUtilTest.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/repository/RepositoryUtilTest.java
Thu Jun 28 12:30:24 2007
@@ -98,7 +98,13 @@
             Session session = RepositoryUtil.login(repository, "superuser", "superuser");
             Node root = session.getRootNode();
             assertNotNull("Root node is null", root);
+            
+            Session session2 = RepositoryUtil.login(repository, "superuser", "superuser");
+            root = session2.getRootNode();
+            assertNotNull("Root node is null", root);
+            
             session.logout();
+            session2.logout();
         }
         catch (Exception e)
         {



Mime
View raw message