org.modeshape.connector.meta.jdbc
Class JdbcMetadataSource

java.lang.Object
  extended by org.modeshape.graph.connector.base.AbstractRepositorySource
      extended by org.modeshape.connector.meta.jdbc.JdbcMetadataSource
All Implemented Interfaces:
Serializable, Referenceable, ObjectFactory, BaseRepositorySource, RepositorySource

@ThreadSafe
public class JdbcMetadataSource
extends AbstractRepositorySource
implements ObjectFactory

See Also:
Serialized Form

Field Summary
protected static String CACHE_TIME_TO_LIVE_IN_MILLISECONDS
           
protected static String DATA_SOURCE_JNDI_NAME
           
protected static String DEFAULT_CATALOG_NAME
           
static String DEFAULT_NAME_OF_DEFAULT_CATALOG
          The initial catalog name for databases that do not support catalogs is ""default" ", unless otherwise specified.
static String DEFAULT_NAME_OF_DEFAULT_SCHEMA
          The initial schema name for databases that do not support schemas is ""default" ", unless otherwise specified.
static String DEFAULT_NAME_OF_DEFAULT_WORKSPACE
          The initial name of the default workspace is ""default" ", unless otherwise specified.
protected static String DEFAULT_SCHEMA_NAME
           
protected static String DEFAULT_WORKSPACE
           
protected static String DRIVER_CLASS_NAME
           
protected static String DRIVER_CLASSLOADER_NAME
           
protected static String IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS
           
protected static String MAXIMUM_CONNECTION_IDLE_TIME_IN_SECONDS
           
protected static String MAXIMUM_CONNECTIONS_IN_POOL
           
protected static String MAXIMUM_SIZE_OF_STATEMENT_CACHE
           
protected static String METADATA_COLLECTOR_CLASS_NAME
           
protected static String MINIMUM_CONNECTIONS_IN_POOL
           
protected static String NUMBER_OF_CONNECTIONS_TO_BE_ACQUIRED_AS_NEEDED
           
protected static String PASSWORD
           
protected static String RETRY_LIMIT
           
protected static String ROOT_NODE_UUID
           
protected static String SOURCE_NAME
           
static boolean SUPPORTS_CREATING_WORKSPACES
          This source does not support creating workspaces.
protected static boolean SUPPORTS_EVENTS
          This source does not support events.
protected static boolean SUPPORTS_REFERENCES
          This source does not support creating references.
protected static boolean SUPPORTS_SAME_NAME_SIBLINGS
          This source does support same-name-siblings for procedure nodes.
static boolean SUPPORTS_UPDATES
          This source does not support updates.
protected static String URL
           
protected static String USERNAME
           
 
Fields inherited from class org.modeshape.graph.connector.base.AbstractRepositorySource
cachePolicy, DEFAULT_CACHE_POLICY, DEFAULT_RETRY_LIMIT, DEFAULT_ROOT_NODE_UUID, repositoryContext, retryLimit, rootNodeUuid
 
Constructor Summary
JdbcMetadataSource()
           
 
Method Summary
 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 getDataSourceJndiName()
           
 String getDefaultCatalogName()
          Get the name of the default catalog.
 String getDefaultSchemaName()
          Get the name of the default schema.
 String getDefaultWorkspaceName()
          Get the name of the default workspace.
 String getDriverClassloaderName()
           
 String getDriverClassName()
           
 int getIdleTimeInSecondsBeforeTestingConnections()
           
 int getMaximumConnectionIdleTimeInSeconds()
           
 int getMaximumConnectionsInPool()
           
 int getMaximumSizeOfStatementCache()
           
 MetadataCollector getMetadataCollector()
          Returns the metadata collector instance
 String getMetadataCollectorClassName()
          Get the class name of the metadata collector.
 int getMinimumConnectionsInPool()
           
 int getNumberOfConnectionsToAcquireAsNeeded()
           
 Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
           
 String getPassword()
           
 Reference getReference()
           
 String getUrl()
           
 String getUsername()
           
 void setDataSourceJndiName(String dataSourceJndiName)
           
 void setDefaultCatalogName(String defaultCatalogName)
          Set the name of the catalog that should be used when the database does not support catalogs.
 void setDefaultSchemaName(String defaultSchemaName)
          Set the name of the schema that should be used when the database does not support schemas.
 void setDefaultWorkspaceName(String nameOfDefaultWorkspace)
          Set the name of the workspace that should be used when clients don't specify a workspace.
 void setDriverClassloaderName(String driverClassloaderName)
           
 void setDriverClassName(String driverClassName)
           
 void setIdleTimeInSecondsBeforeTestingConnections(int idleTimeInSecondsBeforeTestingConnections)
           
 void setMaximumConnectionIdleTimeInSeconds(int maximumConnectionIdleTimeInSeconds)
           
 void setMaximumConnectionsInPool(int maximumConnectionsInPool)
           
 void setMaximumSizeOfStatementCache(int maximumSizeOfStatementCache)
           
 void setMetadataCollectorClassName(String metadataCollectorClassName)
          Set the class name of the metadata collector and instantiates a new metadata collector object for that class
 void setMinimumConnectionsInPool(int minimumConnectionsInPool)
           
 void setNumberOfConnectionsToAcquireAsNeeded(int numberOfConnectionsToAcquireAsNeeded)
           
 void setPassword(String password)
           
 void setUpdatesAllowed(boolean updatesAllowed)
          In-memory connectors aren't shared and cannot be loaded from external sources if updates are not allowed.
 void setUrl(String url)
           
 void setUsername(String username)
           
 
Methods inherited from class org.modeshape.graph.connector.base.AbstractRepositorySource
areUpdatesAllowed, getDefaultCachePolicy, getName, getRepositoryContext, getRetryLimit, getRootNodeUuid, getRootNodeUuidObject, initialize, setCachePolicy, setName, setRetryLimit, setRootNodeUuid, setRootNodeUuidObject, valuesFrom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCE_NAME

protected static final String SOURCE_NAME
See Also:
Constant Field Values

ROOT_NODE_UUID

protected static final String ROOT_NODE_UUID
See Also:
Constant Field Values

DATA_SOURCE_JNDI_NAME

protected static final String DATA_SOURCE_JNDI_NAME
See Also:
Constant Field Values

USERNAME

protected static final String USERNAME
See Also:
Constant Field Values

PASSWORD

protected static final String PASSWORD
See Also:
Constant Field Values

URL

protected static final String URL
See Also:
Constant Field Values

DRIVER_CLASS_NAME

protected static final String DRIVER_CLASS_NAME
See Also:
Constant Field Values

DRIVER_CLASSLOADER_NAME

protected static final String DRIVER_CLASSLOADER_NAME
See Also:
Constant Field Values

MAXIMUM_CONNECTIONS_IN_POOL

protected static final String MAXIMUM_CONNECTIONS_IN_POOL
See Also:
Constant Field Values

MINIMUM_CONNECTIONS_IN_POOL

protected static final String MINIMUM_CONNECTIONS_IN_POOL
See Also:
Constant Field Values

MAXIMUM_CONNECTION_IDLE_TIME_IN_SECONDS

protected static final String MAXIMUM_CONNECTION_IDLE_TIME_IN_SECONDS
See Also:
Constant Field Values

MAXIMUM_SIZE_OF_STATEMENT_CACHE

protected static final String MAXIMUM_SIZE_OF_STATEMENT_CACHE
See Also:
Constant Field Values

NUMBER_OF_CONNECTIONS_TO_BE_ACQUIRED_AS_NEEDED

protected static final String NUMBER_OF_CONNECTIONS_TO_BE_ACQUIRED_AS_NEEDED
See Also:
Constant Field Values

IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS

protected static final String IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS
See Also:
Constant Field Values

CACHE_TIME_TO_LIVE_IN_MILLISECONDS

protected static final String CACHE_TIME_TO_LIVE_IN_MILLISECONDS
See Also:
Constant Field Values

RETRY_LIMIT

protected static final String RETRY_LIMIT
See Also:
Constant Field Values

DEFAULT_WORKSPACE

protected static final String DEFAULT_WORKSPACE
See Also:
Constant Field Values

DEFAULT_CATALOG_NAME

protected static final String DEFAULT_CATALOG_NAME
See Also:
Constant Field Values

DEFAULT_SCHEMA_NAME

protected static final String DEFAULT_SCHEMA_NAME
See Also:
Constant Field Values

METADATA_COLLECTOR_CLASS_NAME

protected static final String METADATA_COLLECTOR_CLASS_NAME
See Also:
Constant Field Values

SUPPORTS_EVENTS

protected static final boolean SUPPORTS_EVENTS
This source does not support events.

See Also:
Constant Field Values

SUPPORTS_SAME_NAME_SIBLINGS

protected static final boolean SUPPORTS_SAME_NAME_SIBLINGS
This source does support same-name-siblings for procedure nodes.

See Also:
Constant Field Values

SUPPORTS_REFERENCES

protected static final boolean SUPPORTS_REFERENCES
This source does not support creating references.

See Also:
Constant Field Values

SUPPORTS_UPDATES

public static final boolean SUPPORTS_UPDATES
This source does not support updates.

See Also:
Constant Field Values

SUPPORTS_CREATING_WORKSPACES

public static final boolean SUPPORTS_CREATING_WORKSPACES
This source does not support creating workspaces.

See Also:
Constant Field Values

DEFAULT_NAME_OF_DEFAULT_WORKSPACE

public static final String DEFAULT_NAME_OF_DEFAULT_WORKSPACE
The initial name of the default workspace is ""default" ", unless otherwise specified.

See Also:
Constant Field Values

DEFAULT_NAME_OF_DEFAULT_CATALOG

public static final String DEFAULT_NAME_OF_DEFAULT_CATALOG
The initial catalog name for databases that do not support catalogs is ""default" ", unless otherwise specified.

See Also:
Constant Field Values

DEFAULT_NAME_OF_DEFAULT_SCHEMA

public static final String DEFAULT_NAME_OF_DEFAULT_SCHEMA
The initial schema name for databases that do not support schemas is ""default" ", unless otherwise specified.

See Also:
Constant Field Values
Constructor Detail

JdbcMetadataSource

public JdbcMetadataSource()
Method Detail

close

public void close()
Description copied from class: AbstractRepositorySource
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
Overrides:
close in class AbstractRepositorySource
See Also:
RepositorySource.close()

getCapabilities

public RepositorySourceCapabilities getCapabilities()
Description copied from interface: RepositorySource
Get the capabilities for this source.

Specified by:
getCapabilities in interface RepositorySource
Returns:
the capabilities for this source; never null

getConnection

public RepositoryConnection getConnection()
                                   throws RepositorySourceException
Description copied from interface: RepositorySource
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

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

getDataSourceJndiName

public String getDataSourceJndiName()
Returns:
dataSourceJndiName

setDataSourceJndiName

public void setDataSourceJndiName(String dataSourceJndiName)
Parameters:
dataSourceJndiName - Sets dataSourceJndiName to the specified value.

getDriverClassName

public String getDriverClassName()
Returns:
driverClassName

setDriverClassName

public void setDriverClassName(String driverClassName)
Parameters:
driverClassName - Sets driverClassName to the specified value.

getDriverClassloaderName

public String getDriverClassloaderName()
Returns:
driverClassloaderName

setDriverClassloaderName

public void setDriverClassloaderName(String driverClassloaderName)
Parameters:
driverClassloaderName - Sets driverClassloaderName to the specified value.

getUsername

public String getUsername()
Returns:
username

setUsername

public void setUsername(String username)
Parameters:
username - Sets username to the specified value.

getPassword

public String getPassword()
Returns:
password

setPassword

public void setPassword(String password)
Parameters:
password - Sets password to the specified value.

getUrl

public String getUrl()
Returns:
url

setUrl

public void setUrl(String url)
Parameters:
url - Sets url to the specified value.

getMaximumConnectionsInPool

public int getMaximumConnectionsInPool()
Returns:
maximumConnectionsInPool

setMaximumConnectionsInPool

public void setMaximumConnectionsInPool(int maximumConnectionsInPool)
Parameters:
maximumConnectionsInPool - Sets maximumConnectionsInPool to the specified value.

getMinimumConnectionsInPool

public int getMinimumConnectionsInPool()
Returns:
minimumConnectionsInPool

setMinimumConnectionsInPool

public void setMinimumConnectionsInPool(int minimumConnectionsInPool)
Parameters:
minimumConnectionsInPool - Sets minimumConnectionsInPool to the specified value.

getMaximumConnectionIdleTimeInSeconds

public int getMaximumConnectionIdleTimeInSeconds()
Returns:
maximumConnectionIdleTimeInSeconds

setMaximumConnectionIdleTimeInSeconds

public void setMaximumConnectionIdleTimeInSeconds(int maximumConnectionIdleTimeInSeconds)
Parameters:
maximumConnectionIdleTimeInSeconds - Sets maximumConnectionIdleTimeInSeconds to the specified value.

getMaximumSizeOfStatementCache

public int getMaximumSizeOfStatementCache()
Returns:
maximumSizeOfStatementCache

setMaximumSizeOfStatementCache

public void setMaximumSizeOfStatementCache(int maximumSizeOfStatementCache)
Parameters:
maximumSizeOfStatementCache - Sets maximumSizeOfStatementCache to the specified value.

getNumberOfConnectionsToAcquireAsNeeded

public int getNumberOfConnectionsToAcquireAsNeeded()
Returns:
numberOfConnectionsToAcquireAsNeeded

setNumberOfConnectionsToAcquireAsNeeded

public void setNumberOfConnectionsToAcquireAsNeeded(int numberOfConnectionsToAcquireAsNeeded)
Parameters:
numberOfConnectionsToAcquireAsNeeded - Sets numberOfConnectionsToAcquireAsNeeded to the specified value.

getIdleTimeInSecondsBeforeTestingConnections

public int getIdleTimeInSecondsBeforeTestingConnections()
Returns:
idleTimeInSecondsBeforeTestingConnections

setIdleTimeInSecondsBeforeTestingConnections

public void setIdleTimeInSecondsBeforeTestingConnections(int idleTimeInSecondsBeforeTestingConnections)
Parameters:
idleTimeInSecondsBeforeTestingConnections - Sets idleTimeInSecondsBeforeTestingConnections to the specified value.

getDefaultWorkspaceName

public String getDefaultWorkspaceName()
Get the name of the default workspace.

Specified by:
getDefaultWorkspaceName in interface BaseRepositorySource
Returns:
the name of the workspace that should be used by default, or null if there is no default workspace

setDefaultWorkspaceName

public void setDefaultWorkspaceName(String nameOfDefaultWorkspace)
Set the name of the workspace that should be used when clients don't specify a workspace.

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

getDefaultCatalogName

public String getDefaultCatalogName()
Get the name of the default catalog.

Returns:
the name that should be used as the catalog name when the database does not support catalogs

setDefaultCatalogName

public void setDefaultCatalogName(String defaultCatalogName)
Set the name of the catalog that should be used when the database does not support catalogs.

Parameters:
defaultCatalogName - the name that should be used as the catalog name by default, or null if the default name should be used

getDefaultSchemaName

public String getDefaultSchemaName()
Get the name of the default schema.

Returns:
the name that should be used as the schema name when the database does not support schemas

setDefaultSchemaName

public void setDefaultSchemaName(String defaultSchemaName)
Set the name of the schema that should be used when the database does not support schemas.

Parameters:
defaultSchemaName - the name that should be used as the schema name by default, or null if the default name should be used

getMetadataCollectorClassName

public String getMetadataCollectorClassName()
Get the class name of the metadata collector.

Returns:
the name the class name of the metadata collector

setMetadataCollectorClassName

public void setMetadataCollectorClassName(String metadataCollectorClassName)
                                   throws ClassNotFoundException,
                                          IllegalAccessException,
                                          InstantiationException
Set the class name of the metadata collector and instantiates a new metadata collector object for that class

Parameters:
metadataCollectorClassName - the class name for the metadata collector, or null if the default metadata collector should be used
Throws:
ClassNotFoundException - if the the named metadata collector class cannot be located
IllegalAccessException - if the metadata collector class or its nullary constructor is not accessible.
InstantiationException - if the metadata collector class represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
ClassCastException - if the given class cannot be cast to MetadataCollector.
See Also:
Class.forName(String), Class.newInstance()

getMetadataCollector

public MetadataCollector getMetadataCollector()
Returns the metadata collector instance

Returns:
the metadata collector

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


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