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:
Repository, JackrabbitRepository, WorkspaceListener, SessionListener

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

A RepositoryImpl ...


Nested Class Summary
protected  class RepositoryImpl.DescriptorValue
          Represents a Repository Descriptor Value (either Value or Value[])
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 ACTIVITIES_NODE_ID
          hardcoded id of the "/jcr:system/jcr:activities" node
static NodeId CONFIGURATIONS_NODE_ID
          hardcoded id of the "/jcr:system/jcr:configurations" node
protected  RepositoryContext context
           
protected  ScheduledExecutorService executor
          Scheduled executor service.
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 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
IDENTIFIER_STABILITY, IDENTIFIER_STABILITY_INDEFINITE_DURATION, IDENTIFIER_STABILITY_METHOD_DURATION, IDENTIFIER_STABILITY_SAVE_DURATION, IDENTIFIER_STABILITY_SESSION_DURATION, LEVEL_1_SUPPORTED, LEVEL_2_SUPPORTED, NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED, NODE_TYPE_MANAGEMENT_INHERITANCE, NODE_TYPE_MANAGEMENT_INHERITANCE_MINIMAL, NODE_TYPE_MANAGEMENT_INHERITANCE_MULTIPLE, NODE_TYPE_MANAGEMENT_INHERITANCE_SINGLE, NODE_TYPE_MANAGEMENT_MULTIPLE_BINARY_PROPERTIES_SUPPORTED, NODE_TYPE_MANAGEMENT_MULTIVALUED_PROPERTIES_SUPPORTED, NODE_TYPE_MANAGEMENT_ORDERABLE_CHILD_NODES_SUPPORTED, NODE_TYPE_MANAGEMENT_OVERRIDES_SUPPORTED, NODE_TYPE_MANAGEMENT_PRIMARY_ITEM_NAME_SUPPORTED, NODE_TYPE_MANAGEMENT_PROPERTY_TYPES, NODE_TYPE_MANAGEMENT_RESIDUAL_DEFINITIONS_SUPPORTED, NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED, NODE_TYPE_MANAGEMENT_UPDATE_IN_USE_SUPORTED, NODE_TYPE_MANAGEMENT_VALUE_CONSTRAINTS_SUPPORTED, OPTION_ACCESS_CONTROL_SUPPORTED, OPTION_ACTIVITIES_SUPPORTED, OPTION_BASELINES_SUPPORTED, OPTION_JOURNALED_OBSERVATION_SUPPORTED, OPTION_LIFECYCLE_SUPPORTED, OPTION_LOCKING_SUPPORTED, OPTION_NODE_AND_PROPERTY_WITH_SAME_NAME_SUPPORTED, OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED, OPTION_OBSERVATION_SUPPORTED, OPTION_QUERY_SQL_SUPPORTED, OPTION_RETENTION_SUPPORTED, OPTION_SHAREABLE_NODES_SUPPORTED, OPTION_SIMPLE_VERSIONING_SUPPORTED, OPTION_TRANSACTIONS_SUPPORTED, OPTION_UNFILED_CONTENT_SUPPORTED, OPTION_UPDATE_MIXIN_NODE_TYPES_SUPPORTED, OPTION_UPDATE_PRIMARY_NODE_TYPE_SUPPORTED, OPTION_VERSIONING_SUPPORTED, OPTION_WORKSPACE_MANAGEMENT_SUPPORTED, OPTION_XML_EXPORT_SUPPORTED, OPTION_XML_IMPORT_SUPPORTED, QUERY_FULL_TEXT_SEARCH_SUPPORTED, QUERY_JOINS, QUERY_JOINS_INNER, QUERY_JOINS_INNER_OUTER, QUERY_JOINS_NONE, QUERY_LANGUAGES, QUERY_STORED_QUERIES_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, WRITE_SUPPORTED
 
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.
 GarbageCollector createDataStoreGarbageCollector()
          Creates a data store garbage collector for this repository.
protected  SharedItemStateManager createItemStateManager(PersistenceManager persistMgr, boolean usesReferences, ISMLocking locking)
          Creates a SharedItemStateManager or derivative.
protected  NamespaceRegistryImpl createNamespaceRegistry()
          Protected factory method for creating the namespace registry.
protected  NodeTypeRegistry createNodeTypeRegistry()
          Protected factory method for creating the node type registry.
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  InternalVersionManagerImpl 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.
protected  void doShutdown()
          Protected method that performs the actual shutdown after the shutdown lock has been acquired by the shutdown() method.
 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.
 RepositoryConfig getConfig()
          Returns the configuration of this repository.
protected  Properties getCustomRepositoryDescriptors()
          Returns a Properties object containing custom repository descriptors or null if none exist.
 String getDescriptor(String key)
          
 String[] getDescriptorKeys()
          
 Value getDescriptorValue(String key)
          
 Value[] getDescriptorValues(String key)
          
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 initRepositoryDescriptors()
          Initializes the repository descriptors by executing the following steps: Sets standard descriptors getCustomRepositoryDescriptors() is called afterwards in order to add custom/overwrite standard repository decriptors.
protected  void initStartupWorkspaces()
          Initialize startup workspaces.
 boolean isSingleValueDescriptor(String key)
          
 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)
          
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 setDescriptor(String desc, String value)
           
protected  void setDescriptor(String desc, Value value)
           
protected  void setDescriptor(String desc, Value[] values)
           
protected  void setReferentialIntegrityChecking(String workspace, boolean enabled)
          Enables or disables referential integrity checking for given workspace.
 void shutdown()
          Shuts down this repository.
 
Methods inherited from class org.apache.jackrabbit.commons.AbstractRepository
isStandardDescriptor, 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
isStandardDescriptor, 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


ACTIVITIES_NODE_ID

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


CONFIGURATIONS_NODE_ID

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


NODETYPES_NODE_ID

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


context

protected final RepositoryContext context

repConfig

protected final RepositoryConfig repConfig

executor

protected final ScheduledExecutorService executor
Scheduled executor service.

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

createNamespaceRegistry

protected NamespaceRegistryImpl createNamespaceRegistry()
                                                 throws RepositoryException
Protected factory method for creating the namespace registry. Called by the constructor after the repository file system has been initialised.

Returns:
namespace registry
Throws:
RepositoryException - if the namespace registry can not be created

createNodeTypeRegistry

protected NodeTypeRegistry createNodeTypeRegistry()
                                           throws RepositoryException
Protected factory method for creating the node type registry. Called by the constructor after the repository file system and namespace registry have been initialised.

Returns:
node type registry
Throws:
RepositoryException - if the node type registry can not be created

getCacheManager

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

Returns:
the cache manager
Since:
1.3

createVersionManager

protected InternalVersionManagerImpl 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

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

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:
WorkspaceImpl.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:
WorkspaceImpl.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

doShutdown

protected void doShutdown()
Protected method that performs the actual shutdown after the shutdown lock has been acquired by the shutdown() method.


getConfig

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

Returns:
repository configuration

initRepositoryDescriptors

protected void initRepositoryDescriptors()
                                  throws RepositoryException
Initializes the repository descriptors by executing the following steps:

Throws:
RepositoryException

getCustomRepositoryDescriptors

protected Properties getCustomRepositoryDescriptors()
                                             throws RepositoryException
Returns a Properties object containing custom repository descriptors or null if none exist.

Overridable to allow subclasses to add custom descriptors or to override standard descriptor values.

Note that the properties entries will be set as single-valued STRING descriptor values.

This method tries to load the Properties from the org/apache/jackrabbit/core/repository.properties resource found in the class path.

Throws:
RepositoryException - if the properties can not be loaded

setDescriptor

protected void setDescriptor(String desc,
                             String value)

setDescriptor

protected void setDescriptor(String desc,
                             Value value)

setDescriptor

protected void setDescriptor(String desc,
                             Value[] values)

createItemStateManager

protected SharedItemStateManager createItemStateManager(PersistenceManager persistMgr,
                                                        boolean usesReferences,
                                                        ISMLocking locking)
                                                 throws ItemStateException
Creates a SharedItemStateManager or derivative.

Parameters:
persistMgr - persistence manager
usesReferences - true if the item state manager should use node references to verify integrity of its reference properties; false otherwise
Returns:
item state manager
Throws:
ItemStateException - if an error occurs

createDataStoreGarbageCollector

public GarbageCollector createDataStoreGarbageCollector()
                                                 throws RepositoryException
Creates a data store garbage collector for this repository.

Note that you should use the RepositoryManager interface to access this functionality. This RepositoryImpl method may be removed in future Jackrabbit versions.

Throws:
RepositoryException

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)

Specified by:
getDescriptorValue in interface Repository

getDescriptorValues

public Value[] getDescriptorValues(String key)

Specified by:
getDescriptorValues in interface Repository

isSingleValueDescriptor

public boolean isSingleValueDescriptor(String key)

Specified by:
isSingleValueDescriptor 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'

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