|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.graph.connector.base.Repository<NodeType,WorkspaceType>
NodeType
- the node typeWorkspaceType
- the workspace type@ThreadSafe public abstract class Repository<NodeType extends Node,WorkspaceType extends Workspace>
A representation of a repository as a set of named workspaces. Workspaces can be
created
or destroyed
, though the exact type of Workspace
is dictated by the Transaction
. All workspaces contain a root
node with the same UUID
.
Note that this class is thread-safe, since a BaseRepositorySource
will contain a single instance of a concrete subclass
of this class. Often, the Workspace objects are used to hold onto the workspace-related content, but access to the content is
always done through a transaction
.
Field Summary | |
---|---|
protected ExecutionContext |
context
|
protected UUID |
rootNodeUuid
|
protected BaseRepositorySource |
source
|
Constructor Summary | |
---|---|
protected |
Repository(BaseRepositorySource source)
Creates a MapRepository with the given repository source name, root node UUID, and a default workspace with the
given name. |
Method Summary | |
---|---|
RequestProcessor |
createRequestProcessor(Transaction<NodeType,WorkspaceType> txn)
Create a RequestProcessor instance that should be used to process a set of requests within the supplied transaction. |
WorkspaceType |
createWorkspace(Transaction<NodeType,WorkspaceType> txn,
String name,
CreateWorkspaceRequest.CreateConflictBehavior existingWorkspaceBehavior,
String nameOfWorkspaceToClone)
Attempts to create a workspace with the given name with name-collision behavior determined by the behavior parameter. |
boolean |
destroyWorkspace(String name)
Removes the named workspace from the #workspaces workspaces map . |
ExecutionContext |
getContext()
|
protected String |
getDefaultWorkspaceName()
|
UUID |
getRootNodeUuid()
Returns the UUID used by the root nodes in each workspace. |
String |
getSourceName()
Returns the logical name (as opposed to the class name) of the repository source that defined this instance of the repository for use in error, informational, and other contextual messages. |
WorkspaceType |
getWorkspace(Transaction<NodeType,WorkspaceType> txn,
String name)
Returns the workspace with the given name. |
Set<String> |
getWorkspaceNames()
Get the names of the available workspaces that have been loaded. |
protected void |
initialize()
Initializes the repository by creating the default workspace. |
abstract Transaction<NodeType,WorkspaceType> |
startTransaction(ExecutionContext context,
boolean readonly)
Begin a transaction, hinting whether the transaction will be used only to read the content. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final BaseRepositorySource source
protected final UUID rootNodeUuid
protected final ExecutionContext context
Constructor Detail |
---|
protected Repository(BaseRepositorySource source)
MapRepository
with the given repository source name, root node UUID, and a default workspace with the
given name.
source
- the repository source to which this repository belongs
IllegalArgumentException
- if the repository source is null, if the source's
BaseRepositorySource.getRepositoryContext()
is null, or if the source name is null or emptyMethod Detail |
---|
protected void initialize()
Due to the ordering restrictions on constructor chaining, this method cannot be called until the repository is fully
initialized. This method MUST be called at the end of the constructor by any class that implements MapRepository
.
public ExecutionContext getContext()
protected String getDefaultWorkspaceName()
public final UUID getRootNodeUuid()
Note that the root nodes themselves are distinct objects in each workspace and a change to the root node of one workspace does not imply a change to the root nodes of any other workspaces. However, the JCR specification mandates that all referenceable root nodes in a repository use a common UUID (in support of node correspondence); therefore this must be supported by ModeShape.
public String getSourceName()
public Set<String> getWorkspaceNames()
public WorkspaceType getWorkspace(Transaction<NodeType,WorkspaceType> txn, String name)
txn
- the transaction attempting to get the workspace, and which may be used to create the workspace object if needed;
may not be nullname
- the name of the workspace to return
public WorkspaceType createWorkspace(Transaction<NodeType,WorkspaceType> txn, String name, CreateWorkspaceRequest.CreateConflictBehavior existingWorkspaceBehavior, String nameOfWorkspaceToClone) throws InvalidWorkspaceException
This method will first check to see if a workspace already exists with the given name. If no such workspace exists, the
method will create a new workspace with the given name, add it to the #workspaces workspaces map
, and return it. If
a workspace with the requested name already exists and the behavior
is CreateWorkspaceRequest.CreateConflictBehavior.DO_NOT_CREATE
, this method will return null
without modifying the state of the repository. If a workspace with the requested
name already exists and the behavior
is CreateWorkspaceRequest.CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME
, this method will
generate a unique new name for the workspace, create a new workspace with the given name, added it to the #workspaces workspaces map
, and return it.
If nameOfWorkspaceToClone
is given, this method will clone the content in this original workspace into the new
workspace. However, if no workspace with the name nameOfWorkspaceToClone
exists, the method will create an empty
workspace.
txn
- the transaction creating the workspace; may not be nullname
- the requested name of the workspace. The name of the workspace that is returned from this method may not be the
same as the requested name; may not be nullexistingWorkspaceBehavior
- the behavior to use in case a workspace with the requested name already exists in the
repositorynameOfWorkspaceToClone
- the name of the workspace from which the content should be cloned; be null if the new
workspace is to be empty (other than the root node)
nameOfWorkspaceToClone
or null
if a workspace with the requested name already exists in the repository and
behavior == CreateConflictBehavior#DO_NOT_CREATE
.
InvalidWorkspaceException
- if the workspace could not be createdpublic boolean destroyWorkspace(String name)
#workspaces workspaces map
.
name
- the name of the workspace to remove
true
if a workspace with that name previously existed in the mappublic RequestProcessor createRequestProcessor(Transaction<NodeType,WorkspaceType> txn)
txn
- the transaction; may not be null
public abstract Transaction<NodeType,WorkspaceType> startTransaction(ExecutionContext context, boolean readonly)
committed
or rolled back
.
context
- the context in which the transaction is to be performed; may not be nullreadonly
- true if the transaction will not modify any content, or false if changes are to be made
Transaction.commit()
,
Transaction.rollback()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |