org.apache.jackrabbit.core.jndi
Class BindableRepository

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

public class BindableRepository
extends AbstractRepository
implements Repository, JackrabbitRepository, 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 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 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
static String REPHOMEDIR_ADDRTYPE
          type of repHomeDir reference address
 
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
BindableRepository(Reference reference)
          Creates a BindableRepository instance with the configuration information in the given JNDI reference.
 
Method Summary
protected  JackrabbitRepository createRepository()
          Creates a repository instance based on the contained JNDI reference.
 String getDescriptor(String key)
          Delegated to the underlying repository instance.
 String[] getDescriptorKeys()
          Delegated to the underlying repository instance.
 Value getDescriptorValue(String key)
          The value of a single-value descriptor is found by passing the key for that descriptor to this method.
 Value[] getDescriptorValues(String key)
          The value array of a multi-value descriptor is found by passing the key for that descriptor to this method.
 Reference getReference()
          Returns the JNDI reference for this content repository.
protected  JackrabbitRepository getRepository()
          Returns the underlying repository instance.
 boolean isSingleValueDescriptor(String key)
          Returns true if key is a valid single-value descriptor; otherwise returns false.
 boolean isStandardDescriptor(String key)
          Returns true if key is a standard descriptor defined by the string constants in this interface and false if it is either a valid implementation-specific key or not a valid key.
 Session login(Credentials credentials, String workspaceName)
          Delegated to the underlying repository instance.
 void shutdown()
          Delegated to the underlying repository instance.
 
Methods inherited from class org.apache.jackrabbit.commons.AbstractRepository
login, login, login
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jcr.Repository
login, login, login
 

Field Detail

CONFIGFILEPATH_ADDRTYPE

public static final String CONFIGFILEPATH_ADDRTYPE
type of configFilePath reference address

See Also:
Reference.get(String), Constant Field Values

REPHOMEDIR_ADDRTYPE

public static final String REPHOMEDIR_ADDRTYPE
type of repHomeDir reference address

See Also:
Reference.get(String), Constant Field Values
Constructor Detail

BindableRepository

public BindableRepository(Reference reference)
                   throws RepositoryException
Creates a BindableRepository instance with the configuration information in the given JNDI reference.

Parameters:
reference - JNDI reference
Throws:
RepositoryException - if the repository can not be started
Method Detail

createRepository

protected JackrabbitRepository createRepository()
                                         throws RepositoryException
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 getReference() method. The default implementation returns a RepositoryImpl instance.

Returns:
repository instance
Throws:
RepositoryException - if the repository could not be created

getRepository

protected JackrabbitRepository getRepository()
Returns the underlying repository instance. Can be used by subclasses to access the repository instance.

Returns:
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

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

getDescriptorValue

public Value getDescriptorValue(String key)
Description copied from interface: Repository
The value of a single-value descriptor is found by passing the key for that descriptor to this method. If key is the key of a multi-value descriptor or not a valid key this method returns null.

Parameters:
key - a descriptor key.
Returns:
The value of the indicated descriptor

getDescriptorValues

public Value[] getDescriptorValues(String key)
Description copied from interface: Repository
The value array of a multi-value descriptor is found by passing the key for that descriptor to this method. If key is the key of a single-value descriptor then this method returns that value as an array of size one. If key is not a valid key this method returns null.

Parameters:
key - a descriptor key.
Returns:
the value array for the indicated descriptor

isSingleValueDescriptor

public boolean isSingleValueDescriptor(String key)
Description copied from interface: Repository
Returns true if key is a valid single-value descriptor; otherwise returns false.

Parameters:
key - a descriptor key.
Returns:
whether the specified desdfriptor is multi-valued.

isStandardDescriptor

public boolean isStandardDescriptor(String key)
Description copied from interface: Repository
Returns true if key is a standard descriptor defined by the string constants in this interface and false if it is either a valid implementation-specific key or not a valid key.

Parameters:
key - a descriptor key.
Returns:
whether key is a standard descriptor.

getReference

public Reference getReference()
Returns the 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 JNDI reference

shutdown

public void shutdown()
Delegated to the underlying repository instance.

Specified by:
shutdown in interface JackrabbitRepository


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