svn commit: r966077 - in /ofbiz/branches/jackrabbit20100709/framework/jackrabbit: config/ src/org/ofbiz/jackrabbit/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r966077 - in /ofbiz/branches/jackrabbit20100709/framework/jackrabbit: config/ src/org/ofbiz/jackrabbit/

adrianc
Author: adrianc
Date: Wed Jul 21 03:51:20 2010
New Revision: 966077

URL: http://svn.apache.org/viewvc?rev=966077&view=rev
Log:
Small improvement to RepositoryFactory.java, plus added some documentation.

Modified:
    ofbiz/branches/jackrabbit20100709/framework/jackrabbit/config/jcr-repositories.xml
    ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/JcrRepositoryFactory.java
    ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/LocalRepositoryFactory.java
    ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/RepositoryFactory.java

Modified: ofbiz/branches/jackrabbit20100709/framework/jackrabbit/config/jcr-repositories.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jackrabbit/config/jcr-repositories.xml?rev=966077&r1=966076&r2=966077&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jackrabbit/config/jcr-repositories.xml (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jackrabbit/config/jcr-repositories.xml Wed Jul 21 03:51:20 2010
@@ -17,6 +17,15 @@ KIND, either express or implied.  See th
 specific language governing permissions and limitations
 under the License.
 -->
+
+<!-- Any number of JCR repositories can be configured in this file,
+     and this file can be located anywhere in the Java classpath.
+
+      Each repository must have a unique name, and there must
+      be one repository named "default" - which is used when
+      no repository name is specified.
+ -->
+
 <jcr-repositories xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
     <!-- A JCR Repository located using JNDI -->
@@ -24,7 +33,8 @@ under the License.
 
     <!-- A JCR Repository created from a factory. The
          class-name attribute contains the name of a class that
-         implements JcrRepositoryFactory. -->
+         implements JcrRepositoryFactory. The name attribute is
+         passed to the factory's getInstance method. -->
     <!--
     <repository name="foo" class-name="com.mydomain.fooRepoFactory"/>
     -->

Modified: ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/JcrRepositoryFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/JcrRepositoryFactory.java?rev=966077&r1=966076&r2=966077&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/JcrRepositoryFactory.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/JcrRepositoryFactory.java Wed Jul 21 03:51:20 2010
@@ -21,5 +21,10 @@ package org.ofbiz.jackrabbit;
 import javax.jcr.Repository;
 
 public interface JcrRepositoryFactory {
-    Repository getInstance();
+    /**
+     *
+     * @param repositoryName The name specified in the <code>jcr-repositories.xml</code> file
+     * @return
+     */
+    Repository getInstance(String repositoryName);
 }

Modified: ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/LocalRepositoryFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/LocalRepositoryFactory.java?rev=966077&r1=966076&r2=966077&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/LocalRepositoryFactory.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/LocalRepositoryFactory.java Wed Jul 21 03:51:20 2010
@@ -27,7 +27,7 @@ import javax.naming.Reference;
 import javax.naming.spi.ObjectFactory;
 
 /**
- * An <code>ObjectFactory</code> that returns a <code>javax.jcr.Repository</code>
+ * A JNDI <code>ObjectFactory</code> that returns a <code>javax.jcr.Repository</code>
  * instance.
  */
 public class LocalRepositoryFactory implements ObjectFactory {

Modified: ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/RepositoryFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/RepositoryFactory.java?rev=966077&r1=966076&r2=966077&view=diff
==============================================================================
--- ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/RepositoryFactory.java (original)
+++ ofbiz/branches/jackrabbit20100709/framework/jackrabbit/src/org/ofbiz/jackrabbit/RepositoryFactory.java Wed Jul 21 03:51:20 2010
@@ -41,9 +41,9 @@ public class RepositoryFactory {
     public static final String module = RepositoryFactory.class.getName();
     private static final Map<String, Repository> repositoryMap = createRepositoryMap();
 
-    private static Repository createFromFactory(ClassLoader loader, String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+    private static Repository createFromFactory(String repositoryName, ClassLoader loader, String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
         JcrRepositoryFactory factory = (JcrRepositoryFactory) loader.loadClass(className).newInstance();
-        return factory.getInstance();
+        return factory.getInstance(repositoryName);
     }
     
     private static Map<String, Repository> createRepositoryMap() {
@@ -53,10 +53,22 @@ public class RepositoryFactory {
         return Collections.unmodifiableMap(result);
     }
 
+    /**
+     * Returns the default repository.
+     *
+     * @return
+     */
     public static Repository getRepository() {
         return repositoryMap.get("default");
     }
 
+    /**
+     * Returns the specified repository, or <code>null</code> if the
+     * specified repository doesn't exist.
+     *
+     * @param name
+     * @return
+     */
     public static Repository getRepository(String name) {
         return repositoryMap.get(name);
     }
@@ -99,7 +111,7 @@ public class RepositoryFactory {
                 String className = element.getAttribute("class-name");
                 if (UtilValidate.isNotEmpty(className)) {
                     try {
-                        map.put(name, createFromFactory(loader, className));
+                        map.put(name, createFromFactory(name, loader, className));
                     } catch (Exception e) {
                         Debug.logError(e, module);
                     }