org.apache.cocoon.jcr
Class AbstractRepository

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.jcr.AbstractRepository
All Implemented Interfaces:
Component, Configurable, Contextualizable, Disposable, LogEnabled, javax.jcr.Repository, Serviceable, ThreadSafe
Direct Known Subclasses:
JackrabbitRepository, JNDIRepository

public abstract class AbstractRepository
extends AbstractLogEnabled
implements javax.jcr.Repository, ThreadSafe, Contextualizable, Serviceable, Configurable, Disposable, Component

Base class for JCR (aka JSR-170) repository as a Cocoon component. The main purpose of this class is to allow repository credentials to be specified in the component's configuration, so that the application code just has to call repository.login().

There is no Cocoon-specific role for this component: "javax.jcr.Repository" should be used.

The configuration of this class, inherited by its subclasses, is as follows:

    <jcr-repository>
      <jaas src="context://samples/jaas.config"/>
      <credentials login="expression" password="expression"/>
      ... other specific configuration...
    </jcr-repository>
 
Login and password can be specified using the sitemap expression language, thus allowing the use of input modules to compute their values, e.g. password="{session-attr:jcr-password}".

<credentials> is optional. If not specified, the application must explicitely supply credentials when calling Repository.login().

Version:
$Id: AbstractRepository.java 290710 2005-09-21 14:29:48Z sylvain $

Field Summary
protected  Context context
           
protected  javax.jcr.Repository delegate
           
static String JCR_SESSION_REQUEST_ATTRIBUTE
          The request attribute in which the JCR session is stored
protected  VariableResolver loginResolver
           
protected  ServiceManager manager
           
protected  VariableResolver passwordResolver
           
static String ROLE
          Role which shall be used for JCR repository implementations.
 
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
AbstractRepository()
           
 
Method Summary
 void configure(Configuration config)
           
 void contextualize(Context context)
           
 void dispose()
           
 String getDescriptor(String key)
           
 String[] getDescriptorKeys()
           
 javax.jcr.Session login()
           
 javax.jcr.Session login(javax.jcr.Credentials creds)
           
 javax.jcr.Session login(javax.jcr.Credentials creds, String workspace)
           
 javax.jcr.Session login(String workspace)
           
 void service(ServiceManager manager)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROLE

public static final String ROLE
Role which shall be used for JCR repository implementations.

See Also:
Constant Field Values

JCR_SESSION_REQUEST_ATTRIBUTE

public static final String JCR_SESSION_REQUEST_ATTRIBUTE
The request attribute in which the JCR session is stored

See Also:
Constant Field Values

manager

protected ServiceManager manager

context

protected Context context

delegate

protected javax.jcr.Repository delegate

loginResolver

protected VariableResolver loginResolver

passwordResolver

protected VariableResolver passwordResolver
Constructor Detail

AbstractRepository

public AbstractRepository()
Method Detail

contextualize

public void contextualize(Context context)
                   throws ContextException
Specified by:
contextualize in interface Contextualizable
Throws:
ContextException

service

public void service(ServiceManager manager)
             throws ServiceException
Specified by:
service in interface Serviceable
Throws:
ServiceException

configure

public void configure(Configuration config)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException

dispose

public void dispose()
Specified by:
dispose in interface Disposable

getDescriptor

public String getDescriptor(String key)
Specified by:
getDescriptor in interface javax.jcr.Repository

getDescriptorKeys

public String[] getDescriptorKeys()
Specified by:
getDescriptorKeys in interface javax.jcr.Repository

login

public javax.jcr.Session login()
                        throws javax.jcr.LoginException,
                               javax.jcr.NoSuchWorkspaceException,
                               javax.jcr.RepositoryException
Specified by:
login in interface javax.jcr.Repository
Throws:
javax.jcr.LoginException
javax.jcr.NoSuchWorkspaceException
javax.jcr.RepositoryException

login

public javax.jcr.Session login(javax.jcr.Credentials creds)
                        throws javax.jcr.LoginException,
                               javax.jcr.NoSuchWorkspaceException,
                               javax.jcr.RepositoryException
Specified by:
login in interface javax.jcr.Repository
Throws:
javax.jcr.LoginException
javax.jcr.NoSuchWorkspaceException
javax.jcr.RepositoryException

login

public javax.jcr.Session login(javax.jcr.Credentials creds,
                               String workspace)
                        throws javax.jcr.LoginException,
                               javax.jcr.NoSuchWorkspaceException,
                               javax.jcr.RepositoryException
Specified by:
login in interface javax.jcr.Repository
Throws:
javax.jcr.LoginException
javax.jcr.NoSuchWorkspaceException
javax.jcr.RepositoryException

login

public javax.jcr.Session login(String workspace)
                        throws javax.jcr.LoginException,
                               javax.jcr.NoSuchWorkspaceException,
                               javax.jcr.RepositoryException
Specified by:
login in interface javax.jcr.Repository
Throws:
javax.jcr.LoginException
javax.jcr.NoSuchWorkspaceException
javax.jcr.RepositoryException


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.