Methods Summary |
---|
public javax.resource.spi.ManagedConnection | createManagedConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri)
Properties props = getConnectionProperties(subject, cri);
try
{
final String user = props.getProperty("user");
final String password = props.getProperty("password");
XAConnection xaConnection = (user != null)
? getXADataSource().getXAConnection(user, password)
: getXADataSource().getXAConnection();
return newXAManagedConnection(props, xaConnection);
}
catch (Exception e)
{
throw new JBossResourceException("Could not create connection", e);
}
|
public boolean | equals(java.lang.Object other)
if (this == other)
return true;
if (getClass() != other.getClass())
return false;
XAManagedConnectionFactory otherMcf = (XAManagedConnectionFactory) other;
return this.xaDataSourceClass.equals(otherMcf.xaDataSourceClass) && this.xaProps.equals(otherMcf.xaProps)
&& ((this.userName == null) ? otherMcf.userName == null : this.userName.equals(otherMcf.userName))
&& ((this.password == null) ? otherMcf.password == null : this.password.equals(otherMcf.password))
&& this.transactionIsolation == otherMcf.transactionIsolation;
|
protected synchronized javax.sql.XADataSource | getXADataSource()
if (xads == null)
{
if (xaDataSourceClass == null)
throw new JBossResourceException("No XADataSourceClass supplied!");
try
{
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(xaDataSourceClass);
xads = (XADataSource) clazz.newInstance();
Class[] NOCLASSES = new Class[] {};
for (Iterator i = xaProps.keySet().iterator(); i.hasNext();)
{
String name = (String) i.next();
String value = xaProps.getProperty(name);
//This is a bad solution. On the other hand the only known example
// of a setter with no getter is for Oracle with password.
//Anyway, each xadatasource implementation should get its
//own subclass of this that explicitly sets the
//properties individually.
Class type = null;
try
{
Method getter = clazz.getMethod("get" + name, NOCLASSES);
type = getter.getReturnType();
}
catch (NoSuchMethodException e)
{
type = String.class;
try
{
//HACK for now until we can rethink the XADataSourceProperties variable and pass type information
Method getter = clazz.getMethod("is" + name, NOCLASSES);
type = getter.getReturnType();
}catch(NoSuchMethodException nsme)
{
type = String.class;
}
}
Method setter = clazz.getMethod("set" + name, new Class[] { type });
PropertyEditor editor = PropertyEditorManager.findEditor(type);
if (editor == null)
throw new JBossResourceException("No property editor found for type: " + type);
editor.setAsText(value);
setter.invoke(xads, new Object[] { editor.getValue() });
}
}
catch (ClassNotFoundException cnfe)
{
throw new JBossResourceException("Class not found for XADataSource " + xaDataSourceClass, cnfe);
}
catch (InstantiationException ie)
{
throw new JBossResourceException("Could not create an XADataSource: ", ie);
}
catch (IllegalAccessException iae)
{
throw new JBossResourceException("Could not set a property: ", iae);
}
catch (IllegalArgumentException iae)
{
throw new JBossResourceException("Could not set a property: ", iae);
}
catch (InvocationTargetException ite)
{
throw new JBossResourceException("Could not invoke setter on XADataSource: ", ite);
}
catch (NoSuchMethodException nsme)
{
throw new JBossResourceException("Could not find accessor on XADataSource: ", nsme);
}
}
return xads;
|
public java.lang.String | getXADataSourceClass()Get the XaDataSourceClass value.
return xaDataSourceClass;
|
public java.lang.String | getXADataSourceProperties()Get the XADataSourceProperties value.
return xaDataSourceProperties;
|
protected java.util.Properties | getXaProps()
return xaProps;
|
public int | hashCode()
int result = 17;
result = result * 37 + ((xaDataSourceClass == null) ? 0 : xaDataSourceClass.hashCode());
result = result * 37 + xaProps.hashCode();
result = result * 37 + ((userName == null) ? 0 : userName.hashCode());
result = result * 37 + ((password == null) ? 0 : password.hashCode());
result = result * 37 + transactionIsolation;
return result;
|
public javax.resource.spi.ManagedConnection | matchManagedConnections(java.util.Set mcs, javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cri)
Properties newProps = getConnectionProperties(subject, cri);
for (Iterator i = mcs.iterator(); i.hasNext();)
{
Object o = i.next();
if (o instanceof XAManagedConnection)
{
XAManagedConnection mc = (XAManagedConnection) o;
if (mc.getProps().equals(newProps))
{
//Next check to see if we are validating on matchManagedConnections
if((getValidateOnMatch() && mc.checkValid()) || !getValidateOnMatch())
{
return mc;
}
}
}
}
return null;
|
protected javax.resource.spi.ManagedConnection | newXAManagedConnection(java.util.Properties props, javax.sql.XAConnection xaConnection)This method can be overwritten by sublcasses to provide rm specific
implementation of XAManagedConnection
return new XAManagedConnection(this, xaConnection, props, transactionIsolation, preparedStatementCacheSize);
|
public void | setXADataSourceClass(java.lang.String xaDataSourceClass)Set the XaDataSourceClass value.
this.xaDataSourceClass = xaDataSourceClass;
|
public void | setXADataSourceProperties(java.lang.String xaDataSourceProperties)Set the XADataSourceProperties value.
this.xaDataSourceProperties = xaDataSourceProperties;
xaProps.clear();
if (xaDataSourceProperties != null)
{
// Map any \ to \\
xaDataSourceProperties = xaDataSourceProperties.replaceAll("\\\\", "\\\\\\\\");
InputStream is = new ByteArrayInputStream(xaDataSourceProperties.getBytes());
try
{
xaProps.load(is);
}
catch (IOException ioe)
{
throw new JBossResourceException("Could not load connection properties", ioe);
}
}
|