1 23 package com.sun.enterprise.resource; 24 25 import java.io.Serializable ; 26 import com.sun.enterprise.connectors.PoolMetaData; 27 import com.sun.enterprise.connectors.ConnectorConstants; 28 29 32 33 public class ResourceSpec implements Serializable { 34 private String resourceId; 35 private int resourceIdType; 36 private boolean pmResource; 37 private boolean nonTxResource; 38 private boolean lazyEnlistable_; 39 private boolean lazyAssociatable_; 40 private Object connectionToAssoc_; 41 private boolean isXA_; 42 43 private String connectionPoolName; 44 45 static public final int JDBC_URL = 0; 46 static public final int JNDI_NAME = 1; 47 static public final int JMS = 2; 48 49 public ResourceSpec(String resourceId, 50 int resourceIdType) { 51 if (resourceId == null) throw new NullPointerException (); 52 this.resourceId = resourceId; 53 this.resourceIdType = resourceIdType; 54 if (resourceId.endsWith(ConnectorConstants.PM_JNDI_SUFFIX) ) { 55 pmResource = true; 56 } 57 if (resourceId.endsWith(ConnectorConstants.NON_TX_JNDI_SUFFIX) ) { 58 nonTxResource = true; 59 } 60 } 61 62 public ResourceSpec( String resourceId, int resourceIdType, 63 PoolMetaData pmd ) { 64 this( resourceId, resourceIdType ); 65 66 if (pmd != null ) { 67 if ( pmd.isPM() ) { 68 pmResource = true; 69 } 70 if( pmd.isNonTx() ) { 71 nonTxResource = true; 72 } 73 74 if( pmd.isLazyEnlistable() && !nonTxResource && !pmResource ) { 75 lazyEnlistable_ = true; 76 } 77 78 if ( pmd.isLazyAssociatable() && !nonTxResource && !pmResource) { 79 lazyAssociatable_ = true; 80 lazyEnlistable_ = false; 85 } 86 87 } 88 89 } 90 91 public String getConnectionPoolName() { 92 return connectionPoolName; 93 } 94 95 96 public void setConnectionPoolName(String name) { 97 connectionPoolName = name; 98 } 99 100 101 108 109 public boolean equals(Object other) { 110 if (other == null) return false; 111 if (other instanceof ResourceSpec) { 112 ResourceSpec obj = (ResourceSpec) other; 113 if(connectionPoolName == null) { 114 return (resourceId.equals(obj.resourceId) && 115 resourceIdType == obj.resourceIdType); 116 } else { 117 return (connectionPoolName.equals(obj.connectionPoolName)); 118 119 } 120 } else { 121 return false; 122 } 123 } 124 125 131 132 public int hashCode() { 133 if(connectionPoolName == null) { 134 return resourceId.hashCode() + resourceIdType; 135 } else { 136 return connectionPoolName.hashCode(); 137 } 138 } 139 140 public String getResourceId() { 141 return resourceId; 142 } 143 144 public boolean isPM() { 145 return pmResource; 146 } 147 148 153 154 public boolean isNonTx() { 155 return nonTxResource; 156 } 157 158 public boolean isXA() { 159 return isXA_; 160 } 161 162 public void markAsXA() { 163 isXA_ = true; 164 } 165 166 public boolean isLazyEnlistable() { 167 return lazyEnlistable_; 168 } 169 170 171 public void setLazyEnlistable( boolean lazyEnlist ) { 172 lazyEnlistable_ = lazyEnlist; 173 } 174 175 public boolean isLazyAssociatable() { 176 return lazyAssociatable_; 177 } 178 179 180 public void setLazyAssociatable( boolean lazyAssoc ) { 181 lazyAssociatable_ = lazyAssoc; 182 } 183 184 public void setConnectionToAssociate( Object conn ) { 185 connectionToAssoc_ = conn; 186 } 187 188 public Object getConnectionToAssociate() { 189 return connectionToAssoc_; 190 } 191 192 public String toString() { 193 StringBuffer sb = new StringBuffer ("ResourceSpec :- "); 194 sb.append("\nconnectionPoolName : " + connectionPoolName ); 195 sb.append("\nisXA_ : " + isXA_ ); 196 sb.append("\nresoureId : " + resourceId ); 197 sb.append("\nresoureIdType : " + resourceIdType ); 198 sb.append("\npmResource : " + pmResource ); 199 sb.append("\nnonTxResource : " + nonTxResource ); 200 sb.append("\nlazyEnlistable : " + lazyEnlistable_ ); 201 sb.append("\nlazyAssociatable : " + lazyAssociatable_ ); 202 203 return sb.toString(); 204 } 205 206 } 207 | Popular Tags |