Fields Summary |
---|
static final long | serialVersionUID |
public static final int | TRACK_STATEMENTS_FALSE_INT |
public static final int | TRACK_STATEMENTS_TRUE_INT |
public static final int | TRACK_STATEMENTS_NOWARN_INT |
public static final String | TRACK_STATEMENTS_FALSE |
public static final String | TRACK_STATEMENTS_TRUE |
public static final String | TRACK_STATEMENTS_NOWARN |
protected final Logger | log |
protected String | userName |
protected String | password |
protected final Properties | connectionProps |
protected int | transactionIsolation |
protected int | preparedStatementCacheSize |
protected boolean | doQueryTimeout |
protected String | newConnectionSQLThe variable newConnectionSQL holds an SQL
statement which if not null is executed when a new Connection is
obtained for a new ManagedConnection. |
protected String | checkValidConnectionSQLThe variable checkValidConnectionSQL holds an sql
statement that may be executed whenever a managed connection is
removed from the pool, to check that it is still valid. This
requires setting up an mbean to execute it when notified by the
ConnectionManager. |
protected String | validConnectionCheckerClassNameThe classname used to check whether a connection is valid |
protected ValidConnectionChecker | connectionCheckerThe instance of the valid connection checker |
private String | exceptionSorterClassName |
private ExceptionSorter | exceptionSorter |
protected int | trackStatements |
protected boolean | sharePSWhether to share cached prepared statements |
protected boolean | isTransactionQueryTimeout |
protected int | queryTimeout |
private boolean | validateOnMatch |
Methods Summary |
---|
public java.lang.Object | createConnectionFactory(javax.resource.spi.ConnectionManager cm)
return new WrapperDataSource(this, cm);
|
public java.lang.Object | createConnectionFactory()
throw new JBossResourceException("NYI");
|
public java.lang.String | getCheckValidConnectionSQL()
return checkValidConnectionSQL;
|
protected java.util.Properties | getConnectionProperties(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri)Gets full set of connection properties, i.e. whatever is provided
in config plus "user" and "password" from subject/cri.
Note that the set is used to match connections to datasources as well
as to create new managed connections.
In fact, we have a problem here. Theoretically, there is a possible
name collision between config properties and "user"/"password".
if (cri != null && cri.getClass() != WrappedConnectionRequestInfo.class)
throw new JBossResourceException("Wrong kind of ConnectionRequestInfo: " + cri.getClass());
Properties props = new Properties();
props.putAll(connectionProps);
if (subject != null)
{
if (SubjectActions.addMatchingProperties(subject, props, this) == true)
return props;
throw new JBossResourceException("No matching credentials in Subject!");
}
WrappedConnectionRequestInfo lcri = (WrappedConnectionRequestInfo)cri;
if (lcri != null)
{
props.setProperty("user", (lcri.getUserName() == null)? "": lcri.getUserName());
props.setProperty("password", (lcri.getPassword() == null)? "": lcri.getPassword());
return props;
}
if (userName != null)
{
props.setProperty("user", userName);
props.setProperty("password", (password == null) ? "" : password);
}
return props;
|
public java.lang.String | getExceptionSorterClassName()
return exceptionSorterClassName;
|
public java.util.Set | getInvalidConnections(java.util.Set connectionSet)
final Set invalid = new HashSet();
for(Iterator iter = connectionSet.iterator(); iter.hasNext();){
Object anonymous = iter.next();
if (anonymous instanceof BaseWrapperManagedConnection)
{
BaseWrapperManagedConnection mc = (BaseWrapperManagedConnection) anonymous;
if(!mc.checkValid()){
invalid.add(mc);
}
}
}
return invalid;
|
public java.io.PrintWriter | getLogWriter()
// TODO: implement this javax.resource.spi.ManagedConnectionFactory method
return null;
|
public java.lang.String | getNewConnectionSQL()
return newConnectionSQL;
|
public java.lang.String | getPassword()
return password;
|
public int | getPreparedStatementCacheSize()
return preparedStatementCacheSize;
|
public int | getQueryTimeout()
return queryTimeout;
|
public boolean | getSharePreparedStatements()
return sharePS;
|
public java.lang.String | getTrackStatements()
if (trackStatements == TRACK_STATEMENTS_FALSE_INT)
return TRACK_STATEMENTS_FALSE;
else if (trackStatements == TRACK_STATEMENTS_TRUE_INT)
return TRACK_STATEMENTS_TRUE;
return TRACK_STATEMENTS_NOWARN;
|
public java.lang.String | getTransactionIsolation()
switch (this.transactionIsolation)
{
case Connection.TRANSACTION_NONE:
return "TRANSACTION_NONE";
case Connection.TRANSACTION_READ_COMMITTED:
return "TRANSACTION_READ_COMMITTED";
case Connection.TRANSACTION_READ_UNCOMMITTED:
return "TRANSACTION_READ_UNCOMMITTED";
case Connection.TRANSACTION_REPEATABLE_READ:
return "TRANSACTION_REPEATABLE_READ";
case Connection.TRANSACTION_SERIALIZABLE:
return "TRANSACTION_SERIALIZABLE";
case -1:
return "DEFAULT";
default:
return Integer.toString(transactionIsolation);
}
|
public java.lang.String | getUserName()
return userName;
|
public java.lang.String | getValidConnectionCheckerClassName()
return validConnectionCheckerClassName;
|
public boolean | getValidateOnMatch()
return this.validateOnMatch;
|
boolean | isExceptionFatal(java.sql.SQLException e)
try
{
if (exceptionSorter != null)
return exceptionSorter.isExceptionFatal(e);
if (exceptionSorterClassName != null)
{
try
{
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class clazz = cl.loadClass(exceptionSorterClassName);
exceptionSorter = (ExceptionSorter)clazz.newInstance();
return exceptionSorter.isExceptionFatal(e);
}
catch (Exception e2)
{
log.warn("exception trying to create exception sorter (disabling):", e2);
exceptionSorter = new NullExceptionSorter();
}
}
}
catch (Throwable t)
{
log.warn("Error checking exception fatality: ", t);
}
return false;
|
public boolean | isTransactionQueryTimeout()
return isTransactionQueryTimeout;
|
java.sql.SQLException | isValidConnection(java.sql.Connection c)Checks whether a connection is valid
// Already got a checker
if (connectionChecker != null)
return connectionChecker.isValidConnection(c);
// Class specified
if (validConnectionCheckerClassName != null)
{
try
{
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class clazz = cl.loadClass(validConnectionCheckerClassName);
connectionChecker = (ValidConnectionChecker) clazz.newInstance();
return connectionChecker.isValidConnection(c);
}
catch (Exception e)
{
log.warn("Exception trying to create connection checker (disabling):", e);
connectionChecker = new NullValidConnectionChecker();
}
}
// SQL statement specified
if (checkValidConnectionSQL != null)
{
connectionChecker = new CheckValidConnectionSQL(checkValidConnectionSQL);
return connectionChecker.isValidConnection(c);
}
// No Check
return null;
|
public void | setCheckValidConnectionSQL(java.lang.String checkValidConnectionSQL)
this.checkValidConnectionSQL = checkValidConnectionSQL;
|
public void | setExceptionSorterClassName(java.lang.String exceptionSorterClassName)
this.exceptionSorterClassName = exceptionSorterClassName;
|
public void | setLogWriter(java.io.PrintWriter param1)
// TODO: implement this javax.resource.spi.ManagedConnectionFactory method
|
public void | setNewConnectionSQL(java.lang.String newConnectionSQL)
this.newConnectionSQL = newConnectionSQL;
|
public void | setPassword(java.lang.String password)
this.password = password;
|
public void | setPreparedStatementCacheSize(int size)
preparedStatementCacheSize = size;
|
public void | setQueryTimeout(int timeout)
queryTimeout = timeout;
|
public void | setSharePreparedStatements(boolean sharePS)
this.sharePS = sharePS;
|
public void | setTrackStatements(java.lang.String value)
if (value == null)
throw new IllegalArgumentException("Null value for trackStatements");
String trimmed = value.trim();
if (trimmed.equalsIgnoreCase(TRACK_STATEMENTS_FALSE))
trackStatements = TRACK_STATEMENTS_FALSE_INT;
else if (trimmed.equalsIgnoreCase(TRACK_STATEMENTS_TRUE))
trackStatements = TRACK_STATEMENTS_TRUE_INT;
else
trackStatements = TRACK_STATEMENTS_NOWARN_INT;
|
public void | setTransactionIsolation(java.lang.String transactionIsolation)
if (transactionIsolation.equals("TRANSACTION_NONE"))
this.transactionIsolation = Connection.TRANSACTION_NONE;
else if (transactionIsolation.equals("TRANSACTION_READ_COMMITTED"))
this.transactionIsolation = Connection.TRANSACTION_READ_COMMITTED;
else if (transactionIsolation.equals("TRANSACTION_READ_UNCOMMITTED"))
this.transactionIsolation = Connection.TRANSACTION_READ_UNCOMMITTED;
else if (transactionIsolation.equals("TRANSACTION_REPEATABLE_READ"))
this.transactionIsolation = Connection.TRANSACTION_REPEATABLE_READ;
else if (transactionIsolation.equals("TRANSACTION_SERIALIZABLE"))
this.transactionIsolation = Connection.TRANSACTION_SERIALIZABLE;
else
{
try
{
this.transactionIsolation = Integer.parseInt(transactionIsolation);
}
catch (NumberFormatException nfe)
{
throw new IllegalArgumentException("Setting Isolation level to unknown state: " + transactionIsolation);
}
}
|
public void | setTransactionQueryTimeout(boolean value)
isTransactionQueryTimeout = value;
|
public void | setUserName(java.lang.String userName)
this.userName = userName;
|
public void | setValidConnectionCheckerClassName(java.lang.String value)
validConnectionCheckerClassName = value;
|
public void | setValidateOnMatch(boolean validateOnMatch)
this.validateOnMatch = validateOnMatch;
|