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.connector.disk
Class DiskRepository

    java.lang.Object
      org.modeshape.graph.connector.base.Repository<DiskNode,DiskWorkspace>
          org.modeshape.connector.disk.DiskRepository

    @ThreadSafe
    public class DiskRepository

extends Repository<DiskNode,DiskWorkspace>

The representation of a disk-based repository and its content.

Field Summary
`protected FileChannel` | `lockFileChannel`
`protected static Logger` | `LOGGER`
`protected AtomicInteger` | `readLockCount`

Fields inherited from class org.modeshape.graph.connector.base.Repository
`context, rootNodeUuid, source`

Constructor Summary
`DiskRepository(DiskSource source)`

Method Summary
`DiskWorkspace` | `createWorkspace(Transaction<DiskNode,DiskWorkspace> 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.
`protected File` | `getRepositoryRoot()` Get the root of this repository
`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.
`DiskTransaction` | `startTransaction(ExecutionContext context, boolean readonly)` Begin a transaction, hinting whether the transaction will be used only to read the content.

Methods inherited from class org.modeshape.graph.connector.base.Repository
`createRequestProcessor, destroyWorkspace, getContext, getDefaultWorkspaceName, getRootNodeUuid, getSourceName, getWorkspace`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOGGER

    protected static final Logger LOGGER

### lockFileChannel

    protected final FileChannel lockFileChannel

### readLockCount

    protected AtomicInteger readLockCount

Constructor Detail

### DiskRepository

    public DiskRepository(DiskSource source)

Method Detail

### initialize

    protected void initialize()

  Description copied from class: `Repository`
  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` .

  Overrides:
    `initialize` in class `Repository<DiskNode,DiskWorkspace>`

### createWorkspace

    public DiskWorkspace createWorkspace(Transaction<DiskNode,DiskWorkspace> txn,
                                         String name,
                                         CreateWorkspaceRequest.CreateConflictBehavior existingWorkspaceBehavior,
                                         String nameOfWorkspaceToClone)
                                  throws InvalidWorkspaceException

  Description copied from class: `Repository`
  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.

  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.

  Overrides:
    `createWorkspace` in class `Repository<DiskNode,DiskWorkspace>`
  Parameters:
    `txn` - the transaction creating the workspace; 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; be null if the new workspace is to be empty (other than the root node)
  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`.
  Throws:
    `InvalidWorkspaceException` - if the workspace could not be created

### getWorkspaceNames

    public Set<String> getWorkspaceNames()

  Get the names of the available workspaces that have been loaded.

  Overrides:
    `getWorkspaceNames` in class `Repository<DiskNode,DiskWorkspace>`
  Returns:
    the immutable names of the workspaces.
  See Also:
    `Repository.getWorkspaceNames()`

### getRepositoryRoot

    protected File getRepositoryRoot()

  Get the root of this repository

  Returns:
    the root of this repository; never null

### startTransaction

    public DiskTransaction startTransaction(ExecutionContext context,
                                            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`.

  Specified by:
    `startTransaction` in class `Repository<DiskNode,DiskWorkspace>`
  Parameters:
    `context` - the context in which the transaction is to be performed; may not be null
    `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:
    `Repository.startTransaction(org.modeshape.graph.ExecutionContext, boolean)`

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-2012 JBoss, a division of Red Hat. All Rights Reserved.