jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r683268 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi: BindableRepository.java BindableRepositoryFactory.java
Date Wed, 06 Aug 2008 14:10:50 GMT
Author: jukka
Date: Wed Aug  6 07:10:49 2008
New Revision: 683268

URL: http://svn.apache.org/viewvc?rev=683268&view=rev
Log:
JCR-1644: JNDI Referencable Issues

Updated BindableRepository to better support subclasses.

Also some minor updates like making BindableRepositoryFactory.cache final.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java?rev=683268&r1=683267&r2=683268&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
Wed Aug  6 07:10:49 2008
@@ -49,8 +49,7 @@
  * <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".
+ * construction, deserialization, and JNDI "referenciation".
  * <p/>
  * A JVM shutdown hook is used to make sure that the initialized
  * repository is properly closed when the JVM shuts down. The
@@ -86,7 +85,7 @@
     /**
      * The delegate repository instance. Created by {@link #init() init}.
      */
-    private transient JackrabbitRepository delegatee;
+    private transient JackrabbitRepository repository;
 
     /**
      * Thread that is registered as shutdown hook after {@link #init} has been
@@ -95,11 +94,11 @@
     private transient Thread hook;
 
     /**
-     * Creates a BindableRepository instance with the given configuration
-     * information, but does not create the underlying repository instance.
+     * Creates a BindableRepository instance with the configuration
+     * information in the given JNDI reference.
      *
-     * @param configFilePath repository configuration file path
-     * @param repHomeDir     repository home directory path
+     * @param reference JNDI reference
+     * @throws RepositoryException if the repository can not be started
      */
     public BindableRepository(Reference reference) throws RepositoryException {
         this.reference = reference;
@@ -113,8 +112,8 @@
      *
      * @throws RepositoryException if the repository cannot be created
      */
-    protected void init() throws RepositoryException {
-        delegatee = getRepository(reference);
+    private void init() throws RepositoryException {
+        repository = createRepository();
         hook = new Thread() {
             public void run() {
                 shutdown();
@@ -124,15 +123,16 @@
     }
 
     /**
-     * Creates a repository instance based on the given reference. Can be
-     * overridden by subclasses to return different repositories. The default
-     * implementation returns a {@link RepositoryImpl} instance.
+     * Creates a repository instance based on the contained JNDI reference.
+     * Can be overridden by subclasses to return different repositories.
+     * A subclass can access the JNDI reference through the
+     * {@link #getReference()} method. The default implementation
+     * returns a {@link RepositoryImpl} instance.
      *
-     * @param reference repository reference
      * @return repository instance
      * @throws RepositoryException if the repository could not be created
      */
-    protected JackrabbitRepository getRepository(Reference reference)
+    protected JackrabbitRepository createRepository()
             throws RepositoryException {
         RepositoryConfig config = RepositoryConfig.create(
                 reference.get(CONFIGFILEPATH_ADDRTYPE).getContent().toString(),
@@ -140,6 +140,16 @@
         return RepositoryImpl.create(config);
     }
 
+    /**
+     * Returns the underlying repository instance. Can be used by subclasses
+     * to access the repository instance.
+     *
+     * @return repository instance
+     */
+    protected JackrabbitRepository getRepository() {
+        return repository;
+    }
+
     //-----------------------------------------------------------< Repository >
 
     /**
@@ -148,7 +158,7 @@
      */
     public Session login(Credentials credentials, String workspaceName)
             throws LoginException, NoSuchWorkspaceException, RepositoryException {
-        return delegatee.login(credentials, workspaceName);
+        return repository.login(credentials, workspaceName);
     }
 
     /**
@@ -156,7 +166,7 @@
      * {@inheritDoc}
      */
     public String getDescriptor(String key) {
-        return delegatee.getDescriptor(key);
+        return repository.getDescriptor(key);
     }
 
     /**
@@ -164,7 +174,7 @@
      * {@inheritDoc}
      */
     public String[] getDescriptorKeys() {
-        return delegatee.getDescriptorKeys();
+        return repository.getDescriptorKeys();
     }
 
     //--------------------------------------------------------< Referenceable >
@@ -212,7 +222,7 @@
      * Delegated to the underlying repository instance.
      */
     public void shutdown() {
-        delegatee.shutdown();
+        repository.shutdown();
         try {
             Runtime.getRuntime().removeShutdownHook(hook);
         } catch (IllegalStateException e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java?rev=683268&r1=683267&r2=683268&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
Wed Aug  6 07:10:49 2008
@@ -37,7 +37,7 @@
      * cache using <code>java.naming.Reference</code> objects as keys and
      * storing soft references to <code>BindableRepository</code> instances
      */
-    private static Map cache = new ReferenceMap();
+    private static final Map cache = new ReferenceMap();
 
     /**
      * {@inheritDoc}



Mime
View raw message