org.apache.jackrabbit.core
Class RepositoryImpl

java.lang.Object
  extended by org.apache.jackrabbit.commons.AbstractRepository
      extended by org.apache.jackrabbit.core.RepositoryImpl
All Implemented Interfaces:
EventListener, Repository, JackrabbitRepository, WorkspaceListener, SessionListener

public class RepositoryImpl
extends AbstractRepository
implements Repository, JackrabbitRepository, SessionListener, EventListener, WorkspaceListener

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. the same physical storage.
 
Field Summary
static NodeId NODETYPES_NODE_ID
          hardcoded id of the "/jcr:system/jcr:nodeTypes" node
protected  RepositoryConfig repConfig
           
static NodeId ROOT_NODE_ID
          hardcoded id of the repository root node
static String STATS_NODE_COUNT_PROPERTY
           
static String STATS_PROP_COUNT_PROPERTY
           
static NodeId SYSTEM_ROOT_NODE_ID
          hardcoded id of the "/jcr:system" node
static NodeId VERSION_STORAGE_NODE_ID
          hardcoded id of the "/jcr:system/jcr:versionStorage" node
 
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)
          Protected constructor.
 
Method Summary
static RepositoryImpl create(RepositoryConfig config)
          Creates a new RepositoryImpl instance.
protected  ClusterNode createClusterNode()
          Creates the cluster node.
protected  SharedItemStateManager createItemStateManager(PersistenceManager persistMgr, NodeId rootNodeId, NodeTypeRegistry ntReg, boolean usesReferences, ItemStateCacheFactory cacheFactory, ISMLocking locking)
          Creates a SharedItemStateManager or derivative.
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  VersionManagerImpl createVersionManager(VersioningConfig vConfig, DelegatingObservationDispatcher delegatingDispatcher)
          Creates the version manager.
protected  void createWorkspace(String workspaceName)
          Creates a workspace with the given name.
protected  void createWorkspace(String workspaceName, InputSource configTemplate)
          Creates a workspace with the given name and given workspace configuration template.
protected  RepositoryImpl.WorkspaceInfo createWorkspaceInfo(WorkspaceConfig wspConfig)
          Creates a new RepositoryImpl.WorkspaceInfo instance for wspConfig.
 void externalWorkspaceCreated(String workspaceName, InputSource configTemplate)
          Workspace created on another cluster node.
 CacheManager getCacheManager()
          Get the cache manager of this repository, useful for setting its memory parameters.
 ClusterNode getClusterNode()
          Get the cluster node.
 RepositoryConfig getConfig()
          Returns the configuration of this repository.
 DataStore getDataStore()
           
 String getDescriptor(String key)
          
 String[] getDescriptorKeys()
          
 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.
protected  FileSystem getFileSystem()
          Returns the repository file system.
 ItemStateCacheFactory getItemStateCacheFactory()
          Get the item state cache factory of this repository.
protected  NamespaceRegistryImpl getNamespaceRegistry()
           
protected  NodeTypeRegistry getNodeTypeRegistry()
           
protected  NodeId getRootNodeId()
           
protected  JackrabbitSecurityManager getSecurityManager()
          Returns the SecurityManager of this Repository
protected  VersionManager getVersionManager()
           
protected  RepositoryImpl.WorkspaceInfo getWorkspaceInfo(String workspaceName)
          Returns the RepositoryImpl.WorkspaceInfo for the named workspace.
protected  String[] getWorkspaceNames()
          Returns the names of all workspaces in this repository.
protected  void initStartupWorkspaces()
          Initialize startup workspaces.
 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.
protected  Properties loadRepProps()
          Loads the repository properties by executing the following steps: if the PROPERTIES_RESOURCE exists in the meta data store, the properties are loaded from that resource.
protected  NodeId loadRootNodeId(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(Credentials credentials, String workspaceName)
          
 void onEvent(EventIterator events)
          
protected  void onSessionCreated(SessionImpl session)
          Adds the given session to the list of active sessions and registers this repository as listener.
protected  void sanityCheck()
          Performs a sanity check on this repository instance.
protected  void setDefaultRepositoryProperties(Properties props)
          Sets the default properties of the repository.
protected  void setReferentialIntegrityChecking(String workspace, boolean enabled)
          Enables or disables referential integrity checking for given workspace.
 void shutdown()
          Shuts down this repository.
protected  void storeRepProps(Properties props)
          Stores the properties to a persistent resource in the meta filesytem.
 
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

ROOT_NODE_ID

public static final NodeId ROOT_NODE_ID
hardcoded id of the repository root node


SYSTEM_ROOT_NODE_ID

public static final NodeId SYSTEM_ROOT_NODE_ID
hardcoded id of the "/jcr:system" node


VERSION_STORAGE_NODE_ID

public static final NodeId VERSION_STORAGE_NODE_ID
hardcoded id of the "/jcr:system/jcr:versionStorage" node


NODETYPES_NODE_ID

public static final NodeId NODETYPES_NODE_ID
hardcoded id of the "/jcr:system/jcr:nodeTypes" node


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
Protected constructor.

Parameters:
repConfig - the repository configuration.
Throws:
RepositoryException - if there is already another repository instance running on the given configuration or another error occurs.
Method Detail

getDataStore

public DataStore getDataStore()

getCacheManager

public CacheManager getCacheManager()
Get the cache manager of this repository, useful for setting its memory parameters.

Returns:
the cache manager
Since:
1.3

getItemStateCacheFactory

public ItemStateCacheFactory getItemStateCacheFactory()
Get the item state cache factory of this repository.

Returns:
the cache factory

getClusterNode

public ClusterNode getClusterNode()
Get the cluster node. Returns null if this repository is not running clustered.

Returns:
cluster node

getSecurityManager

protected JackrabbitSecurityManager getSecurityManager()
                                                throws RepositoryException
Returns the SecurityManager of this Repository

Returns:
the security manager
Throws:
RepositoryException - if an error occurs.

createVersionManager

protected VersionManagerImpl createVersionManager(VersioningConfig vConfig,
                                                  DelegatingObservationDispatcher delegatingDispatcher)
                                           throws RepositoryException
Creates the version manager.

Parameters:
vConfig - the versioning config
Returns:
the newly created version manager
Throws:
RepositoryException - if an error occurs

initStartupWorkspaces

protected void initStartupWorkspaces()
                              throws RepositoryException
Initialize startup workspaces. Base implementation will initialize the default workspace. Derived classes may initialize their own startup workspaces after having called the base implementation.

Throws:
RepositoryException - if an error occurs

loadRootNodeId

protected NodeId loadRootNodeId(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.

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

sanityCheck

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

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

createClusterNode

protected ClusterNode createClusterNode()
                                 throws RepositoryException
Creates the cluster node.

Returns:
clustered node
Throws:
RepositoryException

getNamespaceRegistry

protected NamespaceRegistryImpl getNamespaceRegistry()

getNodeTypeRegistry

protected NodeTypeRegistry getNodeTypeRegistry()

getVersionManager

protected VersionManager getVersionManager()

getRootNodeId

protected NodeId getRootNodeId()

getWorkspaceNames

protected String[] getWorkspaceNames()
Returns the names of all workspaces in this repository.

Returns:
the names of all workspaces in this repository.
See Also:
Workspace.getAccessibleWorkspaceNames()

getWorkspaceInfo

protected RepositoryImpl.WorkspaceInfo getWorkspaceInfo(String workspaceName)
                                                 throws NoSuchWorkspaceException,
                                                        RepositoryException
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:
NoSuchWorkspaceException - If the named workspace does not exist.
RepositoryException - If this repository has been shut down.

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)

externalWorkspaceCreated

public void externalWorkspaceCreated(String workspaceName,
                                     InputSource configTemplate)
                              throws RepositoryException
Description copied from interface: WorkspaceListener
Workspace created on another cluster node.

Specified by:
externalWorkspaceCreated in interface WorkspaceListener
Throws:
RepositoryException

createWorkspace

protected void createWorkspace(String workspaceName,
                               InputSource configTemplate)
                        throws RepositoryException
Creates a workspace with the given name and given workspace configuration template.

Parameters:
workspaceName - name of the new workspace
configTemplate - the workspace configuration template 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,InputSource)

setReferentialIntegrityChecking

protected void setReferentialIntegrityChecking(String workspace,
                                               boolean enabled)
                                        throws RepositoryException
Enables or disables referential integrity checking for given workspace. Disabling referential integrity checks can result in a corrupted workspace, and thus this feature is only available to customized implementations that subclass RepositoryImpl.

Parameters:
workspace - name of the workspace
enabled - true to enable integrity checking (default), false to disable it
Throws:
RepositoryException - if an error occurs
See Also:
Issue JCR-954

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

onSessionCreated

protected void onSessionCreated(SessionImpl session)
Adds the given session to the list of active sessions and registers this repository as listener.

Parameters:
session - the session to register

shutdown

public void shutdown()
Shuts down this repository. The shutdown is guarded by a shutdown lock that prevents any new sessions from being started simultaneously.

Specified by:
shutdown in interface JackrabbitRepository

getConfig

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

Returns:
repository configuration

getFileSystem

protected FileSystem getFileSystem()
Returns the repository file system.

Returns:
repository file system

setDefaultRepositoryProperties

protected void setDefaultRepositoryProperties(Properties props)
                                       throws RepositoryException
Sets the default properties of the repository.

This method loads the Properties from the org/apache/jackrabbit/core/repository.properties resource found in the class path and (re)sets the statistics properties, if not present.

Parameters:
props - the properties object to load
Throws:
RepositoryException - if the properties can not be loaded

loadRepProps

protected Properties loadRepProps()
                           throws RepositoryException
Loads the repository properties by executing the following steps:

Returns:
the newly loaded/initialized repository properties
Throws:
RepositoryException

storeRepProps

protected void storeRepProps(Properties props)
                      throws RepositoryException
Stores the properties to a persistent resource in the meta filesytem.

Throws:
RepositoryException

createItemStateManager

protected SharedItemStateManager createItemStateManager(PersistenceManager persistMgr,
                                                        NodeId rootNodeId,
                                                        NodeTypeRegistry ntReg,
                                                        boolean usesReferences,
                                                        ItemStateCacheFactory cacheFactory,
                                                        ISMLocking locking)
                                                 throws ItemStateException
Creates a SharedItemStateManager or derivative.

Parameters:
persistMgr - persistence manager
rootNodeId - root node id
ntReg - node type registry
usesReferences - true if the item state manager should use node references to verify integrity of its reference properties; false otherwise
cacheFactory - cache factory
Returns:
item state manager
Throws:
ItemStateException - if an error occurs

login

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

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

getDescriptor

public String getDescriptor(String key)

Specified by:
getDescriptor in interface Repository

getDescriptorKeys

public String[] getDescriptorKeys()

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.

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 occurs 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 occurs 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-2009 The Apache Software Foundation. All Rights Reserved.