Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.connector.map
Class MapRepository

    java.lang.Object
      org.modeshape.graph.connector.map.MapRepository

Direct Known Subclasses:
  SimpleJpaRepository

    public abstract class MapRepository

extends Object

A default implementation of a map-based repository.

`MapRepository` provides means for creating, retrieving, and destroying `map-based workspaces`, including providing the locking primitives required for safe control of the workspaces.

Field Summary
`protected UUID` | `rootNodeUuid`

Constructor Summary
`protected` | `MapRepository(String sourceName, UUID rootNodeUuid)` Creates a `MapRepository` with the given repository source name, root node UUID, and a default workspace named `""` (the empty string).
`protected` | `MapRepository(String sourceName, UUID rootNodeUuid, String defaultWorkspaceName)` Creates a `MapRepository` with the given repository source name, root node UUID, and a default workspace with the given name.

Method Summary
`protected abstract MapWorkspace` | `createWorkspace(ExecutionContext context, String name)` Creates a new workspace with the given name containing only a root node.
`MapWorkspace` | `createWorkspace(ExecutionContext context, String name, CreateWorkspaceRequest.CreateConflictBehavior behavior)` Attempts to create a workspace with the given name with name-collision behavior determined by the behavior parameter.
`MapWorkspace` | `createWorkspace(ExecutionContext context, String name, CreateWorkspaceRequest.CreateConflictBehavior existingWorkspaceBehavior, String nameOfWorkspaceToClone)` Attempts to create a workspace with the requested name as in the `#createWorkspace(ExecutionContext, String, CreateConflictBehavior)` method and then clones the content from the given source workspace into the new workspace if the creation was successful.
`boolean` | `destroyWorkspace(String name)` Removes the named workspace from the `#workspaces workspaces map`.
`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.
`MapWorkspace` | `getWorkspace(String name)` Returns the workspace with the given name
`Set<String>` | `getWorkspaceNames()` Returns a list of the names of the currently created workspaces
`protected void` | `initialize()` Initializes the repository by creating the default workspace.
`abstract MapRepositoryTransaction` | `startTransaction(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

### rootNodeUuid

    protected final UUID rootNodeUuid

Constructor Detail

### MapRepository

    protected MapRepository(String sourceName,
                            UUID rootNodeUuid)

  Creates a `MapRepository` with the given repository source name, root node UUID, and a default workspace named `""` (the empty string).

  Parameters:
    `sourceName` - the name of the repository source for use in error and informational messages; may not be null or empty
    `rootNodeUuid` - the UUID that will be used as the root node UUID for each workspace in the repository; may not be null or empty

### MapRepository

    protected MapRepository(String sourceName,
                            UUID rootNodeUuid,
                            String defaultWorkspaceName)

  Creates a `MapRepository` with the given repository source name, root node UUID, and a default workspace with the given name.

  Parameters:
    `sourceName` - the name of the repository source for use in error and informational messages; may not be null or empty
    `rootNodeUuid` - the UUID that will be used as the root node UUID for each workspace in the repository; may not be null or empty
    `defaultWorkspaceName` - the name of the default, auto-created workspace

Method Detail

### initialize

    protected void initialize()

  Initializes the repository by creating the default workspace.

  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` .

### getDefaultWorkspaceName

    protected String getDefaultWorkspaceName()

### getRootNodeUuid

    public final UUID getRootNodeUuid()

  Returns the UUID used by the root nodes in each workspace.

  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.

  Returns:
    the root node UUID

### getSourceName

    public 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.

  Returns:
    sourceName the logical name for the repository source name

### getWorkspaceNames

    public Set<String> getWorkspaceNames()

  Returns a list of the names of the currently created workspaces

  Returns:
    a list of the names of the currently created workspaces

### getWorkspace

    public MapWorkspace getWorkspace(String name)

  Returns the workspace with the given name

  Parameters:
    `name` - the name of the workspace to return
  Returns:
    the workspace with the given name; may be null if no workspace with the given name exists

### createWorkspace

    protected abstract MapWorkspace createWorkspace(ExecutionContext context,
                                                    String name)

  Creates a new workspace with the given name containing only a root node.

  This method does NOT automatically add the newly created workspace to the `workspace map` or check to see if a workspace already exists in this repository with the same name.

  Parameters:
    `context` - the context in which the workspace is to be created
    `name` - the name of the workspace
  Returns:
    the newly created workspace; may not be null

### createWorkspace

    public MapWorkspace createWorkspace(ExecutionContext context,
                                        String name,
                                        CreateWorkspaceRequest.CreateConflictBehavior behavior)

  Attempts to create a workspace with the given name with name-collision behavior determined by the behavior parameter.

  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.

  Parameters:
    `context` - the context in which the workspace is to be created; may not be null
    `name` - 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 null
    `behavior` - the behavior to use in case a workspace with the requested name already exists in the repository
  Returns:
    the newly created workspace or `null` if a workspace with the requested name already exists in the repository and `behavior == CreateConflictBehavior#DO_NOT_CREATE`.

### createWorkspace

    public MapWorkspace createWorkspace(ExecutionContext context,
                                        String name,
                                        CreateWorkspaceRequest.CreateConflictBehavior existingWorkspaceBehavior,
                                        String nameOfWorkspaceToClone)

  Attempts to create a workspace with the requested name as in the `#createWorkspace(ExecutionContext, String, CreateConflictBehavior)` method and then clones the content from the given source workspace into the new workspace if the creation was successful.

  If no workspace with the name `nameOfWorkspaceToClone` exists, the method will return an empty workspace.

  Parameters:
    `context` - the context in which the workspace is to be created; may not be null
    `name` - 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 null
    `existingWorkspaceBehavior` - the behavior to use in case a workspace with the requested name already exists in the repository
    `nameOfWorkspaceToClone` - the name of the workspace from which the content should be cloned; may not be null
  Returns:
    the newly created workspace with an exact copy of the contents from the workspace named `nameOfWorkspaceToClone` or `null` if a workspace with the requested name already exists in the repository and `behavior == CreateConflictBehavior#DO_NOT_CREATE`.

### destroyWorkspace

    public boolean destroyWorkspace(String name)

  Removes the named workspace from the `#workspaces workspaces map`.

  Parameters:
    `name` - the name of the workspace to remove
  Returns:
    `true` if a workspace with that name previously existed in the map

### startTransaction

    public abstract MapRepositoryTransaction startTransaction(boolean readonly)

  Begin a transaction, hinting whether the transaction will be used only to read the content. If this is called, then the transaction must be either `committed` or `rolled back`.

  Parameters:
    `readonly` - true if the transaction will not modify any content, or false if changes are to be made
  Returns:
    the transaction; never null
  See Also:
    `MapRepositoryTransaction.commit()`, `MapRepositoryTransaction.rollback()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.