org.apache.jackrabbit.core
Class RepositoryImpl

java.lang.Object
  extended byorg.apache.jackrabbit.core.RepositoryImpl
All Implemented Interfaces:
EventListener, Repository, SessionListener

public class RepositoryImpl
extends Object
implements Repository, SessionListener, EventListener

A RepositoryImpl ...


Nested Class Summary
protected  class RepositoryImpl.WorkspaceInfo
          WorkspaceInfo holds the objects that are shared among multiple per-session WorkspaceImpl instances representing the same named workspace, i.e.
 
Field Summary
protected  RepositoryConfig repConfig
           
static String STATS_NODE_COUNT_PROPERTY
           
static String STATS_PROP_COUNT_PROPERTY
           
 
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 RepositoryImpl(RepositoryConfig repConfig)
          private constructor
 
Method Summary
protected  void acquireRepositoryLock()
          Lock the repository home.
static RepositoryImpl create(RepositoryConfig config)
          Creates a new RepositoryImpl instance.
protected  NamespaceRegistryImpl createNamespaceRegistry(FileSystem fs)
          Creates the NamespaceRegistry instance.
protected  NodeTypeRegistry createNodeTypeRegistry(NamespaceRegistry nsReg, FileSystem fs)
          Creates the NodeTypeRegistry instance.
protected  SessionImpl createSession(AuthContext loginContext, String workspaceName)
          Creates a new repository session on the specified workspace for the authenticated subject of the given login context and adds it to the active sessions.
protected  SessionImpl createSession(Subject subject, String workspaceName)
          Creates a new repository session on the specified workspace for the given authenticated subject and adds it to the active sessions.
protected  SessionImpl createSessionInstance(AuthContext loginContext, WorkspaceConfig wspConfig)
          Creates an instance of the SessionImpl class representing a user authenticated by the loginContext instance attached to the workspace configured by the wspConfig.
protected  SessionImpl createSessionInstance(Subject subject, WorkspaceConfig wspConfig)
          Creates an instance of the SessionImpl class representing a user represented by the subject instance attached to the workspace configured by the wspConfig.
protected  void createWorkspace(String workspaceName)
          Creates a workspace with the given name.
protected  RepositoryImpl.WorkspaceInfo createWorkspaceInfo(WorkspaceConfig wspConfig)
          Creates a new RepositoryImpl.WorkspaceInfo instance for wspConfig.
 RepositoryConfig getConfig()
          Returns the configuration of this repository.
protected  InputStream getDefaultRepositoryProperties()
          Returns an InputStream on a Properties resource which contains the default properties for the repository.
 String getDescriptor(String key)
          
 String[] getDescriptorKeys()
          
protected  RepositoryImpl.WorkspaceInfo getWorkspaceInfo(String workspaceName)
          Returns the RepositoryImpl.WorkspaceInfo for the named workspace.
protected  String loadRootNodeUUID(FileSystem fs)
          Returns the root node uuid.
 void loggedOut(SessionImpl session)
          Called when a Session has been 'closed' by calling Session.logout()
 void loggingOut(SessionImpl session)
          Called when a Session is about to be 'closed' by calling Session.logout()
 Session login()
          
 Session login(Credentials credentials)
          
 Session login(Credentials credentials, String workspaceName)
          
 Session login(String workspaceName)
          
 void onEvent(EventIterator events)
          
protected  void releaseRepositoryLock()
          Release repository lock
protected  void sanityCheck()
          Performs a sanity check on this repository instance.
 void shutdown()
          Shuts down this repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATS_NODE_COUNT_PROPERTY

public static final String STATS_NODE_COUNT_PROPERTY
See Also:
Constant Field Values

STATS_PROP_COUNT_PROPERTY

public static final String STATS_PROP_COUNT_PROPERTY
See Also:
Constant Field Values

repConfig

protected final RepositoryConfig repConfig
Constructor Detail

RepositoryImpl

protected RepositoryImpl(RepositoryConfig repConfig)
                  throws RepositoryException
private constructor

Parameters:
repConfig -
Method Detail

acquireRepositoryLock

protected void acquireRepositoryLock()
                              throws RepositoryException
Lock the repository home.

Throws:
RepositoryException - if the repository lock can not be acquired

releaseRepositoryLock

protected void releaseRepositoryLock()
Release repository lock


loadRootNodeUUID

protected String loadRootNodeUUID(FileSystem fs)
                           throws RepositoryException
Returns the root node uuid.

Parameters:
fs -
Returns:
Throws:
RepositoryException

createNamespaceRegistry

protected NamespaceRegistryImpl createNamespaceRegistry(FileSystem fs)
                                                 throws RepositoryException
Creates the NamespaceRegistry instance.

Parameters:
fs -
Returns:
Throws:
RepositoryException

createNodeTypeRegistry

protected NodeTypeRegistry createNodeTypeRegistry(NamespaceRegistry nsReg,
                                                  FileSystem fs)
                                           throws RepositoryException
Creates the NodeTypeRegistry instance.

Parameters:
fs -
Returns:
Throws:
RepositoryException

create

public static RepositoryImpl create(RepositoryConfig config)
                             throws RepositoryException
Creates a new RepositoryImpl instance.

todo prevent multiple instantiation from same configuration as this could lead to data corruption/loss

Parameters:
config - the configuration of the repository
Returns:
a new RepositoryImpl instance
Throws:
RepositoryException - If an error occurs

sanityCheck

protected void sanityCheck()
                    throws IllegalStateException
Performs a sanity check on this repository instance.

Throws:
IllegalStateException - if this repository has been rendered invalid for some reason (e.g. if it has been shut down)

getWorkspaceInfo

protected RepositoryImpl.WorkspaceInfo getWorkspaceInfo(String workspaceName)
                                                 throws IllegalStateException,
                                                        NoSuchWorkspaceException
Returns the RepositoryImpl.WorkspaceInfo for the named workspace.

Parameters:
workspaceName - The name of the workspace whose RepositoryImpl.WorkspaceInfo is to be returned. This must not be null.
Returns:
The RepositoryImpl.WorkspaceInfo for the named workspace. This will never be null.
Throws:
IllegalStateException - If this repository has already been shut down.
NoSuchWorkspaceException - If the named workspace does not exist.

createWorkspace

protected void createWorkspace(String workspaceName)
                        throws RepositoryException
Creates a workspace with the given name.

Parameters:
workspaceName - name of the new workspace
Throws:
RepositoryException - if a workspace with the given name already exists or if another error occurs
See Also:
SessionImpl.createWorkspace(String)

createSession

protected final SessionImpl createSession(AuthContext loginContext,
                                          String workspaceName)
                                   throws NoSuchWorkspaceException,
                                          AccessDeniedException,
                                          RepositoryException
Creates a new repository session on the specified workspace for the authenticated subject of the given login context and adds it to the active sessions.

Calls createSessionInstance(AuthContext, WorkspaceConfig) to create the actual SessionImpl instance.

Parameters:
loginContext - login context with authenticated subject
workspaceName - workspace name
Returns:
a new session
Throws:
NoSuchWorkspaceException - if the specified workspace does not exist
AccessDeniedException - if the subject of the given login context is not granted access to the specified workspace
RepositoryException - if another error occurs

createSession

protected final SessionImpl createSession(Subject subject,
                                          String workspaceName)
                                   throws NoSuchWorkspaceException,
                                          AccessDeniedException,
                                          RepositoryException
Creates a new repository session on the specified workspace for the given authenticated subject and adds it to the active sessions.

Calls createSessionInstance(Subject, WorkspaceConfig) to create the actual SessionImpl instance.

Parameters:
subject - authenticated subject
workspaceName - workspace name
Returns:
a new session
Throws:
NoSuchWorkspaceException - if the specified workspace does not exist
AccessDeniedException - if the subject of the given login context is not granted access to the specified workspace
RepositoryException - if another error occurs

shutdown

public void shutdown()
Shuts down this repository. Note that this method is called automatically through a shutdown hook.

See Also:
Runtime.addShutdownHook(Thread)

getConfig

public RepositoryConfig getConfig()
Returns the configuration of this repository.

Returns:
repository configuration

getDefaultRepositoryProperties

protected InputStream getDefaultRepositoryProperties()
Returns an InputStream on a Properties resource which contains the default properties for the repository. This method is only called once during repository initialization.

The InputStream returned is closed by the caller.

This method returns an InputStream on the org/apache/jackrabbit/core/repository.properties resource found in the class path.

Returns:
InputStream on a Properties resource or null if the resource does not exist.

login

public Session login(Credentials credentials,
                     String workspaceName)
              throws LoginException,
                     NoSuchWorkspaceException,
                     RepositoryException

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

login

public Session login(String workspaceName)
              throws LoginException,
                     NoSuchWorkspaceException,
                     RepositoryException

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

login

public Session login()
              throws LoginException,
                     RepositoryException

Specified by:
login in interface Repository
Throws:
LoginException
RepositoryException

login

public Session login(Credentials credentials)
              throws LoginException,
                     RepositoryException

Specified by:
login in interface Repository
Throws:
LoginException
RepositoryException

getDescriptor

public String getDescriptor(String key)

Specified by:
getDescriptor in interface Repository

getDescriptorKeys

public String[] getDescriptorKeys()

Specified by:
getDescriptorKeys in interface Repository

loggingOut

public void loggingOut(SessionImpl session)
Called when a Session is about to be 'closed' by calling Session.logout()
Specified by:
loggingOut in interface SessionListener
Parameters:
session - the Session that is about to be 'closed'

loggedOut

public void loggedOut(SessionImpl session)
Called when a Session has been 'closed' by calling Session.logout()
Specified by:
loggedOut in interface SessionListener
Parameters:
session - the Session that has been 'closed'

onEvent

public void onEvent(EventIterator events)

Specified by:
onEvent in interface EventListener

createSessionInstance

protected SessionImpl createSessionInstance(AuthContext loginContext,
                                            WorkspaceConfig wspConfig)
                                     throws AccessDeniedException,
                                            RepositoryException
Creates an instance of the SessionImpl class representing a user authenticated by the loginContext instance attached to the workspace configured by the wspConfig.

Throws:
AccessDeniedException - if the subject of the given login context is not granted access to the specified workspace
RepositoryException - If any other error occurrs creating the session.

createSessionInstance

protected SessionImpl createSessionInstance(Subject subject,
                                            WorkspaceConfig wspConfig)
                                     throws AccessDeniedException,
                                            RepositoryException
Creates an instance of the SessionImpl class representing a user represented by the subject instance attached to the workspace configured by the wspConfig.

Throws:
AccessDeniedException - if the subject of the given login context is not granted access to the specified workspace
RepositoryException - If any other error occurrs creating the session.

createWorkspaceInfo

protected RepositoryImpl.WorkspaceInfo createWorkspaceInfo(WorkspaceConfig wspConfig)
Creates a new RepositoryImpl.WorkspaceInfo instance for wspConfig.

Parameters:
wspConfig - the workspace configuration.
Returns:
a new WorkspaceInfo instance.


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