jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r409597 - in /jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi: BindableRepository.java BindableRepositoryFactory.java RegistryHelper.java
Date Fri, 26 May 2006 09:03:12 GMT
Author: jukka
Date: Fri May 26 02:03:11 2006
New Revision: 409597

URL: http://svn.apache.org/viewvc?rev=409597&view=rev
Log:
1.0: Merged revision 397583: JCR-411

Modified:
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
    jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/RegistryHelper.java

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java?rev=409597&r1=409596&r2=409597&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
Fri May 26 02:03:11 2006
@@ -24,7 +24,6 @@
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.naming.NamingException;
 import javax.naming.Reference;
 import javax.naming.Referenceable;
 import javax.naming.StringRefAddr;
@@ -40,18 +39,18 @@
  * delays the instantiation of the actual Repository instance and
  * implements serialization and JNDI referenceability by keeping
  * track of the repository configuration parameters.
- * <p>
+ * <p/>
  * A BindableRepository instance contains the configuration file
  * and home directory paths of a Jackrabbit repository. The separate
  * {@link #init() init()} method is used to create a transient
  * {@link RepositoryImpl RepositoryImpl} instance to which all the
  * JCR API calls are delegated.
- * <p>
+ * <p/>
  * An instance of this class is normally always also initialized.
  * The uninitialized state is only used briefly during the static
  * {@link #create(String, String) create} method and during
  * serialization and JNDI "referenciation".
- * <p>
+ * <p/>
  * A JVM shutdown hook is used to make sure that the initialized
  * repository is properly closed when the JVM shuts down. The
  * {@link RegistryHelper#unregisterRepository(javax.naming.Context, String)}
@@ -60,13 +59,19 @@
  */
 class BindableRepository implements Repository, Referenceable, Serializable {
 
-    /** The serialization UID of this class. */
+    /**
+     * The serialization UID of this class.
+     */
     static final long serialVersionUID = -2298220550793843166L;
 
-    /** The repository configuration file path. */
+    /**
+     * The repository configuration file path.
+     */
     private final String configFilePath;
 
-    /** The repository home directory path. */
+    /**
+     * The repository home directory path.
+     */
     private final String repHomeDir;
 
     /**
@@ -78,7 +83,9 @@
      */
     static final String REPHOMEDIR_ADDRTYPE = "repHomeDir";
 
-    /** The delegate repository instance. Created by {@link #init() init}. */
+    /**
+     * The delegate repository instance. Created by {@link #init() init}.
+     */
     private transient Repository delegatee;
 
     /**
@@ -92,7 +99,7 @@
      * information, but does not create the underlying repository instance.
      *
      * @param configFilePath repository configuration file path
-     * @param repHomeDir repository home directory path
+     * @param repHomeDir     repository home directory path
      */
     private BindableRepository(String configFilePath, String repHomeDir) {
         this.configFilePath = configFilePath;
@@ -105,7 +112,7 @@
      * configuration information.
      *
      * @param configFilePath repository configuration file path
-     * @param repHomeDir repository home directory path
+     * @param repHomeDir     repository home directory path
      * @return initialized repository instance
      * @throws RepositoryException if the repository cannot be created
      */
@@ -125,7 +132,7 @@
      */
     private void init() throws RepositoryException {
         RepositoryConfig config =
-            RepositoryConfig.create(configFilePath, repHomeDir);
+                RepositoryConfig.create(configFilePath, repHomeDir);
         delegatee = RepositoryImpl.create(config);
         hook = new Thread() {
             public void run() {
@@ -197,11 +204,9 @@
      * copy of this instance.
      *
      * @return the created JNDI reference
-     * @throws NamingException on JNDI errors
      */
-    public Reference getReference() throws NamingException {
-        Reference ref = new Reference(
-                BindableRepository.class.getName(),
+    public Reference getReference() {
+        Reference ref = new Reference(BindableRepository.class.getName(),
                 BindableRepositoryFactory.class.getName(),
                 null); // no classpath defined
         ref.add(new StringRefAddr(CONFIGFILEPATH_ADDRTYPE, configFilePath));
@@ -232,8 +237,8 @@
      * {@link #init() init} method.
      *
      * @param in the serialization stream
-     * @throws IOException if configuration information cannot be deserialized
-     *                     or if the configured repository cannot be created
+     * @throws IOException            if configuration information cannot be deserialized
+     *                                or if the configured repository cannot be created
      * @throws ClassNotFoundException on deserialization errors
      */
     private void readObject(ObjectInputStream in)

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java?rev=409597&r1=409596&r2=409597&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
Fri May 26 02:03:11 2006
@@ -17,6 +17,7 @@
 
 import org.apache.commons.collections.map.ReferenceMap;
 
+import javax.jcr.RepositoryException;
 import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.Reference;
@@ -43,6 +44,22 @@
     public BindableRepositoryFactory() {
     }
 
+    /**
+     * Creates an initialized BindableRepository instance using the given
+     * configuration information and puts it in {@link #cache}.
+     *
+     * @param configFilePath repository configuration file path
+     * @param repHomeDir     repository home directory path
+     * @return initialized repository instance
+     * @throws RepositoryException if the repository cannot be created
+     */
+    static BindableRepository createInstance(String configFilePath, String repHomeDir)
+            throws RepositoryException {
+        BindableRepository rep = BindableRepository.create(configFilePath, repHomeDir);
+        cache.put(rep.getReference(), rep);
+        return rep;
+    }
+
     //--------------------------------------------------------< ObjectFactory >
     /**
      * {@inheritDoc}
@@ -60,9 +77,7 @@
                             (String) ref.get(BindableRepository.CONFIGFILEPATH_ADDRTYPE).getContent();
                     String repHomeDir =
                             (String) ref.get(BindableRepository.REPHOMEDIR_ADDRTYPE).getContent();
-                    BindableRepository rep = BindableRepository.create(configFilePath, repHomeDir);
-                    cache.put(ref, rep);
-                    return rep;
+                    return createInstance(configFilePath, repHomeDir);
                 }
             }
         }

Modified: jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/RegistryHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/RegistryHelper.java?rev=409597&r1=409596&r2=409597&view=diff
==============================================================================
--- jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/RegistryHelper.java
(original)
+++ jackrabbit/branches/1.0/jackrabbit/src/main/java/org/apache/jackrabbit/core/jndi/RegistryHelper.java
Fri May 26 02:03:11 2006
@@ -53,7 +53,10 @@
                                           String repHomeDir,
                                           boolean overwrite)
             throws NamingException, RepositoryException {
-        Object obj = BindableRepository.create(configFilePath, repHomeDir);
+        // always create instance by using BindableRepositoryFactory
+        // which maintains an instance cache;
+        // see http://issues.apache.org/jira/browse/JCR-411 for details
+        Object obj = BindableRepositoryFactory.createInstance(configFilePath, repHomeDir);
         if (overwrite) {
             ctx.rebind(name, obj);
         } else {



Mime
View raw message