|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.modeshape.connector.store.jpa.JpaSource
@ThreadSafe public class JpaSource
The RepositorySource
for the connector that stores content in a (custom) relational database. This connector uses Java
Persistence API as the interface to the database, with Hibernate as the JPA implementation. (Note that some Hibernate-specific
features are used.)
Nested Class Summary | |
---|---|
static class |
JpaSource.Models
This source is capable of using different database schemas |
Field Summary | |
---|---|
protected static String |
ALLOW_CREATING_WORKSPACES
|
protected static String |
AUTO_GENERATE_SCHEMA
|
protected static String |
CACHE_TIME_TO_LIVE_IN_MILLISECONDS
|
protected static String |
COMPRESS_DATA
|
protected static String |
DATA_SOURCE_JNDI_NAME
|
static boolean |
DEFAULT_ALLOWS_UPDATES
This source supports updates by default, but each instance may be configured to be
read-only or updateable . |
static String |
DEFAULT_AUTO_GENERATE_SCHEMA
The initial automatic schema generation setting is ""validate" ", unless otherwise
specified. |
static String |
DEFAULT_NAME_OF_DEFAULT_WORKSPACE
The initial name of the default workspace is ""default" ", unless otherwise specified. |
static String |
DEFAULT_ROOT_NODE_UUID
The default UUID that is used for root nodes in a store. |
static boolean |
DEFAULT_SHOW_SQL
This source does not output executed SQL by default, but this can be overridden by calling setShowSql(boolean) . |
static boolean |
DEFAULT_SUPPORTS_CREATING_WORKSPACES
This source does support creating workspaces. |
protected static String |
DEFAULT_WORKSPACE
|
protected static String |
DIALECT
|
protected static String |
DRIVER_CLASS_NAME
|
protected static String |
DRIVER_CLASSLOADER_NAME
|
protected static String |
ENFORCE_REFERENTIAL_INTEGRITY
|
protected static String |
IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS
|
protected static String |
ISOLATION_LEVEL
|
protected static String |
LARGE_VALUE_SIZE_IN_BYTES
|
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 |
MINIMUM_CONNECTIONS_IN_POOL
|
protected static String |
MODEL_NAME
|
protected static String |
NUMBER_OF_CONNECTIONS_TO_BE_ACQUIRED_AS_NEEDED
|
protected static String |
PASSWORD
|
protected static String |
PREDEFINED_WORKSPACE_NAMES
|
protected static String |
RETRY_LIMIT
|
protected static String |
ROOT_NODE_UUID
|
protected static String |
SOURCE_NAME
|
protected static boolean |
SUPPORTS_AUTOMATIC_GARBAGE_COLLECTION
This source does not support automatic garbage collection. |
protected static boolean |
SUPPORTS_EVENTS
This source supports events. |
protected static boolean |
SUPPORTS_REFERENCES
This source supports creating references. |
protected static boolean |
SUPPORTS_SAME_NAME_SIBLINGS
This source supports same-name-siblings. |
protected static String |
URL
|
protected static String |
USERNAME
|
Constructor Summary | |
---|---|
JpaSource()
|
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. |
protected void |
configure(org.hibernate.ejb.Ejb3Configuration configuration)
Set up the JPA configuration using Hibernate, except for the entity classes (which will already be configured when this method is called) and the data source or connection information (which will be set after this method returns). |
protected String |
determineDialect(javax.persistence.EntityManager entityManager)
Automatically determine the dialect. |
String |
getAutoGenerateSchema()
Get the Hibernate setting dictating what it does with the database schema upon first connection. |
CachePolicy |
getCachePolicy()
Returns the current cache policy |
int |
getCacheTimeToLiveInMilliseconds()
Get the time in milliseconds that content returned from this source may used while in the cache. |
RepositorySourceCapabilities |
getCapabilities()
Get the capabilities for this source. |
RepositoryConnection |
getConnection()
Get a connection from this source. |
String |
getDataSourceJndiName()
|
String |
getDefaultWorkspaceName()
Get the name of the default workspace. |
String |
getDialect()
|
String |
getDriverClassloaderName()
|
String |
getDriverClassName()
|
EntityManagers |
getEntityManagers()
Returns the current EntityManagers reference. |
int |
getIdleTimeInSecondsBeforeTestingConnections()
|
Integer |
getIsolationLevel()
Get the JDBC transaction isolation level that should be used. |
long |
getLargeValueSizeInBytes()
|
protected Logger |
getLogger()
|
int |
getMaximumConnectionIdleTimeInSeconds()
|
int |
getMaximumConnectionsInPool()
|
int |
getMaximumSizeOfStatementCache()
|
int |
getMinimumConnectionsInPool()
|
String |
getModel()
Get the model that will be used. |
String |
getName()
Get the name for this repository source. |
int |
getNumberOfConnectionsToAcquireAsNeeded()
|
Object |
getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable<?,?> environment)
|
String |
getPassword()
|
String[] |
getPredefinedWorkspaceNames()
Gets the names of the workspaces that are available when this source is created. |
Reference |
getReference()
|
RepositoryContext |
getRepositoryContext()
Returns the current repository context for the source, as set with a call to initialize(RepositoryContext) . |
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()
|
UUID |
getRootUuid()
|
boolean |
getShowSql()
Get whether this source outputs the SQL that it executes |
String |
getUrl()
|
String |
getUsername()
|
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 |
isCompressData()
|
boolean |
isCreatingWorkspacesAllowed()
Get whether this source allows workspaces to be created dynamically. |
boolean |
isReferentialIntegrityEnforced()
|
void |
setAllowsUpdates(boolean allowsUpdates)
Set whether this source allows updates. |
void |
setAutoGenerateSchema(String autoGenerateSchema)
Sets the Hibernate setting dictating what it does with the database schema upon first connection. |
void |
setCacheTimeToLiveInMilliseconds(int cacheTimeToLive)
Set the time in milliseconds that content returned from this source may used while in the cache. |
void |
setCompressData(boolean compressData)
|
void |
setCreatingWorkspacesAllowed(boolean allowWorkspaceCreation)
Set whether this source allows workspaces to be created dynamically. |
void |
setDataSourceJndiName(String dataSourceJndiName)
|
void |
setDefaultWorkspaceName(String nameOfDefaultWorkspace)
Set the name of the workspace that should be used when clients don't specify a workspace. |
void |
setDialect(String dialect)
|
void |
setDriverClassloaderName(String driverClassloaderName)
|
void |
setDriverClassName(String driverClassName)
|
void |
setIdleTimeInSecondsBeforeTestingConnections(int idleTimeInSecondsBeforeTestingConnections)
|
void |
setIsolationLevel(Integer isolationLevel)
Set the JDBC transaction isolation level that should be used. |
void |
setLargeValueSizeInBytes(long largeValueSizeInBytes)
|
void |
setMaximumConnectionIdleTimeInSeconds(int maximumConnectionIdleTimeInSeconds)
|
void |
setMaximumConnectionsInPool(int maximumConnectionsInPool)
|
void |
setMaximumSizeOfStatementCache(int maximumSizeOfStatementCache)
|
void |
setMinimumConnectionsInPool(int minimumConnectionsInPool)
|
void |
setModel(String modelName)
Set the model that should be used for this store. |
void |
setName(String name)
Set the name for the source |
void |
setNumberOfConnectionsToAcquireAsNeeded(int numberOfConnectionsToAcquireAsNeeded)
|
void |
setPassword(String password)
|
void |
setPredefinedWorkspaceNames(String[] predefinedWorkspaceNames)
Sets the names of the workspaces that are available when this source is created. |
protected void |
setProperty(org.hibernate.ejb.Ejb3Configuration configurator,
String propertyName,
int propertyValue)
|
protected void |
setProperty(org.hibernate.ejb.Ejb3Configuration configurator,
String propertyName,
String propertyValue)
|
void |
setReferentialIntegrityEnforced(boolean referentialIntegrityEnforced)
|
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 |
setShowSql(boolean showSql)
Sets whether this source should output the SQL that it executes |
void |
setUrl(String url)
|
void |
setUsername(String username)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String SOURCE_NAME
protected static final String ROOT_NODE_UUID
protected static final String DATA_SOURCE_JNDI_NAME
protected static final String DIALECT
protected static final String USERNAME
protected static final String PASSWORD
protected static final String URL
protected static final String DRIVER_CLASS_NAME
protected static final String DRIVER_CLASSLOADER_NAME
protected static final String ISOLATION_LEVEL
protected static final String MAXIMUM_CONNECTIONS_IN_POOL
protected static final String MINIMUM_CONNECTIONS_IN_POOL
protected static final String MAXIMUM_CONNECTION_IDLE_TIME_IN_SECONDS
protected static final String MAXIMUM_SIZE_OF_STATEMENT_CACHE
protected static final String NUMBER_OF_CONNECTIONS_TO_BE_ACQUIRED_AS_NEEDED
protected static final String IDLE_TIME_IN_SECONDS_BEFORE_TESTING_CONNECTIONS
protected static final String CACHE_TIME_TO_LIVE_IN_MILLISECONDS
protected static final String RETRY_LIMIT
protected static final String MODEL_NAME
protected static final String LARGE_VALUE_SIZE_IN_BYTES
protected static final String COMPRESS_DATA
protected static final String ENFORCE_REFERENTIAL_INTEGRITY
protected static final String DEFAULT_WORKSPACE
protected static final String PREDEFINED_WORKSPACE_NAMES
protected static final String ALLOW_CREATING_WORKSPACES
protected static final String AUTO_GENERATE_SCHEMA
protected static final boolean SUPPORTS_EVENTS
protected static final boolean SUPPORTS_AUTOMATIC_GARBAGE_COLLECTION
protected static final boolean SUPPORTS_SAME_NAME_SIBLINGS
protected static final boolean SUPPORTS_REFERENCES
public static final boolean DEFAULT_ALLOWS_UPDATES
be
read-only or updateable
.
public static final boolean DEFAULT_SHOW_SQL
setShowSql(boolean)
.
public static final boolean DEFAULT_SUPPORTS_CREATING_WORKSPACES
public static final String DEFAULT_ROOT_NODE_UUID
public static final String DEFAULT_NAME_OF_DEFAULT_WORKSPACE
name of the default workspace
is ""default" ", unless otherwise specified.
public static final String DEFAULT_AUTO_GENERATE_SCHEMA
automatic schema generation setting
is ""validate" ", unless otherwise
specified.
Constructor Detail |
---|
public JpaSource()
Method Detail |
---|
public String getName()
getName
in interface RepositorySource
RepositorySource.getName()
protected Logger getLogger()
public void setName(String name)
name
- the new name for the sourcepublic RepositorySourceCapabilities getCapabilities()
getCapabilities
in interface RepositorySource
RepositorySource.getCapabilities()
@Description(i18n=JpaConnectorI18n.class, value="updatesAllowedPropertyDescription") @Label(i18n=JpaConnectorI18n.class, value="updatesAllowedPropertyLabel") @Category(i18n=JpaConnectorI18n.class, value="updatesAllowedPropertyCategory") public boolean areUpdatesAllowed()
public void setAllowsUpdates(boolean allowsUpdates)
allowsUpdates
- true if this source allows updating content, or false if this source only allows reading content.public boolean getShowSql()
public void setShowSql(boolean showSql)
showSql
- true if this source should output the SQL that it executes, otherwise falsepublic String getAutoGenerateSchema()
setAutoGenerateSchema(String)
.
public void setAutoGenerateSchema(String autoGenerateSchema)
create
" - Create the database schema objects when the EntityManagerFactory
is created (actually
when Hibernate's SessionFactory
is created by the entity manager factory). If a file named "import.sql" exists in
the root of the class path (e.g., '/import.sql') Hibernate will read and execute the SQL statements in this file after it
has created the database objects. Note that Hibernate first delete all tables, constraints, or any other database object
that is going to be created in the process of building the schema.create-drop
" - Same as "create
", except that the schema will be dropped after the
EntityManagerFactory
is closed.update
" - Attempt to update the database structure to the current mapping (but does not read and invoke
the SQL statements from "import.sql"). Use with caution.validate
" - Validates the existing schema with the current entities configuration, but does not make any
changes to the schema (and does not read and invoke the SQL statements from "import.sql"). This is often the proper setting
to use in production, and thus this is the default value.
autoGenerateSchema
- the setting for the auto-generation, or null if the default should be usedpublic int getRetryLimit()
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.
getRetryLimit
in interface RepositorySource
RepositorySource.getRetryLimit()
public void setRetryLimit(int limit)
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.
setRetryLimit
in interface RepositorySource
limit
- the maximum number of allowable retries, or 0 if the source has no limitRepositorySource.setRetryLimit(int)
public int getCacheTimeToLiveInMilliseconds()
public void setCacheTimeToLiveInMilliseconds(int cacheTimeToLive)
cacheTimeToLive
- the time to live, in milliseconds; 0 if the time to live is not specified by this source; or a
negative number for the default valuepublic CachePolicy getCachePolicy()
public EntityManagers getEntityManagers()
EntityManagers
reference.
EntityManagers
reference.public String getRootNodeUuid()
public UUID getRootUuid()
public void setRootNodeUuid(String rootNodeUuid)
rootNodeUuid
- Sets rootNodeUuid to the specified value.
IllegalArgumentException
- if the string value cannot be converted to UUIDpublic String getDefaultWorkspaceName()
public void setDefaultWorkspaceName(String nameOfDefaultWorkspace)
nameOfDefaultWorkspace
- the name of the workspace that should be used by default, or null if the
default name
should be usedpublic String[] getPredefinedWorkspaceNames()
setPredefinedWorkspaceNames(String[])
,
setCreatingWorkspacesAllowed(boolean)
public void setPredefinedWorkspaceNames(String[] predefinedWorkspaceNames)
predefinedWorkspaceNames
- the names of the workspaces that this source should start with, or null if there are no
such workspacessetCreatingWorkspacesAllowed(boolean)
,
getPredefinedWorkspaceNames()
@Description(i18n=JpaConnectorI18n.class, value="creatingWorkspacesAllowedPropertyDescription") @Label(i18n=JpaConnectorI18n.class, value="creatingWorkspacesAllowedPropertyLabel") @Category(i18n=JpaConnectorI18n.class, value="creatingWorkspacesAllowedPropertyCategory") public boolean isCreatingWorkspacesAllowed()
set of workspaces
is fixedsetPredefinedWorkspaceNames(String[])
,
getPredefinedWorkspaceNames()
,
setCreatingWorkspacesAllowed(boolean)
public void setCreatingWorkspacesAllowed(boolean allowWorkspaceCreation)
allowWorkspaceCreation
- true if this source allows workspaces to be created by clients, or false if the
set of workspaces
is fixedsetPredefinedWorkspaceNames(String[])
,
getPredefinedWorkspaceNames()
,
isCreatingWorkspacesAllowed()
public String getDialect()
public void setDialect(String dialect)
dialect
- Sets dialect to the specified value.public String getDataSourceJndiName()
public void setDataSourceJndiName(String dataSourceJndiName)
dataSourceJndiName
- Sets dataSourceJndiName to the specified value.public String getDriverClassName()
public void setDriverClassName(String driverClassName)
driverClassName
- Sets driverClassName to the specified value.public String getDriverClassloaderName()
public void setDriverClassloaderName(String driverClassloaderName)
driverClassloaderName
- Sets driverClassloaderName to the specified value.public String getUsername()
public void setUsername(String username)
username
- Sets username to the specified value.public String getPassword()
public void setPassword(String password)
password
- Sets password to the specified value.public String getUrl()
public void setUrl(String url)
url
- Sets url to the specified value.public int getMaximumConnectionsInPool()
public void setMaximumConnectionsInPool(int maximumConnectionsInPool)
maximumConnectionsInPool
- Sets maximumConnectionsInPool to the specified value.public int getMinimumConnectionsInPool()
public void setMinimumConnectionsInPool(int minimumConnectionsInPool)
minimumConnectionsInPool
- Sets minimumConnectionsInPool to the specified value.public int getMaximumConnectionIdleTimeInSeconds()
public void setMaximumConnectionIdleTimeInSeconds(int maximumConnectionIdleTimeInSeconds)
maximumConnectionIdleTimeInSeconds
- Sets maximumConnectionIdleTimeInSeconds to the specified value.public int getMaximumSizeOfStatementCache()
public void setMaximumSizeOfStatementCache(int maximumSizeOfStatementCache)
maximumSizeOfStatementCache
- Sets maximumSizeOfStatementCache to the specified value.public int getNumberOfConnectionsToAcquireAsNeeded()
public void setNumberOfConnectionsToAcquireAsNeeded(int numberOfConnectionsToAcquireAsNeeded)
numberOfConnectionsToAcquireAsNeeded
- Sets numberOfConnectionsToAcquireAsNeeded to the specified value.public int getIdleTimeInSecondsBeforeTestingConnections()
public void setIdleTimeInSecondsBeforeTestingConnections(int idleTimeInSecondsBeforeTestingConnections)
idleTimeInSecondsBeforeTestingConnections
- Sets idleTimeInSecondsBeforeTestingConnections to the specified value.public String getModel()
public void setModel(String modelName)
modelName
- the name of the model that should be used for new stores, or null if the default should be usedpublic long getLargeValueSizeInBytes()
public void setLargeValueSizeInBytes(long largeValueSizeInBytes)
largeValueSizeInBytes
- Sets largeValueSizeInBytes to the specified value.public boolean isCompressData()
public void setCompressData(boolean compressData)
compressData
- Sets compressData to the specified value.public boolean isReferentialIntegrityEnforced()
public void setReferentialIntegrityEnforced(boolean referentialIntegrityEnforced)
referentialIntegrityEnforced
- Sets referentialIntegrityEnforced to the specified value.public Integer getIsolationLevel()
public void setIsolationLevel(Integer isolationLevel)
isolationLevel
- the value of the isolation level, or null if the isolation level is not set by this source (meaning
the data source's current setting or its default will be used)public void initialize(RepositoryContext context) throws RepositorySourceException
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.
initialize
in interface RepositorySource
RepositorySourceException
RepositorySource.initialize(org.modeshape.graph.connector.RepositoryContext)
public Reference getReference()
getReference
in interface Referenceable
Referenceable.getReference()
public RepositoryContext getRepositoryContext()
initialize(RepositoryContext)
.
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) throws Exception
getObjectInstance
in interface ObjectFactory
Exception
public RepositoryConnection getConnection() throws RepositorySourceException
getConnection
in interface RepositorySource
RepositorySourceException
- if there is a problem obtaining a connectionRepositorySource.getConnection()
public void close()
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.
close
in interface RepositorySource
RepositorySource.close()
protected String determineDialect(javax.persistence.EntityManager entityManager)
entityManager
- the EntityManager instance; may not be null
protected void configure(org.hibernate.ejb.Ejb3Configuration configuration)
This method sets up the C3P0 connection pooling, the cache provider, and some DDL options.
configuration
- the Hibernate configuration; never nullprotected void setProperty(org.hibernate.ejb.Ejb3Configuration configurator, String propertyName, String propertyValue)
protected void setProperty(org.hibernate.ejb.Ejb3Configuration configurator, String propertyName, int propertyValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |