Methods Summary |
---|
public void | addSequence(oracle.toplink.essentials.sequencing.Sequence sequence)Add sequence corresponding to the name
getDatasourcePlatform().addSequence(sequence);
|
public java.lang.Object | clone()INTERNAL:
Clone the login.
This also clones the platform as it is internal to the login.
DatasourceLogin clone = null;
try {
clone = (DatasourceLogin)super.clone();
} catch (Exception exception) {
// should not happen...do nothing
}
if (getConnector() != null) {
clone.setConnector((Connector)getConnector().clone());
}
clone.setDatasourcePlatform((Platform)getDatasourcePlatform().clone());
clone.setProperties((Properties)properties.clone());
return clone;
|
public java.lang.Object | connectToDatasource(oracle.toplink.essentials.internal.databaseaccess.Accessor accessor)INTERNAL:
Connect to the datasource, and return the driver level connection object.
return getConnector().connect(prepareProperties(properties));
|
public void | dontUseExternalConnectionPooling()PUBLIC:
Do not use external connection pooling. This is appropriate if using regular
TopLink connection pooling and regular JDBC drivers.
setUsesExternalConnectionPooling(false);
|
public void | dontUseExternalTransactionController()PUBLIC:
Let TopLink control transactions instead of some external transaction
service such as JTS.
setUsesExternalTransactionController(false);
|
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 senerio for two unit of works to merge changes different than the database although highly unlikely
and if occured 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: |
public oracle.toplink.essentials.sessions.Connector | getConnector()ADVANCED:
Return the connector that will instantiate the connection.
return connector;
|
public oracle.toplink.essentials.internal.databaseaccess.Platform | getDatasourcePlatform()PUBLIC:
Return the datasource platform specific information.
This allows TopLink to configure certain advanced features for the datasource desired.
return platform;
|
public oracle.toplink.essentials.sequencing.Sequence | getDefaultSequence()Get default sequence
return getDatasourcePlatform().getDefaultSequence();
|
public oracle.toplink.essentials.sequencing.Sequence | getDefaultSequenceToWrite()INTERNAL:
Used only for writing the login into XML or Java.
return getDatasourcePlatform().getDefaultSequenceToWrite();
|
public java.lang.String | getPassword()Return the password. It will be encrypted.
return properties.getProperty("password");
|
public oracle.toplink.essentials.internal.databaseaccess.DatabasePlatform | getPlatform()INTERNAL:
Return the database platform specific information.
This allows TopLink 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.
try {
return (DatabasePlatform)getDatasourcePlatform();
} catch (ClassCastException wrongType) {
throw ValidationException.notSupportedForDatasource();
}
|
public java.lang.String | getPlatformClassName()INTERNAL:
Return the name of the database platform class.
return getDatasourcePlatform().getClass().getName();
|
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).
return properties;
|
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).
return getProperties().get(name);
|
protected oracle.toplink.essentials.internal.security.SecurableObjectHolder | getSecurableObjectHolder()INTERNAL:
Return the encryption securable holder.
Lazy initialize to handle serialization.
if (securableObjectHolder == null) {
securableObjectHolder = new SecurableObjectHolder();
securableObjectHolder.getSecurableObject();
}
return securableObjectHolder;
|
public oracle.toplink.essentials.sequencing.Sequence | getSequence(java.lang.String seqName)Get sequence corresponding to the name
return getDatasourcePlatform().getSequence(seqName);
|
public java.util.Map | getSequences()Returns a map of sequence names to Sequences (may be null).
return getDatasourcePlatform().getSequences();
|
public java.util.Map | getSequencesToWrite()INTERNAL:
Used only for writing the login into XML or Java.
return getDatasourcePlatform().getSequencesToWrite();
|
public java.lang.String | getTableQualifier()PUBLIC:
Return the qualifier for the all of the tables referenced by TopLink.
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.
return getDatasourcePlatform().getTableQualifier();
|
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.
return properties.getProperty("user");
|
public static java.lang.String | getVersion()PUBLIC:
Return the TopLink version.
if (versionString == null) {
Object[] args = { Version.getProduct(), Version.getVersion(), Version.getBuildNumber() };
versionString = MessageFormat.format(versionStringTemplate, args);
}
return versionString;
|
private java.util.Properties | prepareProperties(java.util.Properties properties)SECURE:
The password in the login properties is encrypted. Return a clone
of the properties with the password decrypted.
Properties result = (Properties)properties.clone();
String password = result.getProperty("password");
if (password != null) {
// Fix for bug # 2700529
// The securable object is initialized on first call of
// getSecurableObject. When setting an encrypted password
// we don't make this call since it is already encrypted, hence,
// we do not initialize the securable object on the holder.
//
// If neither setPassword or setEncryptedPassword is called
// (example, user sets properties via the setProperties method),
// when the user tries to connect they will get a null pointer
// exception. So if the holder does not hold
// a securable object or the setEncryptedPassword flag is not true,
// don't bother trying to decrypt.
if (getSecurableObjectHolder().hasSecurableObject() || isEncryptedPasswordSet) {
result.put("password", getSecurableObjectHolder().getSecurableObject().decryptPassword(password));
}
}
return result;
|
public void | removeAllSequences()Remove all sequences but the default one.
getDatasourcePlatform().removeAllSequences();
|
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.
properties.remove(propertyName);
|
public oracle.toplink.essentials.sequencing.Sequence | removeSequence(java.lang.String seqName)Remove sequence corresponding to name.
Doesn't remove default sequence.
return getDatasourcePlatform().removeSequence(seqName);
|
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 senerio for two unit of works to merge changes different than the database although highly unlikely
and if occured 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: |
public void | setConnector(oracle.toplink.essentials.sessions.Connector connector)PUBLIC:
Set the connector that will instantiate the connection.
As an example, to use a JNDI-supplied DataSource , use code
something like the following:
session.getLogin().setConnector(new JNDIConnector(context, dataSourceName));
session.login();
where the context is an instance of a javax.naming.Context and
the dataSourceName refers to the name of the DataSource
within the context.
this.connector = connector;
|
public void | setDatasourcePlatform(oracle.toplink.essentials.internal.databaseaccess.Platform platform)PUBLIC:
Set the database platform specific information.
This allows TopLink to configure certain advanced features for the database desired.
this.platform = platform;
|
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, new Long(0))
getDatasourcePlatform().getConversionManager().setDefaultNullValue(type, value);
|
public void | setDefaultSequence(oracle.toplink.essentials.sequencing.Sequence sequence)Set default sequence
getDatasourcePlatform().setDefaultSequence(sequence);
|
public void | setEncryptedPassword(java.lang.String password)Set the encrypted password.
// remember that we set an encrypted password
// flag will be needed in prepareProperties.
isEncryptedPasswordSet = true;
if (password != null) {
setProperty("password", password);
} else {// is null so remove the property
removeProperty("password");
}
|
public void | setEncryptionClassName(java.lang.String encryptionClassName)Sets the encryption class name
getSecurableObjectHolder().setEncryptionClassName(encryptionClassName);
|
public void | setPassword(java.lang.String password)Set the password.
if (password != null) {
// first call to get will initialize the securable object
setProperty("password", getSecurableObjectHolder().getSecurableObject().encryptPassword(password));
} else {
// is null so remove the property
removeProperty("password");
}
|
public void | setPlatform(oracle.toplink.essentials.internal.databaseaccess.Platform platform)INTERNAL:
Set the database platform specific information.
This allows TopLink to configure certain advanced features for the database desired.
setDatasourcePlatform(platform);
|
public void | setPlatformClassName(java.lang.String platformClassName)INTERNAL:
Set the name of the Platform to be used.
Creates a new instance of the specified Class.
Class platformClass = null;
try {
//First try loading with the Login's class loader
platformClass = this.getClass().getClassLoader().loadClass(platformClassName);
Platform platform = null;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
platform = (Platform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(platformClass));
} catch (PrivilegedActionException exception) {
throw exception.getException();
}
} else {
platform = (Platform)PrivilegedAccessHelper.newInstanceFromClass(platformClass);
}
usePlatform(platform);
} catch(Exception cne) {
//next try using ConversionManager
try {
platformClass = ConversionManager.loadClass(platformClassName);
Platform platform = null;
if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
try {
platform = (Platform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(platformClass));
} catch (PrivilegedActionException exception) {
throw ValidationException.platformClassNotFound(exception.getException(), platformClassName);
}
} else {
platform = (Platform)PrivilegedAccessHelper.newInstanceFromClass(platformClass);
}
usePlatform(platform);
} catch(Exception cne2) {
//if still not found, throw exception
throw ValidationException.platformClassNotFound(cne2, platformClassName);
}
}
|
public void | setProperties(java.util.Properties properties)PUBLIC:
The properties are additional, driver-specific, connection information
to be passed to the JDBC driver.
this.properties = properties;
|
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.
properties.put(propertyName, propertyValue);
|
public void | setSequences(java.util.Map sequences)INTERNAL:
Used only for reading the login from XML.
getDatasourcePlatform().setSequences(sequences);
|
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.
getDatasourcePlatform().setTableQualifier(qualifier);
|
public void | setTimestampQuery(oracle.toplink.essentials.queryframework.ValueReadQuery timestampQuery)PUBLIC:
Override the default query for returning a timestamp from the server.
getDatasourcePlatform().setTimestampQuery(timestampQuery);
|
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.
if (name != null) {
setProperty("user", name);
}
|
public void | setUsesExternalConnectionPooling(boolean usesExternalConnectionPooling)PUBLIC:
Return whether TopLink uses some external connection pooling service such as a JDBC 2.0 driver.
this.usesExternalConnectionPooling = usesExternalConnectionPooling;
|
public void | setUsesExternalTransactionController(boolean usesExternalTransactionController)PUBLIC:
Return whether TopLink uses some external transaction service such as JTS.
this.usesExternalTransactionController = usesExternalTransactionController;
|
public boolean | shouldAllowConcurrentReadWrite()INTERNAL:
Used for cache isolation.
return getCacheTransactionIsolation() == CONCURRENT_READ_WRITE;
|
public boolean | shouldSynchronizeObjectLevelReadWrite()INTERNAL:
Used for Cache Isolation. Causes TopLink to lock at the object level on
cache updates and cache access.
return getCacheTransactionIsolation() == SYNCRONIZED_OBJECT_LEVEL_READ_WRITE;
|
public boolean | shouldSynchronizeObjectLevelReadWriteDatabase()INTERNAL:
Used for Cache Isolation. Causes TopLink to lock at the object level on
cache updates and cache access, based on database transaction.
return getCacheTransactionIsolation() == SYNCRONIZED_OBJECT_LEVEL_READ_WRITE_DATABASE;
|
public boolean | shouldSynchronizeWrites()INTERNAL:
Used for Cache Isolation. Causes TopLink to lock at the class level on
cache updates.
return getCacheTransactionIsolation() == SYNCHRONIZED_WRITE;
|
public boolean | shouldSynchronizedReadOnWrite()INTERNAL:
Used for cache isolation.
return getCacheTransactionIsolation() == SYNCHRONIZED_READ_ON_WRITE;
|
public boolean | shouldUseExternalConnectionPooling()PUBLIC:
Return whether TopLink uses some external connection pooling
(e.g. WebLogic's JTS driver).
return usesExternalConnectionPooling;
|
public boolean | shouldUseExternalTransactionController()PUBLIC:
Return whether TopLink uses some external transaction service such as JTS.
return usesExternalTransactionController;
|
public java.lang.String | toString()PUBLIC:
Print all of the connection information.
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
writer.write(Helper.getShortClassName(getClass()));
writer.println("(");
writer.println("\t" + ToStringLocalization.buildMessage("platform", (Object[])null) + "=> " + getDatasourcePlatform());
if (!shouldUseExternalConnectionPooling()) {
writer.println("\t" + ToStringLocalization.buildMessage("user_name", (Object[])null) + "=> \"" + getUserName() + "\"");
}
writer.print("\t");
getConnector().toString(writer);
writer.write(")");
return stringWriter.toString();
|
public void | useExternalConnectionPooling()PUBLIC:
Use external connection pooling.
setUsesExternalConnectionPooling(true);
|
public void | useExternalTransactionController()PUBLIC:
Use an external transaction controller such as a JTS service
setUsesExternalTransactionController(true);
|
public void | usePlatform(oracle.toplink.essentials.internal.databaseaccess.Platform platform)ADVANCED:
Set the database platform to be custom platform.
if (getDatasourcePlatform() != null) {
getDatasourcePlatform().copyInto(platform);
}
setPlatform(platform);
|