Methods Summary |
---|
protected void | computeStatementWrappingStatus()9.1 has attribute "wrap-statements" which will be overriden
when JVM option is specified as "true" or "false"
JVM Option will be deprecated in future versions.
boolean poolProperty = false;
String statementWrappingString = getStatementWrapping();
if (statementWrappingString != null)
poolProperty = Boolean.valueOf(statementWrappingString);
if (wrapStatement == JVM_OPTION_STATEMENT_WRAPPING_ON ||
(wrapStatement == JVM_OPTION_STATEMENT_WRAPPING_NOT_SET && poolProperty)) {
statementWrapping = true;
} else {
statementWrapping = false;
}
|
protected ManagedConnection | constructManagedConnection(javax.sql.PooledConnection pc, java.sql.Connection sqlCon, javax.resource.spi.security.PasswordCredential passCred, com.sun.gjc.spi.ManagedConnectionFactory mcf)
return new com.sun.gjc.spi.ManagedConnection(pc, sqlCon, passCred, mcf);
|
public java.lang.Object | createConnectionFactory()Creates a Connection Factory instance. The ConnectionManager implementation
of the resource adapter is used here.
if (logWriter != null) {
logWriter.println("In createConnectionFactory()");
}
return jdbcObjectsFactory.getDataSourceInstance(this, null);
|
public java.lang.Object | createConnectionFactory(javax.resource.spi.ConnectionManager cxManager)Creates a Connection Factory instance. The ConnectionManager implementation
of the application server is used here.
if (logWriter != null) {
logWriter.println("In createConnectionFactory(javax.resource.spi.ConnectionManager cxManager)");
}
javax.sql.DataSource cf = jdbcObjectsFactory.getDataSourceInstance(this, cxManager);
if (cxManager instanceof javax.resource.spi.LazyEnlistableConnectionManager) {
cm_ = (javax.resource.spi.LazyEnlistableConnectionManager) cxManager;
isLazyCm_ = true;
}
return cf;
|
public abstract javax.resource.spi.ManagedConnection | createManagedConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)Creates a new physical connection to the underlying EIS resource
manager.
|
public abstract boolean | equals(java.lang.Object other)Check if this ManagedConnectionFactory is equal to
another ManagedConnectionFactory .
|
public java.lang.String | getClassName()Gets the class name of the data source
return spec.getDetail(DataSourceSpec.CLASSNAME);
|
public java.lang.String | getConnectionValidationRequired()Returns if connection validation is required or not
return spec.getDetail(DataSourceSpec.CONNECTIONVALIDATIONREQUIRED);
|
public java.lang.Object | getDataSource()Returns the underlying datasource
if (dsObjBuilder == null) {
dsObjBuilder = new DataSourceObjectBuilder(spec);
}
return dsObjBuilder.constructDataSourceObject();
|
public java.lang.String | getDataSourceName()Gets the data source name.
return spec.getDetail(DataSourceSpec.DATASOURCENAME);
|
public java.lang.String | getDatabaseName()Gets the database name.
return spec.getDetail(DataSourceSpec.DATABASENAME);
|
public java.lang.String | getDelimiter()Gets the delimiter.
return spec.getDetail(DataSourceSpec.DELIMITER);
|
public java.lang.String | getDescription()Gets the description.
return spec.getDetail(DataSourceSpec.DESCRIPTION);
|
public java.lang.String | getDriverProperties()Gets the driver specific properties.
return spec.getDetail(DataSourceSpec.DRIVERPROPERTIES);
|
public java.lang.String | getGuaranteeIsolationLevel()Returns the transaction isolation level
return spec.getDetail(DataSourceSpec.GUARANTEEISOLATIONLEVEL);
|
public java.util.Set | getInvalidConnections(java.util.Set connectionSet)This method returns a set of invalid ManagedConnection
objects chosen from a specified set of ManagedConnection
objects.
Iterator iter = connectionSet.iterator();
Set invalid = new HashSet();
while (iter.hasNext()) {
ManagedConnection mc = (ManagedConnection) iter.next();
try {
isValid(mc);
} catch (ResourceException re) {
invalid.add(mc);
mc.connectionErrorOccurred(re, null);
if(_logger.isLoggable(Level.FINE)){
_logger.log(Level.FINE, "jdbc.invalid_connection", re);
}
}
}
return invalid;
|
public java.lang.String | getJdbc30DataSource()
return spec.getDetail(DataSourceSpec.JDBC30DATASOURCE);
|
public JdbcObjectsFactory | getJdbcObjectsFactory()
return jdbcObjectsFactory;
|
public java.io.PrintWriter | getLogWriter()Get the log writer for this ManagedConnectionFactory instance.
return logWriter;
|
public java.lang.String | getLoginTimeOut()Gets the login timeout.
return spec.getDetail(DataSourceSpec.LOGINTIMEOUT);
|
public java.lang.String | getNetworkProtocol()Gets the network protocol.
return spec.getDetail(DataSourceSpec.NETWORKPROTOCOL);
|
public java.lang.String | getPassword()Gets the password
return spec.getDetail(DataSourceSpec.PASSWORD);
|
public java.lang.String | getPortNumber()Gets the port number.
return spec.getDetail(DataSourceSpec.PORTNUMBER);
|
public javax.resource.spi.ResourceAdapter | getResourceAdapter()Get the ResourceAdapter for this ManagedConnectionFactory instance.
if (logWriter != null) {
logWriter.println("In getResourceAdapter");
}
return ra;
|
public java.lang.String | getRoleName()Gets the role name.
return spec.getDetail(DataSourceSpec.ROLENAME);
|
public java.lang.String | getServerName()Gets the server name.
return spec.getDetail(DataSourceSpec.SERVERNAME);
|
public java.lang.String | getStatementTimeout()Gets the StatementTimeout value
return spec.getDetail(DataSourceSpec.STATEMENTTIMEOUT);
|
public java.lang.String | getStatementWrapping()Gets the statement wrapping value
return spec.getDetail(DataSourceSpec.STATEMENTWRAPPING);
|
private static int | getStatementWrappingJVMOption()Gets the Statement Wrapping JVM Option (available in 8.2)
Which will be deprecated in future versions.
wrapStatement = getStatementWrappingJVMOption();
int result = JVM_OPTION_STATEMENT_WRAPPING_NOT_SET;
String str = System.getProperty(
"com.sun.appserv.jdbc.wrapJdbcObjects");
if ("true".equalsIgnoreCase(str)) {
result = JVM_OPTION_STATEMENT_WRAPPING_ON;
} else if ("false".equalsIgnoreCase(str)) {
result = JVM_OPTION_STATEMENT_WRAPPING_OFF;
}
return result;
|
public java.lang.String | getTransactionIsolation()Returns the transaction isolation level
return spec.getDetail(DataSourceSpec.TRANSACTIONISOLATION);
|
private int | getTransactionIsolationInt(java.lang.String tranIsolation)Gets the integer equivalent of the string specifying
the transaction isolation.
if (tranIsolation.equalsIgnoreCase("read-uncommitted")) {
return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
} else if (tranIsolation.equalsIgnoreCase("read-committed")) {
return java.sql.Connection.TRANSACTION_READ_COMMITTED;
} else if (tranIsolation.equalsIgnoreCase("repeatable-read")) {
return java.sql.Connection.TRANSACTION_REPEATABLE_READ;
} else if (tranIsolation.equalsIgnoreCase("serializable")) {
return java.sql.Connection.TRANSACTION_SERIALIZABLE;
} else {
throw new ResourceException("Invalid transaction isolation; the transaction "
+ "isolation level can be empty or any of the following: "
+ "read-uncommitted, read-committed, repeatable-read, serializable");
}
|
public java.lang.String | getUser()Gets the user name
return spec.getDetail(DataSourceSpec.USERNAME);
|
public java.lang.String | getValidationMethod()Returns the connection validation method type
return spec.getDetail(DataSourceSpec.VALIDATIONMETHOD);
|
public java.lang.String | getValidationTableName()Returns the table checked for during validation
return spec.getDetail(DataSourceSpec.VALIDATIONTABLENAME);
|
public int | hashCode()Returns the hash code for this ManagedConnectionFactory .
if (logWriter != null) {
logWriter.println("In hashCode");
}
return spec.hashCode();
|
protected boolean | isEqual(javax.resource.spi.security.PasswordCredential pc, java.lang.String user, java.lang.String password)
//if equal get direct connection else
//get connection with user and password.
String thisUser = (pc == null) ? null : pc.getUserName();
char[] passwordArray = (pc == null) ? null : pc.getPassword();
String thisPassword = (passwordArray == null) ? null : new String(passwordArray);
return (isStringEqual(thisUser, user) && isStringEqual(thisPassword, password));
|
public boolean | isStatementWrappingEnabled()Returns whether statement wrapping is enabled or not.
return statementWrapping;
|
private boolean | isStringEqual(java.lang.String str1, java.lang.String str2)
return str1 == null ? str2 == null : str1.equals(str2);
|
void | isValid(com.sun.gjc.spi.ManagedConnection mc)Checks if a ManagedConnection is to be validated or not
and validates it or returns.
if (mc == null || mc.isTransactionInProgress()) {
return;
}
String conVal = spec.getDetail(DataSourceSpec.CONNECTIONVALIDATIONREQUIRED);
boolean connectionValidationRequired =
(conVal == null) ? false : Boolean.valueOf(conVal.toLowerCase());
if (!connectionValidationRequired) {
return;
}
String validationMethod = spec.getDetail(DataSourceSpec.VALIDATIONMETHOD).toLowerCase();
mc.checkIfValid();
/**
* The above call checks if the actual physical connection
* is usable or not.
*/
java.sql.Connection con = mc.getActualConnection();
if (validationMethod.equals("auto-commit")) {
isValidByAutoCommit(con);
} else if (validationMethod.equals("meta-data")) {
isValidByMetaData(con);
} else if (validationMethod.equals("table")) {
isValidByTableQuery(con, spec.getDetail(DataSourceSpec.VALIDATIONTABLENAME));
} else {
throw new ResourceException("The validation method is not proper");
}
|
protected void | isValidByAutoCommit(java.sql.Connection con)Checks if a java.sql.Connection is valid or not
by checking its auto commit property.
if (con == null) {
throw new ResourceException("The connection is not valid as "
+ "the connection is null");
}
try {
// Notice that using something like
// dbCon.setAutoCommit(dbCon.getAutoCommit()) will cause problems with
// some drivers like sybase
// We do not validate connections that are already enlisted
//in a transaction
// We cycle autocommit to true and false to by-pass drivers that
// might cache the call to set autocomitt
// Also notice that some XA data sources will throw and exception if
// you try to call setAutoCommit, for them this method is not recommended
boolean ac = con.getAutoCommit();
if (ac) {
con.setAutoCommit(false);
} else {
con.rollback(); // prevents uncompleted transaction exceptions
con.setAutoCommit(true);
}
con.setAutoCommit(ac);
} catch (Exception sqle) {
_logger.log(Level.INFO, "jdbc.exc_autocommit_validation");
throw new ResourceException(sqle);
}
|
protected void | isValidByMetaData(java.sql.Connection con)Checks if a java.sql.Connection is valid or not
by checking its meta data.
if (con == null) {
throw new ResourceException("The connection is not valid as "
+ "the connection is null");
}
try {
con.getMetaData();
} catch (Exception sqle) {
_logger.log(Level.INFO, "jdbc.exc_metadata_validation");
throw new ResourceException(sqle);
}
|
protected void | isValidByTableQuery(java.sql.Connection con, java.lang.String tableName)Checks if a java.sql.Connection is valid or not
by querying a table.
if (con == null) {
throw new ResourceException("The connection is not valid as "
+ "the connection is null");
}
java.sql.PreparedStatement stmt = null;
java.sql.ResultSet rs = null;
try {
stmt = con.prepareStatement("SELECT COUNT(*) FROM " + tableName);
rs = stmt.executeQuery();
} catch (Exception sqle) {
_logger.log(Level.INFO, "jdbc.exc_table_validation", tableName);
throw new ResourceException(sqle);
} finally {
try {
if (rs != null) {
rs.close();
}
} catch (Exception e1) {
}
try {
if (stmt != null) {
stmt.close();
}
} catch (Exception e2) {
}
}
|
public javax.resource.spi.ManagedConnection | matchManagedConnections(java.util.Set connectionSet, javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)Returns a matched ManagedConnection from the candidate
set of ManagedConnection objects.
if (logWriter != null) {
logWriter.println("In matchManagedConnections");
}
if (connectionSet == null) {
return null;
}
PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);
java.util.Iterator iter = connectionSet.iterator();
com.sun.gjc.spi.ManagedConnection mc = null;
while (iter.hasNext()) {
try {
mc = (com.sun.gjc.spi.ManagedConnection) iter.next();
} catch (java.util.NoSuchElementException nsee) {
_logger.log(Level.SEVERE, "jdbc.exc_iter");
throw new ResourceException(nsee.getMessage());
}
if (pc == null && this.equals(mc.getManagedConnectionFactory())) {
return mc;
} else if (SecurityUtils.isPasswordCredentialEqual(pc, mc.getPasswordCredential())) {
return mc;
}
}
return null;
|
void | resetIsolation(com.sun.gjc.spi.ManagedConnection mc, int tranIsol)Resets the isolation level for the ManagedConnection passed.
If the transaction level is to be guaranteed to be the same as the one
present when this ManagedConnection was created, as specified
by the ConnectionRequestInfo passed, it sets the transaction
isolation level from the ConnectionRequestInfo passed. Else,
it sets it to the transaction isolation passed.
java.sql.Connection con = mc.getActualConnection();
if (con == null) {
return;
}
String tranIsolation = spec.getDetail(DataSourceSpec.TRANSACTIONISOLATION);
if (tranIsolation != null && tranIsolation.equals("") == false) {
String guaranteeIsolationLevel = spec.getDetail(DataSourceSpec.GUARANTEEISOLATIONLEVEL);
if (guaranteeIsolationLevel != null && guaranteeIsolationLevel.equals("") == false) {
boolean guarantee = Boolean.valueOf(guaranteeIsolationLevel.toLowerCase());
if (guarantee) {
int tranIsolationInt = getTransactionIsolationInt(tranIsolation);
try {
if (tranIsolationInt != con.getTransactionIsolation()) {
con.setTransactionIsolation(tranIsolationInt);
}
} catch (java.sql.SQLException sqle) {
_logger.log(Level.SEVERE, "jdbc.exc_tx_iso", sqle);
throw new ResourceException("The isolation level could not be set: "
+ sqle.getMessage());
}
} else {
try {
if (tranIsol != con.getTransactionIsolation()) {
con.setTransactionIsolation(tranIsol);
}
} catch (java.sql.SQLException sqle) {
_logger.log(Level.SEVERE, "jdbc.exc_tx_iso", sqle);
throw new ResourceException("The isolation level could not be set: "
+ sqle.getMessage());
}
}
}
}
|
public void | setClassName(java.lang.String className)Sets the class name of the data source
spec.setDetail(DataSourceSpec.CLASSNAME, className);
|
public void | setConnectionValidationRequired(java.lang.String conVldReq)Sets if connection validation is required or not
spec.setDetail(DataSourceSpec.CONNECTIONVALIDATIONREQUIRED, conVldReq);
|
public void | setDataSourceName(java.lang.String dsn)Sets the data source name.
spec.setDetail(DataSourceSpec.DATASOURCENAME, dsn);
|
public void | setDatabaseName(java.lang.String databaseName)Sets the database name.
spec.setDetail(DataSourceSpec.DATABASENAME, databaseName);
|
public void | setDelimiter(java.lang.String delim)Sets the delimiter.
spec.setDetail(DataSourceSpec.DELIMITER, delim);
|
public void | setDescription(java.lang.String desc)Sets the description.
spec.setDetail(DataSourceSpec.DESCRIPTION, desc);
|
public void | setDriverProperties(java.lang.String driverProps)Sets the driver specific properties.
spec.setDetail(DataSourceSpec.DRIVERPROPERTIES, driverProps);
|
public void | setGuaranteeIsolationLevel(java.lang.String guaranteeIsolation)Sets if the transaction isolation level is to be guaranteed
spec.setDetail(DataSourceSpec.GUARANTEEISOLATIONLEVEL, guaranteeIsolation);
|
protected void | setIsolation(com.sun.gjc.spi.ManagedConnection mc)Sets the isolation level specified in the ConnectionRequestInfo
for the ManagedConnection passed.
java.sql.Connection con = mc.getActualConnection();
if (con == null) {
return;
}
String tranIsolation = spec.getDetail(DataSourceSpec.TRANSACTIONISOLATION);
if (tranIsolation != null && tranIsolation.equals("") == false) {
int tranIsolationInt = getTransactionIsolationInt(tranIsolation);
try {
con.setTransactionIsolation(tranIsolationInt);
mc.setLastTransactionIsolationLevel(tranIsolationInt);
} catch (java.sql.SQLException sqle) {
_logger.log(Level.SEVERE, "jdbc.exc_tx_iso", sqle);
throw new ResourceException("The transaction isolation could "
+ "not be set: " + sqle.getMessage());
}
}
|
public void | setJdbc30DataSource(java.lang.String booleanValue)
spec.setDetail(DataSourceSpec.JDBC30DATASOURCE,booleanValue);
|
public void | setLogWriter(java.io.PrintWriter out)Set the log writer for this ManagedConnectionFactory instance.
logWriter = out;
|
public void | setLoginTimeOut(java.lang.String loginTimeOut)Sets the login timeout.
spec.setDetail(DataSourceSpec.LOGINTIMEOUT, loginTimeOut);
|
public void | setNetworkProtocol(java.lang.String nwProtocol)Sets the network protocol.
spec.setDetail(DataSourceSpec.NETWORKPROTOCOL, nwProtocol);
|
public void | setPassword(java.lang.String passwd)Sets the password
spec.setDetail(DataSourceSpec.PASSWORD, passwd);
|
public void | setPortNumber(java.lang.String portNumber)Sets the port number.
spec.setDetail(DataSourceSpec.PORTNUMBER, portNumber);
|
public void | setResourceAdapter(javax.resource.spi.ResourceAdapter ra)Set the associated ResourceAdapter JavaBean.
this.ra = ra;
|
public void | setRoleName(java.lang.String roleName)Sets the role name.
spec.setDetail(DataSourceSpec.ROLENAME, roleName);
|
public void | setServerName(java.lang.String serverName)Sets the server name.
spec.setDetail(DataSourceSpec.SERVERNAME, serverName);
|
public void | setStatementTimeout(java.lang.String timeout)Set StatementTimeout value
spec.setDetail(DataSourceSpec.STATEMENTTIMEOUT, timeout);
|
public void | setStatementWrapping(java.lang.String wrapping)Set Statement Wrapping value
spec.setDetail(DataSourceSpec.STATEMENTWRAPPING, wrapping);
computeStatementWrappingStatus();
|
public void | setTransactionIsolation(java.lang.String trnIsolation)Sets the transaction isolation level
spec.setDetail(DataSourceSpec.TRANSACTIONISOLATION, trnIsolation);
|
public void | setUser(java.lang.String user)Sets the user name
spec.setDetail(DataSourceSpec.USERNAME, user);
|
public void | setValidationMethod(java.lang.String validationMethod)Sets the validation method required
spec.setDetail(DataSourceSpec.VALIDATIONMETHOD, validationMethod);
|
public void | setValidationTableName(java.lang.String table)Sets the table checked for during validation
spec.setDetail(DataSourceSpec.VALIDATIONTABLENAME, table);
|
protected void | validateAndSetIsolation(com.sun.gjc.spi.ManagedConnection mc)Common operation performed by all the child MCFs before returning a created mc
isValid(mc);
setIsolation(mc);
|