org.apache.jackrabbit.core.jndi
Class BindableRepository

java.lang.Object
  extended by org.apache.jackrabbit.core.jndi.BindableRepository
All Implemented Interfaces:
Serializable, Repository, Referenceable

public class BindableRepository
extends Object
implements Repository, Referenceable, Serializable

A referenceable and serializable content repository proxy. This class implements the Proxy design pattern (GoF) for the Jackrabbit Repository implementation. The proxy implementation delays the instantiation of the actual Repository instance and implements serialization and JNDI referenceability by keeping track of the repository configuration parameters.

A BindableRepository instance contains the configuration file and home directory paths of a Jackrabbit repository. The separate init() method is used to create a transient RepositoryImpl instance to which all the JCR API calls are delegated.

An instance of this class is normally always also initialized. The uninitialized state is only used briefly during the static create method and during serialization 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 RegistryHelper.unregisterRepository(javax.naming.Context, String) method should be used to explicitly close the repository if needed.

See Also:
Serialized Form

Field Summary
static String CONFIGFILEPATH_ADDRTYPE
          type of configFilePath reference address (@see Reference.get(String)
protected  Repository delegatee
          The delegate repository instance.
static String REPHOMEDIR_ADDRTYPE
          type of repHomeDir reference address (@see Reference.get(String)
 
Fields inherited from interface javax.jcr.Repository
LEVEL_1_SUPPORTED, LEVEL_2_SUPPORTED, OPTION_LOCKING_SUPPORTED, OPTION_OBSERVATION_SUPPORTED, OPTION_QUERY_SQL_SUPPORTED, OPTION_TRANSACTIONS_SUPPORTED, OPTION_VERSIONING_SUPPORTED, QUERY_XPATH_DOC_ORDER, QUERY_XPATH_POS_INDEX, REP_NAME_DESC, REP_VENDOR_DESC, REP_VENDOR_URL_DESC, REP_VERSION_DESC, SPEC_NAME_DESC, SPEC_VERSION_DESC
 
Constructor Summary
protected BindableRepository(String configFilePath, String repHomeDir)
          Creates a BindableRepository instance with the given configuration information, but does not create the underlying repository instance.
 
Method Summary
protected  Repository createRepository(RepositoryConfig config)
          Creates a plain repository instance from a repository config.
protected  RepositoryConfig createRepositoryConfig(String configFilePath, String repHomeDir)
          Creates a repository configuration from a path to the repository.xml file and the repository home directory.
 String getDescriptor(String key)
          Delegated to the underlying repository instance.
 String[] getDescriptorKeys()
          Delegated to the underlying repository instance.
 Reference getReference()
          Creates a JNDI reference for this content repository.
protected  void init()
          Creates the underlying repository instance.
 Session login()
          Delegated to the underlying repository instance.
 Session login(Credentials credentials)
          Delegated to the underlying repository instance.
 Session login(Credentials credentials, String workspaceName)
          Delegated to the underlying repository instance.
 Session login(String workspaceName)
          Delegated to the underlying repository instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGFILEPATH_ADDRTYPE

public static final String CONFIGFILEPATH_ADDRTYPE
type of configFilePath reference address (@see Reference.get(String)

See Also:
Constant Field Values

REPHOMEDIR_ADDRTYPE

public static final String REPHOMEDIR_ADDRTYPE
type of repHomeDir reference address (@see Reference.get(String)

See Also:
Constant Field Values

delegatee

protected transient Repository delegatee
The delegate repository instance. Created by init.

Constructor Detail

BindableRepository

protected BindableRepository(String configFilePath,
                             String repHomeDir)
Creates a BindableRepository instance with the given configuration information, but does not create the underlying repository instance.

Parameters:
configFilePath - repository configuration file path
repHomeDir - repository home directory path
Method Detail

init

protected void init()
             throws RepositoryException
Creates the underlying repository instance. A shutdown hook is registered to make sure that the initialized repository gets closed when the JVM shuts down.

Throws:
RepositoryException - if the repository cannot be created

createRepositoryConfig

protected RepositoryConfig createRepositoryConfig(String configFilePath,
                                                  String repHomeDir)
                                           throws ConfigurationException
Creates a repository configuration from a path to the repository.xml file and the repository home directory.

Parameters:
configFilePath - path to the repository.xml file.
repHomeDir - the repository home directory.
Returns:
the repository configuration.
Throws:
ConfigurationException - on configuration error.

createRepository

protected Repository createRepository(RepositoryConfig config)
                               throws RepositoryException
Creates a plain repository instance from a repository config.

Parameters:
config - the repository configuration.
Returns:
the repository instance.
Throws:
RepositoryException - if an error occurs while creating the repository instance.

login

public Session login(Credentials credentials,
                     String workspaceName)
              throws LoginException,
                     NoSuchWorkspaceException,
                     RepositoryException
Delegated to the underlying repository instance.

Specified by:
login in interface Repository
Throws:
LoginException
NoSuchWorkspaceException
RepositoryException

login

public Session login(String workspaceName)
              throws LoginException,
                     NoSuchWorkspaceException,
                     RepositoryException
Delegated to the underlying repository instance.

Specified by:
login in interface Repository
Throws:
LoginException
NoSuchWorkspaceException
RepositoryException

login

public Session login()
              throws LoginException,
                     RepositoryException
Delegated to the underlying repository instance.

Specified by:
login in interface Repository
Throws:
LoginException
RepositoryException

login

public Session login(Credentials credentials)
              throws LoginException,
                     RepositoryException
Delegated to the underlying repository instance.

Specified by:
login in interface Repository
Throws:
LoginException
RepositoryException

getDescriptor

public String getDescriptor(String key)
Delegated to the underlying repository instance.

Specified by:
getDescriptor in interface Repository

getDescriptorKeys

public String[] getDescriptorKeys()
Delegated to the underlying repository instance.

Specified by:
getDescriptorKeys in interface Repository

getReference

public Reference getReference()
Creates a JNDI reference for this content repository. The returned reference holds the configuration information required to create a copy of this instance.

Specified by:
getReference in interface Referenceable
Returns:
the created JNDI reference


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.