FileDocCategorySizeDatePackage
ResourceSpec.javaAPI DocGlassfish v2 API7503Fri May 04 22:35:14 BST 2007com.sun.enterprise.resource

ResourceSpec

public class ResourceSpec extends Object implements Serializable
ResourceSpec is used as a key to locate the correct resource pool

Fields Summary
private String
resourceId
private int
resourceIdType
private boolean
pmResource
private boolean
nonTxResource
private boolean
lazyEnlistable_
private boolean
lazyAssociatable_
private Object
connectionToAssoc_
private boolean
isXA_
private String
connectionPoolName
public static final int
JDBC_URL
public static final int
JNDI_NAME
public static final int
JMS
Constructors Summary
public ResourceSpec(String resourceId, int resourceIdType)


      
          
        if (resourceId == null) throw new NullPointerException();
        this.resourceId = resourceId;
        this.resourceIdType = resourceIdType;
        if (resourceId.endsWith(ConnectorConstants.PM_JNDI_SUFFIX) ) {
            pmResource = true;
        }
	if (resourceId.endsWith(ConnectorConstants.NON_TX_JNDI_SUFFIX) ) {
	    nonTxResource = true;
	}
    
public ResourceSpec(String resourceId, int resourceIdType, com.sun.enterprise.connectors.PoolMetaData pmd)

        this( resourceId, resourceIdType );
        
        if (pmd != null ) {
            if ( pmd.isPM() ) {
                pmResource = true;
            }
            if( pmd.isNonTx() ) {
                nonTxResource = true;
            }

            if( pmd.isLazyEnlistable() && !nonTxResource && !pmResource ) {
                lazyEnlistable_ = true;
            }

            if ( pmd.isLazyAssociatable() && !nonTxResource && !pmResource) {
                lazyAssociatable_ = true;    
                //The rationale behind doing this is that in the PoolManagerImpl
                //when we return from getResource called by associateConnections, 
                //enlistment should happen immediately since we are associating on
                //first use anyway, 
                lazyEnlistable_ = false;
            }
        
        }

    
Methods Summary
public booleanequals(java.lang.Object other)

        if (other == null) return false;
        if (other instanceof ResourceSpec) {
            ResourceSpec obj = (ResourceSpec) other;
            if(connectionPoolName == null) {
                return (resourceId.equals(obj.resourceId) &&
                resourceIdType == obj.resourceIdType);
            } else {
                return (connectionPoolName.equals(obj.connectionPoolName));

            }
        } else {
            return false;
        }
    
public java.lang.StringgetConnectionPoolName()

        return connectionPoolName;
    
public java.lang.ObjectgetConnectionToAssociate()

        return connectionToAssoc_;
    
public java.lang.StringgetResourceId()

        return resourceId;
    
public inthashCode()

        if(connectionPoolName == null) {
            return resourceId.hashCode() + resourceIdType;
        } else {
            return connectionPoolName.hashCode();
        }
    
public booleanisLazyAssociatable()

        return lazyAssociatable_;
    
public booleanisLazyEnlistable()

        return lazyEnlistable_;
    
public booleanisNonTx()
Returns the status of the noTxResource flag

return
true if this resource is a noTx resource

        return nonTxResource;
    
public booleanisPM()

        return pmResource;
    
public booleanisXA()

        return isXA_;
    
public voidmarkAsXA()

        isXA_ = true;
    
public voidsetConnectionPoolName(java.lang.String name)

        connectionPoolName = name;
    
public voidsetConnectionToAssociate(java.lang.Object conn)

        connectionToAssoc_ = conn;
    
public voidsetLazyAssociatable(boolean lazyAssoc)

        lazyAssociatable_ = lazyAssoc;
    
public voidsetLazyEnlistable(boolean lazyEnlist)

        lazyEnlistable_ = lazyEnlist;
    
public java.lang.StringtoString()

        StringBuffer sb = new StringBuffer("ResourceSpec :- ");
        sb.append("\nconnectionPoolName : ").append(connectionPoolName);
        sb.append("\nisXA_ : ").append(isXA_);
        sb.append("\nresoureId : ").append(resourceId);
        sb.append("\nresoureIdType : ").append(resourceIdType);
        sb.append("\npmResource : ").append(pmResource);
        sb.append("\nnonTxResource : ").append(nonTxResource);
        sb.append("\nlazyEnlistable : ").append(lazyEnlistable_);
        sb.append("\nlazyAssociatable : ").append(lazyAssociatable_);

        return sb.toString();