You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2009/01/14 15:08:04 UTC
svn commit: r734403 - in /jackrabbit/branches/1.4/jackrabbit-core: ./
src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
Author: jukka
Date: Wed Jan 14 06:07:44 2009
New Revision: 734403
URL: http://svn.apache.org/viewvc?rev=734403&view=rev
Log:
1.4: Merged revision 683268 (JCR-1664/JCR-1935). Added support for subclasses that still override the previous getRepository signature.
Modified:
jackrabbit/branches/1.4/jackrabbit-core/ (props changed)
jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
Propchange: jackrabbit/branches/1.4/jackrabbit-core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 14 06:07:44 2009
@@ -1 +1 @@
-/jackrabbit/trunk/jackrabbit-core:653417,654078,654514,655917,656240,656655,656664,658583,668086,668147,672125,678788,679389,680135,681031,681287,682409,686688,691181,691550,694164,698200,698209,727402,733080,734366
+/jackrabbit/trunk/jackrabbit-core:653417,654078,654514,655917,656240,656655,656664,658583,668086,668147,672125,678788,679389,680135,681031,681287,682409,683268,686688,691181,691550,694164,698200,698209,727402,733080,734366
Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java?rev=734403&r1=734402&r2=734403&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java (original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepository.java Wed Jan 14 06:07:44 2009
@@ -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,14 +123,22 @@
}
/**
- * 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 createRepository()
+ throws RepositoryException {
+ return getRepository(reference);
+ }
+
+ // JCR-1644: Required for compatibility with subclasses that used to
+ // override this older signature of the createRepository method.
protected JackrabbitRepository getRepository(Reference reference)
throws RepositoryException {
RepositoryConfig config = RepositoryConfig.create(
@@ -140,6 +147,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 +165,7 @@
*/
public Session login(Credentials credentials, String workspaceName)
throws LoginException, NoSuchWorkspaceException, RepositoryException {
- return delegatee.login(credentials, workspaceName);
+ return repository.login(credentials, workspaceName);
}
/**
@@ -156,7 +173,7 @@
* {@inheritDoc}
*/
public String getDescriptor(String key) {
- return delegatee.getDescriptor(key);
+ return repository.getDescriptor(key);
}
/**
@@ -164,7 +181,7 @@
* {@inheritDoc}
*/
public String[] getDescriptorKeys() {
- return delegatee.getDescriptorKeys();
+ return repository.getDescriptorKeys();
}
//--------------------------------------------------------< Referenceable >
@@ -212,7 +229,7 @@
* Delegated to the underlying repository instance.
*/
public void shutdown() {
- delegatee.shutdown();
+ repository.shutdown();
try {
Runtime.getRuntime().removeShutdownHook(hook);
} catch (IllegalStateException e) {
Modified: jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java?rev=734403&r1=734402&r2=734403&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java (original)
+++ jackrabbit/branches/1.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/jndi/BindableRepositoryFactory.java Wed Jan 14 06:07:44 2009
@@ -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}