Package org.eclipse.persistence.sessions
Class DatasourceLogin
- java.lang.Object
-
- org.eclipse.persistence.sessions.DatasourceLogin
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,CoreLogin<org.eclipse.persistence.internal.databaseaccess.Platform>,Login
- Direct Known Subclasses:
DatabaseLogin,EISLogin,XMLLogin
public abstract class DatasourceLogin extends java.lang.Object implements Login, java.io.Serializable, java.lang.Cloneable
Purpose: Hold the configuration information necessary to connect to a datasource.
Description: This is an abstract class that defines the common datasource independent connection configuration. It is extended to support specific datasources such as JDBC, JCA, XML, etc.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intcacheTransactionIsolationBy default concurrency is optimized and the cache is not locked during reads or writes, This allows for concurrent reading and writing and should never cause any problems.static intCONCURRENT_READ_WRITEReads and unit of work merges can occur concurrently.protected ConnectorconnectorProvide a little flexibility for connecting to a databaseprotected org.eclipse.persistence.internal.databaseaccess.PlatformplatformImplementation of platform-specific behaviors.protected java.util.PropertiespropertiesConnection properties (e.g. user, password, and driver-specific settings)static intSYNCHRONIZED_READ_ON_WRITEReads and unit of work merges will be serialized.static intSYNCHRONIZED_WRITEReads can occur concurrently but unit of work merges will be serialized.static intSYNCRONIZED_OBJECT_LEVEL_READ_WRITEWrites to the cache (merge, object build/refresh will be synchronized as will cache access (cloning) based on when access is required.static intSYNCRONIZED_OBJECT_LEVEL_READ_WRITE_DATABASEWrites to the cache (merge, object build/refresh will be synchronized as will cache access (cloning) based on database transaction.protected booleanusesExternalConnectionPoolingTrue if we use an external connection pool such as WebLogic's JTS driverprotected booleanusesExternalTransactionControllerTrue if we should use some external transaction service such as JTS.static java.lang.StringversionString
-
Constructor Summary
Constructors Constructor Description DatasourceLogin()PUBLIC: Create a new login.DatasourceLogin(org.eclipse.persistence.internal.databaseaccess.Platform databasePlatform)ADVANCED: Create a new login for the given platform.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSequence(Sequence sequence)Add sequence corresponding to the name Don't use if the session is connected.DatasourceLoginclone()INTERNAL: Clone the login.java.lang.ObjectconnectToDatasource(org.eclipse.persistence.internal.databaseaccess.Accessor accessor, Session session)INTERNAL: Connect to the datasource, and return the driver level connection object.voiddontUseExternalConnectionPooling()PUBLIC: Do not use external connection pooling.voiddontUseExternalTransactionController()PUBLIC: Let EclipseLink control transactions instead of some external transaction service such as JTS.intgetCacheTransactionIsolation()ADVANCED: By default concurrency is optimized and the cache is not locked more than required during reads or writes, This allows for virtual concurrent reading and writing and should never cause any problems.ConnectorgetConnector()ADVANCED: Return the connector that will instantiate the connection.org.eclipse.persistence.internal.databaseaccess.PlatformgetDatasourcePlatform()PUBLIC: Return the datasource platform specific information.SequencegetDefaultSequence()Get default sequenceSequencegetDefaultSequenceToWrite()INTERNAL: Used only for writing the login into XML or Java.java.lang.StringgetPassword()Return the password.DatabasePlatformgetPlatform()INTERNAL: Return the database platform specific information.java.lang.StringgetPlatformClassName()INTERNAL: Return the name of the database platform class.java.util.PropertiesgetProperties()INTERNAL: The properties are additional, driver-specific, connection information to be passed to the driver.java.lang.ObjectgetProperty(java.lang.String name)PUBLIC: The properties are additional, driver-specific, connection information to be passed to the driver.protected org.eclipse.persistence.internal.security.SecurableObjectHoldergetSecurableObjectHolder()INTERNAL: Return the encryption securable holder.SequencegetSequence(java.lang.String seqName)Get sequence corresponding to the namejava.util.MapgetSequences()Returns a map of sequence names to Sequences (may be null).java.util.MapgetSequencesToWrite()INTERNAL: Used only for writing the login into XML or Java.java.lang.StringgetTableQualifier()PUBLIC: Return the qualifier for the all of the tables referenced by EclipseLink.java.lang.StringgetUserName()PUBLIC: The user name is the database login name.static java.lang.StringgetVersion()PUBLIC: Return the EclipseLink version.booleanisConnectionHealthValidatedOnError()PUBLIC: This value defaults to false when not on a DatabaseLogin as the functionality has not been implemented for other datasource type.voidremoveAllSequences()Remove all sequences but the default one.voidremoveProperty(java.lang.String propertyName)PUBLIC: Some drivers don't like the "user" and "password" properties.SequenceremoveSequence(java.lang.String seqName)Remove sequence corresponding to name.voidsetCacheTransactionIsolation(int cacheTransactionIsolation)ADVANCED: By default concurrency is optimized and the cache is not locked more than required during reads or writes, This allows for virtual concurrent reading and writing and should never cause any problems.voidsetConnector(Connector connector)PUBLIC: Set the connector that will instantiate the connection.voidsetDatasourcePlatform(org.eclipse.persistence.internal.databaseaccess.Platform platform)PUBLIC: Set the database platform specific information.voidsetDefaultNullValue(java.lang.Class type, java.lang.Object value)PUBLIC: The default value to substitute for database NULLs can be configured on a per-class basis.voidsetDefaultSequence(Sequence sequence)Set default sequencevoidsetEncryptedPassword(java.lang.String password)Set the encrypted password.voidsetEncryptionClassName(java.lang.String encryptionClassName)Sets the encryption class namevoidsetPassword(java.lang.String password)Set the password.voidsetPlatform(org.eclipse.persistence.internal.databaseaccess.Platform platform)INTERNAL: Set the database platform specific information.voidsetPlatformClassName(java.lang.String platformClassName)INTERNAL: Set the name of the Platform to be used.voidsetPlatformClassName(java.lang.String platformClassName, java.lang.ClassLoader loader)INTERNAL: Set the name of the Platform to be created using the passed in class loader.voidsetProperties(java.util.Properties properties)PUBLIC: The properties are additional, driver-specific, connection information to be passed to the JDBC driver.voidsetProperty(java.lang.String propertyName, java.lang.Object propertyValue)PUBLIC: Some JDBC drivers require additional, driver-specific, properties.voidsetSequences(java.util.Map sequences)INTERNAL: Used only for reading the login from XML.voidsetTableQualifier(java.lang.String qualifier)PUBLIC: Set the default qualifier for all tables.voidsetTimestampQuery(ValueReadQuery timestampQuery)PUBLIC: Override the default query for returning a timestamp from the server.voidsetUserName(java.lang.String name)PUBLIC: The user name is the database login name.voidsetUsesExternalConnectionPooling(boolean usesExternalConnectionPooling)PUBLIC: Return whether EclipseLink uses some external connection pooling service such as a JDBC 2.0 driver.voidsetUsesExternalTransactionController(boolean usesExternalTransactionController)PUBLIC: Return whether EclipseLink uses some external transaction service such as JTS.booleanshouldAllowConcurrentReadWrite()INTERNAL: Used for cache isolation.booleanshouldSynchronizedReadOnWrite()INTERNAL: Used for cache isolation.booleanshouldSynchronizeObjectLevelReadWrite()INTERNAL: Used for Cache Isolation.booleanshouldSynchronizeObjectLevelReadWriteDatabase()INTERNAL: Used for Cache Isolation.booleanshouldSynchronizeWrites()INTERNAL: Used for Cache Isolation.booleanshouldUseExternalConnectionPooling()PUBLIC: Return whether EclipseLink uses some external connection pooling (e.g.booleanshouldUseExternalTransactionController()PUBLIC: Return whether EclipseLink uses some external transaction service such as JTS.java.lang.StringtoString()PUBLIC: Print all of the connection information.voiduseExternalConnectionPooling()PUBLIC: Use external connection pooling.voiduseExternalTransactionController()PUBLIC: Use an external transaction controller such as a JTS servicevoidusePlatform(org.eclipse.persistence.internal.databaseaccess.Platform platform)ADVANCED: Set the database platform to be custom platform.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.sessions.Login
buildAccessor
-
-
-
-
Field Detail
-
versionString
public static java.lang.String versionString
-
properties
protected java.util.Properties properties
Connection properties (e.g. user, password, and driver-specific settings)
-
platform
protected org.eclipse.persistence.internal.databaseaccess.Platform platform
Implementation of platform-specific behaviors.
-
connector
protected Connector connector
Provide a little flexibility for connecting to a database
-
usesExternalConnectionPooling
protected boolean usesExternalConnectionPooling
True if we use an external connection pool such as WebLogic's JTS driver
-
usesExternalTransactionController
protected boolean usesExternalTransactionController
True if we should use some external transaction service such as JTS.
-
cacheTransactionIsolation
protected int cacheTransactionIsolation
By default concurrency is optimized and the cache is not locked during reads or writes, This allows for concurrent reading and writing and should never cause any problems. If the application uses no form of locking the last unit of work to merge changes will win, with no locking it is possible only under this scenario for two unit of works to merge changes different than the database although highly unlikely and if occurred is the entire purpose of locking. This property allows for the isolation level of changes to the cache to be configured for sever situation and it is not suggest that this be changed.
-
CONCURRENT_READ_WRITE
public static final int CONCURRENT_READ_WRITE
Reads and unit of work merges can occur concurrently.- See Also:
- Constant Field Values
-
SYNCHRONIZED_WRITE
public static final int SYNCHRONIZED_WRITE
Reads can occur concurrently but unit of work merges will be serialized.- See Also:
- Constant Field Values
-
SYNCHRONIZED_READ_ON_WRITE
public static final int SYNCHRONIZED_READ_ON_WRITE
Reads and unit of work merges will be serialized.- See Also:
- Constant Field Values
-
SYNCRONIZED_OBJECT_LEVEL_READ_WRITE
public static final int SYNCRONIZED_OBJECT_LEVEL_READ_WRITE
Writes to the cache (merge, object build/refresh will be synchronized as will cache access (cloning) based on when access is required.- See Also:
- Constant Field Values
-
SYNCRONIZED_OBJECT_LEVEL_READ_WRITE_DATABASE
public static final int SYNCRONIZED_OBJECT_LEVEL_READ_WRITE_DATABASE
Writes to the cache (merge, object build/refresh will be synchronized as will cache access (cloning) based on database transaction.- See Also:
- Constant Field Values
-
-
Method Detail
-
getSecurableObjectHolder
protected org.eclipse.persistence.internal.security.SecurableObjectHolder getSecurableObjectHolder()
INTERNAL: Return the encryption securable holder. Lazy initialize to handle serialization.
-
clone
public DatasourceLogin clone()
INTERNAL: Clone the login. This also clones the platform as it is internal to the login.
-
connectToDatasource
public java.lang.Object connectToDatasource(org.eclipse.persistence.internal.databaseaccess.Accessor accessor, Session session) throws DatabaseExceptionINTERNAL: Connect to the datasource, and return the driver level connection object.- Specified by:
connectToDatasourcein interfaceLogin- Throws:
DatabaseException
-
getCacheTransactionIsolation
public int getCacheTransactionIsolation()
ADVANCED: By default concurrency is optimized and the cache is not locked more than required during reads or writes, This allows for virtual concurrent reading and writing and should never cause any problems. If the application uses no form of locking the last unit of work to merge changes will win, with no locking it is possible only under this scenario for two unit of works to merge changes different than the database although highly unlikely and if occurred is the entire purpose of locking and locking is the suggested solution if this is a problem. This property allows for the isolation level of changes to the cache to be configured for sever situations and it is not suggest that this be changed.Setting are:
- ConcurrentReadWrite - default
- SynchronizedWrite - only allow a single writer (i.e. unit of work merge) to the cache at once
- SynchronizedReadOnWrite - do not allow reading or other unit of work merge while a unit of work is in merge
-
getConnector
public Connector getConnector()
ADVANCED: Return the connector that will instantiate the connection.
-
getPlatform
public DatabasePlatform getPlatform()
INTERNAL: Return the database platform specific information. This allows EclipseLink to configure certain advanced features for the database desired. NOTE: this must only be used for relational specific usage and will not work for non-relational datasources.- Specified by:
getPlatformin interfaceLogin
-
getDatasourcePlatform
public org.eclipse.persistence.internal.databaseaccess.Platform getDatasourcePlatform()
PUBLIC: Return the datasource platform specific information. This allows EclipseLink to configure certain advanced features for the datasource desired.- Specified by:
getDatasourcePlatformin interfaceCoreLogin<org.eclipse.persistence.internal.databaseaccess.Platform>- Specified by:
getDatasourcePlatformin interfaceLogin
-
getProperties
public java.util.Properties getProperties()
INTERNAL: The properties are additional, driver-specific, connection information to be passed to the driver.NOTE: Do not set the password directly by getting the properties and setting the "password" property directly. Use the method DatabaseLogin.setPassword(String).
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
PUBLIC: The properties are additional, driver-specific, connection information to be passed to the driver.NOTE: Do not set the password directly by getting the properties and setting the "password" property directly. Use the method DatabaseLogin.setPassword(String).
- Specified by:
getPropertyin interfaceLogin
-
getTableQualifier
public java.lang.String getTableQualifier()
PUBLIC: Return the qualifier for the all of the tables referenced by EclipseLink. This can be the creator of the table or database name the table exists on. This is required by some databases such as Oracle and DB2. This should only be used if all of the tables have the same qualifier. It can also be set on each descriptor when the table name is specified.- Specified by:
getTableQualifierin interfaceLogin
-
getUserName
public java.lang.String getUserName()
PUBLIC: The user name is the database login name. Some databases do not require a user name or the user is obtained from the OS, in this case the user name not be specified.- Specified by:
getUserNamein interfaceLogin
-
isConnectionHealthValidatedOnError
public boolean isConnectionHealthValidatedOnError()
PUBLIC: This value defaults to false when not on a DatabaseLogin as the functionality has not been implemented for other datasource type. On an SQL Exception EclipseLink will ping the database to determine if the connection used can continue to be used for queries. This should have no impact on applications unless the user is using pessimistic locking queries with 'no wait' or are using a query timeout feature. If that is the case and the application is experiencing a performance impact from the health check then this feature can be turned off. Turning this feature off will prevent EclipseLink from being able to retry queries in the case of database failure.- Specified by:
isConnectionHealthValidatedOnErrorin interfaceLogin
-
getVersion
public static java.lang.String getVersion()
PUBLIC: Return the EclipseLink version.- Returns:
- version of EclipseLink
-
removeProperty
public void removeProperty(java.lang.String propertyName)
PUBLIC: Some drivers don't like the "user" and "password" properties. They can be removed with this method, or by using setUserName(null) / setPassword(null)
-
setCacheTransactionIsolation
public void setCacheTransactionIsolation(int cacheTransactionIsolation)
ADVANCED: By default concurrency is optimized and the cache is not locked more than required during reads or writes, This allows for virtual concurrent reading and writing and should never cause any problems. If the application uses no form of locking the last unit of work to merge changes will win, with no locking it is possible only under this scenario for two unit of works to merge changes different than the database although highly unlikely and if occurred is the entire purpose of locking and locking is the suggested solution if this is a problem. This property allows for the isolation level of changes to the cache to be configured for sever situations and it is not suggest that this be changed.Setting are:
- ConcurrentReadWrite - default
- SynchronizedWrite - only allow a single writer (i.e. unit of work merge) to the cache at once
- SynchronizedReadOnWrite - do not allow reading or other unit of work merge while a unit of work is in merge
-
setConnector
public void setConnector(Connector connector)
PUBLIC: Set the connector that will instantiate the connection. As an example, to use a JNDI-suppliedDataSource, use code something like the following:
where thesession.getLogin().setConnector(new JNDIConnector(context, dataSourceName));
session.login();contextis an instance of ajavax.naming.Contextand thedataSourceNamerefers to the name of theDataSourcewithin the context.
-
setDefaultNullValue
public void setDefaultNullValue(java.lang.Class type, java.lang.Object value)PUBLIC: The default value to substitute for database NULLs can be configured on a per-class basis. Example: login.setDefaultNullValue(long.class, Long.valueOf(0))
-
setPassword
public void setPassword(java.lang.String password)
Set the password.- Specified by:
setPasswordin interfaceLogin
-
getPassword
public java.lang.String getPassword()
Return the password. It will be encrypted.- Specified by:
getPasswordin interfaceLogin
-
setEncryptedPassword
public void setEncryptedPassword(java.lang.String password)
Set the encrypted password.
-
setEncryptionClassName
public void setEncryptionClassName(java.lang.String encryptionClassName)
Sets the encryption class name
-
setPlatform
public void setPlatform(org.eclipse.persistence.internal.databaseaccess.Platform platform)
INTERNAL: Set the database platform specific information. This allows EclipseLink to configure certain advanced features for the database desired.- Specified by:
setPlatformin interfaceLogin
-
setDatasourcePlatform
public void setDatasourcePlatform(org.eclipse.persistence.internal.databaseaccess.Platform platform)
PUBLIC: Set the database platform specific information. This allows EclipseLink to configure certain advanced features for the database desired.- Specified by:
setDatasourcePlatformin interfaceLogin
-
getPlatformClassName
public java.lang.String getPlatformClassName()
INTERNAL: Return the name of the database platform class.
-
setPlatformClassName
public void setPlatformClassName(java.lang.String platformClassName) throws ValidationExceptionINTERNAL: Set the name of the Platform to be used. Creates a new instance of the specified Class.- Throws:
ValidationException
-
setPlatformClassName
public void setPlatformClassName(java.lang.String platformClassName, java.lang.ClassLoader loader) throws ValidationExceptionINTERNAL: Set the name of the Platform to be created using the passed in class loader. If no class loader is passed in, of if an exception is thrown, call the setPlatformClassName method with no classloader.- Throws:
ValidationException- See Also:
setPlatformClassName(String platformClassName)
-
usePlatform
public void usePlatform(org.eclipse.persistence.internal.databaseaccess.Platform platform)
ADVANCED: Set the database platform to be custom platform.
-
setProperties
public void setProperties(java.util.Properties properties)
PUBLIC: The properties are additional, driver-specific, connection information to be passed to the JDBC driver.- Specified by:
setPropertiesin interfaceLogin
-
setProperty
public void setProperty(java.lang.String propertyName, java.lang.Object propertyValue)PUBLIC: Some JDBC drivers require additional, driver-specific, properties. Add the specified property to those to be passed to the JDBC driver.- Specified by:
setPropertyin interfaceLogin
-
setTableQualifier
public void setTableQualifier(java.lang.String qualifier)
PUBLIC: Set the default qualifier for all tables. This can be the creator of the table or database name the table exists on. This is required by some databases such as Oracle and DB2.
-
setTimestampQuery
public void setTimestampQuery(ValueReadQuery timestampQuery)
PUBLIC: Override the default query for returning a timestamp from the server.
-
setUserName
public void setUserName(java.lang.String name)
PUBLIC: The user name is the database login name. Some databases do not require a user name or the user is obtained from the OS, in this case this should not be specified.- Specified by:
setUserNamein interfaceLogin
-
setUsesExternalConnectionPooling
public void setUsesExternalConnectionPooling(boolean usesExternalConnectionPooling)
PUBLIC: Return whether EclipseLink uses some external connection pooling service such as a JDBC 2.0 driver.
-
setUsesExternalTransactionController
public void setUsesExternalTransactionController(boolean usesExternalTransactionController)
PUBLIC: Return whether EclipseLink uses some external transaction service such as JTS.
-
dontUseExternalConnectionPooling
public void dontUseExternalConnectionPooling()
PUBLIC: Do not use external connection pooling. This is appropriate if using regular EclipseLink connection pooling and regular JDBC drivers.- See Also:
useExternalConnectionPooling()
-
dontUseExternalTransactionController
public void dontUseExternalTransactionController()
PUBLIC: Let EclipseLink control transactions instead of some external transaction service such as JTS.- See Also:
useExternalTransactionController()
-
shouldAllowConcurrentReadWrite
public boolean shouldAllowConcurrentReadWrite()
INTERNAL: Used for cache isolation.- Specified by:
shouldAllowConcurrentReadWritein interfaceLogin
-
shouldSynchronizedReadOnWrite
public boolean shouldSynchronizedReadOnWrite()
INTERNAL: Used for cache isolation.- Specified by:
shouldSynchronizedReadOnWritein interfaceLogin
-
shouldSynchronizeWrites
public boolean shouldSynchronizeWrites()
INTERNAL: Used for Cache Isolation. Causes EclipseLink to lock at the class level on cache updates.- Specified by:
shouldSynchronizeWritesin interfaceLogin
-
shouldSynchronizeObjectLevelReadWrite
public boolean shouldSynchronizeObjectLevelReadWrite()
INTERNAL: Used for Cache Isolation. Causes EclipseLink to lock at the object level on cache updates and cache access.- Specified by:
shouldSynchronizeObjectLevelReadWritein interfaceLogin
-
shouldSynchronizeObjectLevelReadWriteDatabase
public boolean shouldSynchronizeObjectLevelReadWriteDatabase()
INTERNAL: Used for Cache Isolation. Causes EclipseLink to lock at the object level on cache updates and cache access, based on database transaction.- Specified by:
shouldSynchronizeObjectLevelReadWriteDatabasein interfaceLogin
-
shouldUseExternalConnectionPooling
public boolean shouldUseExternalConnectionPooling()
PUBLIC: Return whether EclipseLink uses some external connection pooling (e.g. WebLogic's JTS driver).- Specified by:
shouldUseExternalConnectionPoolingin interfaceLogin- See Also:
useExternalConnectionPooling(),dontUseExternalConnectionPooling()
-
shouldUseExternalTransactionController
public boolean shouldUseExternalTransactionController()
PUBLIC: Return whether EclipseLink uses some external transaction service such as JTS.- Specified by:
shouldUseExternalTransactionControllerin interfaceLogin- See Also:
useExternalTransactionController(),dontUseExternalTransactionController()
-
useExternalConnectionPooling
public void useExternalConnectionPooling()
PUBLIC: Use external connection pooling.
-
useExternalTransactionController
public void useExternalTransactionController()
PUBLIC: Use an external transaction controller such as a JTS service
-
toString
public java.lang.String toString()
PUBLIC: Print all of the connection information.- Overrides:
toStringin classjava.lang.Object
-
getDefaultSequence
public Sequence getDefaultSequence()
Get default sequence
-
setDefaultSequence
public void setDefaultSequence(Sequence sequence)
Set default sequence
-
addSequence
public void addSequence(Sequence sequence)
Add sequence corresponding to the name Don't use if the session is connected.
-
getSequence
public Sequence getSequence(java.lang.String seqName)
Get sequence corresponding to the name
-
getSequences
public java.util.Map getSequences()
Returns a map of sequence names to Sequences (may be null).
-
removeSequence
public Sequence removeSequence(java.lang.String seqName)
Remove sequence corresponding to name. Doesn't remove default sequence. Don't use if the session is connected.
-
removeAllSequences
public void removeAllSequences()
Remove all sequences but the default one.
-
getDefaultSequenceToWrite
public Sequence getDefaultSequenceToWrite()
INTERNAL: Used only for writing the login into XML or Java.
-
getSequencesToWrite
public java.util.Map getSequencesToWrite()
INTERNAL: Used only for writing the login into XML or Java.
-
setSequences
public void setSequences(java.util.Map sequences)
INTERNAL: Used only for reading the login from XML.
-
-