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.inmemory
Class InMemoryRepositorySource

    java.lang.Object
      org.modeshape.graph.connector.inmemory.InMemoryRepositorySource

All Implemented Interfaces:
  Serializable, Referenceable, ObjectFactory, BaseRepositorySource, RepositorySource

    @ThreadSafe
    public class InMemoryRepositorySource

extends Object
implements BaseRepositorySource, ObjectFactory

A `RepositorySource` for an in-memory repository. Each `InMemoryRepositorySource` instance contains its own repository, and the lifetime of the source dictates the lifetime of the repository and its content.

See Also:
  Serialized Form

Nested Class Summary
`protected class` | `InMemoryRepositorySource.DefaultRepositoryContext`

Field Summary
`protected static RepositorySourceCapabilities` | `CAPABILITIES`
`protected static String` | `DEFAULT_CACHE_POLICY_ATTR`
`static int` | `DEFAULT_RETRY_LIMIT` The default limit is 0 for retrying `connection` calls to the underlying source.
`static String` | `DEFAULT_WORKSPACE_NAME` The default name for the workspace used by this source, which is a blank string.
`protected static String` | `DEFAULT_WORKSPACE_NAME_ATTR`
`protected static String` | `JNDI_NAME_ATTR`
`protected static String` | `PREDEFINED_WORKSPACE_NAMES`
`protected static String` | `RETRY_LIMIT_ATTR`
`protected static String` | `ROOT_NODE_UUID_ATTR`
`protected static String` | `SOURCE_NAME_ATTR`

Constructor Summary
`InMemoryRepositorySource()` Create a repository source instance.

Method Summary
`boolean` | `areUpdatesAllowed()` Get whether this source allows updates.
`void` | `close()` Signal this source that it is no longer needed and should begin the process of reclaiming or closing all resources that it has acquired.
`RepositorySourceCapabilities` | `getCapabilities()` Get the capabilities for this source.
`RepositoryConnection` | `getConnection()` Get a connection from this source.
`CachePolicy` | `getDefaultCachePolicy()` Get the default cache policy for this source, or null if the global default cache policy should be used
`String` | `getDefaultWorkspaceName()` Get the name of the workspace that should be used by default.
`String` | `getJndiName()` Gets the JNDI name this source is bound to.
`String` | `getName()` Get the name for this repository source.
`Object` | `getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)`
`String[]` | `getPredefinedWorkspaceNames()` Gets the names of the workspaces that are available when this source is created.
`Reference` | `getReference()`
`RepositoryContext` | `getRepositoryContext()` Returns the `repository context` for the repository source
`int` | `getRetryLimit()` Get the maximum number of retries that may be performed on a given operation when using `connections` created by this source.
`String` | `getRootNodeUuid()` Get the string representation of the UUID for the root node.
`UUID` | `getRootNodeUuidObject()` Get the UUID for the root node.
`void` | `initialize(RepositoryContext context)` Initialize this source to use the supplied `RepositoryContext`, from which this source can obtain the `configuration` defining this source, `connections` to other `sources`, and the `execution context`.
`boolean` | `isCreatingWorkspacesAllowed()` Get whether this source allows workspaces to be created.
`void` | `setDefaultCachePolicy(CachePolicy defaultCachePolicy)`
`void` | `setDefaultWorkspaceName(String defaultWorkspaceName)` Set the default workspace name.
`void` | `setJndiName(String name)` If you use this to set a JNDI name, this source will be bound to that name using the default `InitialContext`.
`void` | `setJndiName(String name, Context context)` Register this source in JNDI under the supplied name using the supplied context. to set a JNDI name, this source will be bound to that name using the default `InitialContext`.
`void` | `setName(String name)`
`void` | `setPredefinedWorkspaceNames(String[] predefinedWorkspaceNames)` Sets the names of the workspaces that are available when this source is created.
`void` | `setRetryLimit(int limit)` Set the maximum number of retries that may be performed on a given operation when using `connections` created by this source.
`void` | `setRootNodeUuid(String rootNodeUuid)`
`void` | `setRootNodeUuid(UUID rootNodeUuid)`
`void` | `setUpdatesAllowed(boolean updatesAllowed)` In-memory connectors aren't shared and cannot be loaded from external sources if updates are not allowed.
`String` | `toString()`

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

Field Detail

### DEFAULT_RETRY_LIMIT

    public static final int DEFAULT_RETRY_LIMIT

  The default limit is 0 for retrying `connection` calls to the underlying source.

  See Also:
    Constant Field Values

### DEFAULT_WORKSPACE_NAME

    public static final String DEFAULT_WORKSPACE_NAME

  The default name for the workspace used by this source, which is a blank string.

  See Also:
    Constant Field Values

### CAPABILITIES

    protected static final RepositorySourceCapabilities CAPABILITIES

### ROOT_NODE_UUID_ATTR

    protected static final String ROOT_NODE_UUID_ATTR

See Also:
  Constant Field Values

### SOURCE_NAME_ATTR

    protected static final String SOURCE_NAME_ATTR

See Also:
  Constant Field Values

### PREDEFINED_WORKSPACE_NAMES

    protected static final String PREDEFINED_WORKSPACE_NAMES

See Also:
  Constant Field Values

### DEFAULT_WORKSPACE_NAME_ATTR

    protected static final String DEFAULT_WORKSPACE_NAME_ATTR

See Also:
  Constant Field Values

### DEFAULT_CACHE_POLICY_ATTR

    protected static final String DEFAULT_CACHE_POLICY_ATTR

See Also:
  Constant Field Values

### JNDI_NAME_ATTR

    protected static final String JNDI_NAME_ATTR

See Also:
  Constant Field Values

### RETRY_LIMIT_ATTR

    protected static final String RETRY_LIMIT_ATTR

See Also:
  Constant Field Values

Constructor Detail

### InMemoryRepositorySource

    public InMemoryRepositorySource()

  Create a repository source instance.

Method Detail

### initialize

    public void initialize(RepositoryContext context)
                    throws RepositorySourceException

  Initialize this source to use the supplied `RepositoryContext`, from which this source can obtain the `configuration` defining this source, `connections` to other `sources`, and the `execution context`.

  This method may be called each time the configuration changes, allowing the source to update itself.

  Specified by:
    `initialize` in interface `RepositorySource`
  Throws:
    `RepositorySourceException`
  See Also:
    `RepositorySource.initialize(org.modeshape.graph.connector.RepositoryContext)`

### getRepositoryContext

    public RepositoryContext getRepositoryContext()

  Description copied from interface: `BaseRepositorySource`
  Returns the `repository context` for the repository source

  Specified by:
    `getRepositoryContext` in interface `BaseRepositorySource`
  Returns:
    repositoryContext

### getRetryLimit

    public int getRetryLimit()

  Get the maximum number of retries that may be performed on a given operation when using `connections` created by this source. This value does not constitute a minimum number of retries; in fact, the connection user is not required to retry any operations.

  Specified by:
    `getRetryLimit` in interface `RepositorySource`
  Returns:
    the maximum number of allowable retries, or 0 if the source has no limit
  See Also:
    `RepositorySource.getRetryLimit()`

### setRetryLimit

    public void setRetryLimit(int limit)

  Set the maximum number of retries that may be performed on a given operation when using `connections` created by this source. This value does not constitute a minimum number of retries; in fact, the connection user is not required to retry any operations.

  Specified by:
    `setRetryLimit` in interface `RepositorySource`
  Parameters:
    `limit` - the maximum number of allowable retries, or 0 if the source has no limit
  See Also:
    `RepositorySource.setRetryLimit(int)`

### getDefaultCachePolicy

    public CachePolicy getDefaultCachePolicy()

  Get the default cache policy for this source, or null if the global default cache policy should be used

  Specified by:
    `getDefaultCachePolicy` in interface `BaseRepositorySource`
  Returns:
    the default cache policy, or null if this source has no explicit default cache policy

### setDefaultCachePolicy

    public void setDefaultCachePolicy(CachePolicy defaultCachePolicy)

  Parameters:
    `defaultCachePolicy` - Sets defaultCachePolicy to the specified value.

### getDefaultWorkspaceName

    public String getDefaultWorkspaceName()

  Get the name of the workspace that should be used by default.

  Specified by:
    `getDefaultWorkspaceName` in interface `BaseRepositorySource`
  Returns:
    the name of the default workspace

### setDefaultWorkspaceName

    public void setDefaultWorkspaceName(String defaultWorkspaceName)

  Set the default workspace name.

  Parameters:
    `defaultWorkspaceName` - the name of the workspace that should be used by default, or null if "" should be used

### getRootNodeUuid

    public String getRootNodeUuid()

  Get the string representation of the UUID for the root node.

  Returns:
    the root node's UUID as a string; may not be null

### getRootNodeUuidObject

    public UUID getRootNodeUuidObject()

  Get the UUID for the root node.

  Specified by:
    `getRootNodeUuidObject` in interface `BaseRepositorySource`
  Returns:
    the root node's UUID; may not be null
  See Also:
    `BaseRepositorySource.getRootNodeUuidObject()`

### setRootNodeUuid

    public void setRootNodeUuid(UUID rootNodeUuid)

  Parameters:
    `rootNodeUuid` - Sets rootNodeUuid to the specified value.

### setRootNodeUuid

    public void setRootNodeUuid(String rootNodeUuid)

  Parameters:
    `rootNodeUuid` - Sets rootNodeUuid to the specified value.

### setJndiName

    public void setJndiName(String name)
                     throws NamingException

  If you use this to set a JNDI name, this source will be bound to that name using the default `InitialContext`. You can also do this manually if you have additional requirements.

  Parameters:
    `name` - the JNDI name
  Throws:
    `NamingException` - if there is a problem registering this object
  See Also:
    `getJndiName()`

### setJndiName

    public void setJndiName(String name,
                            Context context)
                     throws NamingException

  Register this source in JNDI under the supplied name using the supplied context. to set a JNDI name, this source will be bound to that name using the default `InitialContext`. You can also do this manually if you have additional requirements.

  Parameters:
    `name` - the JNDI name, or null if this object is to no longer be registered
    `context` - the JNDI context, or null if the `InitialContext` should be used
  Throws:
    `NamingException` - if there is a problem registering this object
  See Also:
    `getJndiName()`

### getJndiName

    public String getJndiName()

  Gets the JNDI name this source is bound to. Only valid if you used setJNDIName to bind it.

  Returns:
    the JNDI name, or null if it is not bound in JNDI
  See Also:
    `setJndiName(String)`

### getName

    public String getName()

  Get the name for this repository source.

  Specified by:
    `getName` in interface `RepositorySource`
  Returns:
    the name; never null or empty

### setName

    public void setName(String name)

  Parameters:
    `name` - Sets name to the specified value.

### getConnection

    public RepositoryConnection getConnection()
                                       throws RepositorySourceException

  Get a connection from this source. Even though each RepositorySource need not be thread safe, this method should be safe to be called concurrently by multiple threads.

  Specified by:
    `getConnection` in interface `RepositorySource`
  Returns:
    a connection
  Throws:
    `RepositorySourceException` - if there is a problem obtaining a connection
  See Also:
    `RepositorySource.getConnection()`

### close

    public void close()

  Signal this source that it is no longer needed and should begin the process of reclaiming or closing all resources that it has acquired. Because `connections` may still be in use, this method may not necessarily close all resources immediately.

  This is a required method, and must be called when this source is no longer needed if one or more `connections` have been obtained since the previous call to this method.

  Note that calling this method also does not preclude `obtaining more connections` after this method is called. If that happens, this source should simply reacquire any resources necessary to provide additional connections, and this method needs to be called once again.

  Specified by:
    `close` in interface `RepositorySource`
  See Also:
    `RepositorySource.close()`

### getReference

    public Reference getReference()

  Specified by:
    `getReference` in interface `Referenceable`

### getObjectInstance

    public Object getObjectInstance(Object obj,
                                    Name name,
                                    Context nameCtx,
                                    Hashtable<?,?> environment)
                             throws Exception

  Specified by:
    `getObjectInstance` in interface `ObjectFactory`
  Throws:
    `Exception`

### getPredefinedWorkspaceNames

    public String[] getPredefinedWorkspaceNames()

  Gets the names of the workspaces that are available when this source is created.

  Returns:
    the names of the workspaces that this source starts with, or null if there are no such workspaces
  See Also:
    `setPredefinedWorkspaceNames(String[])`

### setPredefinedWorkspaceNames

    public void setPredefinedWorkspaceNames(String[] predefinedWorkspaceNames)

  Sets the names of the workspaces that are available when this source is created.

  Parameters:
    `predefinedWorkspaceNames` - the names of the workspaces that this source should start with, or null if there are no such workspaces
  See Also:
    `getPredefinedWorkspaceNames()`

### getCapabilities

    public RepositorySourceCapabilities getCapabilities()

  Get the capabilities for this source.

  Specified by:
    `getCapabilities` in interface `RepositorySource`
  Returns:
    the capabilities for this source; never null
  See Also:
    `RepositorySource.getCapabilities()`

### areUpdatesAllowed

    @Description(i18n=GraphI18n.class,
                 value="updatesAllowedPropertyDescription")
    @Label(i18n=GraphI18n.class,
           value="updatesAllowedPropertyLabel")
    @Category(i18n=GraphI18n.class,
              value="updatesAllowedPropertyCategory")
    @ReadOnly
    public boolean areUpdatesAllowed()

  Description copied from interface: `BaseRepositorySource`
  Get whether this source allows updates.

  Specified by:
    `areUpdatesAllowed` in interface `BaseRepositorySource`
  Returns:
    true if this source allows updates by clients, or false if no updates are allowed
  See Also:
    `BaseRepositorySource.setUpdatesAllowed(boolean)`

### isCreatingWorkspacesAllowed

    @Description(i18n=GraphI18n.class,
                 value="creatingWorkspacesAllowedPropertyDescription")
    @Label(i18n=GraphI18n.class,
           value="creatingWorkspacesAllowedPropertyLabel")
    @Category(i18n=GraphI18n.class,
              value="creatingWorkspacesAllowedPropertyCategory")
    @ReadOnly
    public boolean isCreatingWorkspacesAllowed()

  Description copied from interface: `BaseRepositorySource`
  Get whether this source allows workspaces to be created.

  Specified by:
    `isCreatingWorkspacesAllowed` in interface `BaseRepositorySource`
  Returns:
    true if this source allows workspaces to be created by clients, or false if creating workspaces is not allowed

### setUpdatesAllowed

    public void setUpdatesAllowed(boolean updatesAllowed)

  In-memory connectors aren't shared and cannot be loaded from external sources if updates are not allowed. Therefore, in order to avoid setting up an in-memory connector that is permanently empty (presumably, not a desired outcome), all in-memory connectors must allow updates.

  Specified by:
    `setUpdatesAllowed` in interface `BaseRepositorySource`
  Parameters:
    `updatesAllowed` - must be true
  Throws:
    `RepositorySourceException` - if `updatesAllowed != true`.
  See Also:
    `BaseRepositorySource.areUpdatesAllowed()`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  See Also:
    `Object.toString()`

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.