Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 21966 invoked from network); 6 Aug 2008 14:11:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Aug 2008 14:11:11 -0000 Received: (qmail 748 invoked by uid 500); 6 Aug 2008 14:11:11 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 716 invoked by uid 500); 6 Aug 2008 14:11:11 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 707 invoked by uid 99); 6 Aug 2008 14:11:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2008 07:11:10 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Aug 2008 14:10:23 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id DA57B2388986; Wed, 6 Aug 2008 07:10:50 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080806141050.DA57B2388986@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ *

* 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". *

* 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 java.naming.Reference objects as keys and * storing soft references to BindableRepository instances */ - private static Map cache = new ReferenceMap(); + private static final Map cache = new ReferenceMap(); /** * {@inheritDoc}