org.modeshape.graph.connector.xmlfile
Class XmlFileRepositorySource

java.lang.Object
  extended by org.modeshape.graph.connector.xmlfile.XmlFileRepositorySource
All Implemented Interfaces:
Serializable, Referenceable, ObjectFactory, RepositorySource

@ThreadSafe
public class XmlFileRepositorySource
extends Object
implements RepositorySource, ObjectFactory

A RepositorySource for a in-memory repository with content defined by an XML file. Note that any changes made to the content are not currently persisted back to the XML file.

See Also:
Serialized Form

Nested Class Summary
protected  class XmlFileRepositorySource.DefaultRepositoryContext
           
 
Field Summary
protected static RepositorySourceCapabilities CAPABILITIES
           
protected static String CONTENT_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 RETRY_LIMIT_ATTR
           
protected static String SOURCE_NAME_ATTR
           
 
Constructor Summary
XmlFileRepositorySource()
          Create a repository source instance.
 
Method Summary
 boolean areUpdatesAllowed()
           
 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.
 String getContentLocation()
          Get the location where the initial content is defined.
 String getDefaultWorkspaceName()
          Get the name of the workspace that should be used by default.
 String getName()
          Get the name for this repository source.
 Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
          
 Reference getReference()
          
 RepositoryContext getRepositoryContext()
           
 int getRetryLimit()
          Get the maximum number of retries that may be performed on a given operation when using connections created by this source.
 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.
 void setContentLocation(String uriOrFilePathOrResourcePath)
          Set the location where the initial content is defined.
 void setDefaultWorkspaceName(String defaultWorkspaceName)
          Set the default workspace name.
 void setName(String name)
           
 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.
 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

CONTENT_ATTR

protected static final String CONTENT_ATTR
See Also:
Constant Field Values

SOURCE_NAME_ATTR

protected static final String SOURCE_NAME_ATTR
See Also:
Constant Field Values

DEFAULT_WORKSPACE_NAME_ATTR

protected static final String DEFAULT_WORKSPACE_NAME_ATTR
See Also:
Constant Field Values

RETRY_LIMIT_ATTR

protected static final String RETRY_LIMIT_ATTR
See Also:
Constant Field Values
Constructor Detail

XmlFileRepositorySource

public XmlFileRepositorySource()
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()
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)

getDefaultWorkspaceName

public String getDefaultWorkspaceName()
Get the name of the workspace that should be used by default.

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

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.

getContentLocation

public String getContentLocation()
Get the location where the initial content is defined.

Returns:
the URL, file path, or classpath resource path to the file containing the content, or null if there is no such content

setContentLocation

public void setContentLocation(String uriOrFilePathOrResourcePath)
Set the location where the initial content is defined.

Parameters:
uriOrFilePathOrResourcePath - the URL, file path, or classpath resource path to the file containing the content

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

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()

toString

public String toString()

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


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