FileDocCategorySizeDatePackage
XAManagedConnectionFactory.javaAPI DocGlassfish v2 API10385Fri May 04 22:36:04 BST 2007com.sun.gjc.spi

XAManagedConnectionFactory

public class XAManagedConnectionFactory extends ManagedConnectionFactory
XA ManagedConnectionFactory implementation for Generic JDBC Connector.
author
Evani Sai Surya Kiran
version
1.0, 02/07/27

Fields Summary
private transient XADataSource
xaDataSourceObj
private static Logger
_logger
Constructors Summary
Methods Summary
public javax.resource.spi.ManagedConnectioncreateManagedConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
Creates a new physical connection to the underlying EIS resource manager.

param
subject Subject instance passed by the application server
param
cxRequestInfo ConnectionRequestInfo which may be created as a result of the invocation getConnection(user, password) on the DataSource object
return
ManagedConnection object created
throws
ResourceException if there is an error in instantiating the DataSource object used for the creation of the ManagedConnection object
throws
SecurityException if there ino PasswordCredential object satisfying this request
throws
ResourceAllocationException if there is an error in allocating the physical connection

        _logger = LogDomains.getLogger(LogDomains.RSR_LOGGER);
    
        if (logWriter != null) {
            logWriter.println("In createManagedConnection");
        }
        PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);

        javax.sql.XADataSource dataSource = getDataSource();

        javax.sql.XAConnection xaConn = null;

        try {
            /* For the case where the user/passwd of the connection pool is
            * equal to the PasswordCredential for the connection request
            * get a connection from this pool directly.
            * for all other conditions go create a new connection
            */
            if (isEqual(pc, getUser(), getPassword())) {
                xaConn = dataSource.getXAConnection();
            } else {
                xaConn = dataSource.getXAConnection(pc.getUserName(),
                        new String(pc.getPassword()));
            }


        } catch (java.sql.SQLException sqle) {
            //_logger.log(Level.WARNING, "jdbc.exc_create_xa_conn",sqle);
            _logger.log(Level.FINE, "jdbc.exc_create_xa_conn", sqle);
            StringManager sm = StringManager.getManager(
                    DataSourceObjectBuilder.class);
            String msg = sm.getString("jdbc.cannot_allocate_connection", sqle.getMessage());
            throw new ResourceAllocationException(msg, sqle);
        }

        com.sun.gjc.spi.ManagedConnection mc = constructManagedConnection(
                xaConn, null, pc, this);

        mc.initializeConnectionType(ManagedConnection.ISXACONNECTION);
        //GJCINT
        validateAndSetIsolation(mc);
        return mc;
    
public booleanequals(java.lang.Object other)
Check if this ManagedConnectionFactory is equal to another ManagedConnectionFactory.

param
other ManagedConnectionFactory object for checking equality with
return
true if the property sets of both the ManagedConnectionFactory objects are the same false otherwise

        if (logWriter != null) {
            logWriter.println("In equals");
        }
        /**
         * The check below means that two ManagedConnectionFactory objects are equal
         * if and only if their properties are the same.
         */
        if (other instanceof com.sun.gjc.spi.XAManagedConnectionFactory) {
            com.sun.gjc.spi.XAManagedConnectionFactory otherMCF =
                    (com.sun.gjc.spi.XAManagedConnectionFactory) other;
            return this.spec.equals(otherMCF.spec);
        }
        return false;
    
public javax.sql.XADataSourcegetDataSource()
Returns the underlying datasource

return
DataSource of jdbc vendor
throws
ResourceException

        if (xaDataSourceObj == null) {
            try {
                xaDataSourceObj = (javax.sql.XADataSource) super.getDataSource();
            } catch (ClassCastException cce) {
                _logger.log(Level.SEVERE, "jdbc.exc_cce_XA", cce);
                throw new ResourceException(cce.getMessage());
            }
        }
        return xaDataSourceObj;
    
public java.lang.StringgetInitialPoolSize()
Gets the initial pool size.

return
initPoolSz
see
setInitialPoolSize

        return spec.getDetail(DataSourceSpec.INITIALPOOLSIZE);
    
public java.lang.StringgetMaxIdleTime()
Gets the maximum idle time.

return
maxIdleTime
see
setMaxIdleTime

        return spec.getDetail(DataSourceSpec.MAXIDLETIME);
    
public java.lang.StringgetMaxPoolSize()
Gets the maximum pool size.

return
maxPoolSz
see
setMaxPoolSize

        return spec.getDetail(DataSourceSpec.MAXPOOLSIZE);
    
public java.lang.StringgetMaxStatements()
Gets the max statements.

return
maxStmts
see
setMaxStatements

        return spec.getDetail(DataSourceSpec.MAXSTATEMENTS);
    
public java.lang.StringgetMinPoolSize()
Gets the minimum pool size.

return
minPoolSz
see
setMinPoolSize

        return spec.getDetail(DataSourceSpec.MINPOOLSIZE);
    
public java.lang.StringgetPropertyCycle()
Gets the property cycle.

return
propCycle
see
setPropertyCycle

        return spec.getDetail(DataSourceSpec.PROPERTYCYCLE);
    
public voidsetInitialPoolSize(java.lang.String initPoolSz)
Sets the initial pool size.

param
initPoolSz String
see
getInitialPoolSize

        spec.setDetail(DataSourceSpec.INITIALPOOLSIZE, initPoolSz);
    
public voidsetMaxIdleTime(java.lang.String maxIdleTime)
Sets the maximum idle time.

param
maxIdleTime String
see
getMaxIdleTime

        spec.setDetail(DataSourceSpec.MAXIDLETIME, maxIdleTime);
    
public voidsetMaxPoolSize(java.lang.String maxPoolSz)
Sets the maximum pool size.

param
maxPoolSz String
see
getMaxPoolSize

        spec.setDetail(DataSourceSpec.MAXPOOLSIZE, maxPoolSz);
    
public voidsetMaxStatements(java.lang.String maxStmts)
Sets the max statements.

param
maxStmts String
see
getMaxStatements

        spec.setDetail(DataSourceSpec.MAXSTATEMENTS, maxStmts);
    
public voidsetMinPoolSize(java.lang.String minPoolSz)
Sets the minimum pool size.

param
minPoolSz String
see
getMinPoolSize

        spec.setDetail(DataSourceSpec.MINPOOLSIZE, minPoolSz);
    
public voidsetPropertyCycle(java.lang.String propCycle)
Sets the property cycle.

param
propCycle String
see
getPropertyCycle

        spec.setDetail(DataSourceSpec.PROPERTYCYCLE, propCycle);