1 17 package org.apache.geronimo.connector.deployment.jsr88; 18 19 import javax.enterprise.deploy.model.DDBean ; 20 import org.apache.geronimo.deployment.plugin.XmlBeanSupport; 21 import org.apache.geronimo.xbeans.geronimo.GerConnectionmanagerType; 22 import org.apache.xmlbeans.SchemaTypeLoader; 23 24 30 public class ConnectionManager extends XmlBeanSupport { 31 private DDBean outboundRA; 32 private SinglePool singlePool; 33 private PartitionedPool partitionedPool; 34 35 public ConnectionManager() { 36 super(null); 37 } 38 39 public ConnectionManager(DDBean outboundRA, GerConnectionmanagerType manager) { 40 super(null); 41 configure(outboundRA, manager); 42 } 43 44 void configure(DDBean outboundRA, GerConnectionmanagerType manager) { 45 this.outboundRA = outboundRA; 46 setXmlObject(manager); 47 if(!manager.isSetNoTransaction() && !manager.isSetLocalTransaction() && 48 !manager.isSetXaTransaction()) { 49 String [] test = outboundRA.getText("transaction-support"); 50 if(test.length > 0) { 51 String tx = test[0]; 52 if(tx.equalsIgnoreCase("NoTransaction")) { 53 manager.addNewNoTransaction(); 54 } else if(tx.equalsIgnoreCase("LocalTransaction")) { 55 manager.addNewLocalTransaction(); 56 } else if(tx.equalsIgnoreCase("XATransaction")) { 57 manager.addNewXaTransaction(); 58 manager.getXaTransaction().addNewTransactionCaching(); 59 } 60 } 61 } 62 if(manager.isSetSinglePool()) { 63 singlePool = new SinglePool(manager.getSinglePool()); 64 } else if(manager.isSetPartitionedPool()) { 65 partitionedPool = new PartitionedPool(manager.getPartitionedPool()); 66 } else if(!manager.isSetNoPool()) { 67 singlePool = new SinglePool(manager.addNewSinglePool()); 68 } 69 } 70 71 protected GerConnectionmanagerType getManager() { 72 return (GerConnectionmanagerType) getXmlObject(); 73 } 74 75 77 public boolean isContainerManagedSecurity() { 78 return getManager().isSetContainerManagedSecurity(); 79 } 80 81 public void setContainerManagedSecurity(boolean set) { 82 if(set) { 83 if(!isContainerManagedSecurity()) { 84 getManager().addNewContainerManagedSecurity(); 85 pcs.firePropertyChange("containerManagedSecurity", !set, set); 86 } 87 } else { 88 if(isContainerManagedSecurity()) { 89 getManager().unsetContainerManagedSecurity(); 90 pcs.firePropertyChange("containerManagedSecurity", !set, set); 91 } 92 } 93 } 94 95 public boolean isTransactionNone() { 96 return getManager().isSetNoTransaction(); 97 } 98 99 public void setTransactionNone(boolean set) { 100 if(set) { 101 if(!isTransactionNone()) { 102 getManager().addNewNoTransaction(); 103 pcs.firePropertyChange("transactionNone", !set, set); 104 } 105 if(isTransactionLocal()) setTransactionLocal(false); 106 if(isTransactionXA()) setTransactionXA(false); 107 if(isTransactionLog()) setTransactionLog(false); 108 } else { 109 if(isTransactionNone()) { 110 getManager().unsetNoTransaction(); 111 pcs.firePropertyChange("transactionNone", !set, set); 112 } 113 } 114 } 115 116 public boolean isTransactionLocal() { 117 return getManager().isSetLocalTransaction(); 118 } 119 120 public void setTransactionLocal(boolean set) { 121 if(set) { 122 if(!isTransactionLocal()) { 123 getManager().addNewLocalTransaction(); 124 pcs.firePropertyChange("transactionLocal", !set, set); 125 } 126 if(isTransactionNone()) setTransactionNone(false); 127 if(isTransactionXA()) setTransactionXA(false); 128 if(isTransactionLog()) setTransactionLog(false); 129 } else { 130 if(isTransactionLocal()) { 131 getManager().unsetLocalTransaction(); 132 pcs.firePropertyChange("transactionLocal", !set, set); 133 } 134 } 135 } 136 137 public boolean isTransactionLog() { 138 return getManager().isSetTransactionLog(); 139 } 140 141 public void setTransactionLog(boolean set) { 142 if(set) { 143 if(!isTransactionLog()) { 144 getManager().addNewTransactionLog(); 145 pcs.firePropertyChange("transactionLog", !set, set); 146 } 147 if(isTransactionNone()) setTransactionNone(false); 148 if(isTransactionXA()) setTransactionXA(false); 149 if(isTransactionLocal()) setTransactionLocal(false); 150 } else { 151 if(isTransactionLog()) { 152 getManager().unsetTransactionLog(); 153 pcs.firePropertyChange("transactionLog", !set, set); 154 } 155 } 156 } 157 158 public boolean isTransactionXA() { 159 return getManager().isSetXaTransaction(); 160 } 161 162 public void setTransactionXA(boolean set) { 163 if(set) { 164 if(!isTransactionXA()) { 165 getManager().addNewXaTransaction(); 166 pcs.firePropertyChange("transactionXA", !set, set); 167 } 168 if(isTransactionNone()) setTransactionNone(false); 169 if(isTransactionLog()) setTransactionLog(false); 170 if(isTransactionLocal()) setTransactionLocal(false); 171 } else { 172 if(isTransactionXA()) { 173 boolean oldTX = isTransactionXACachingTransaction(); 174 boolean oldThread = isTransactionXACachingThread(); 175 getManager().unsetXaTransaction(); 176 pcs.firePropertyChange("transactionXA", !set, set); 177 if(oldTX) { 178 pcs.firePropertyChange("transactionXACachingTransaction", true, false); 179 } 180 if(oldThread) { 181 pcs.firePropertyChange("transactionXACachingThread", true, false); 182 } 183 } 184 } 185 } 186 187 public boolean isTransactionXACachingTransaction() { 188 return isTransactionXA() && getManager().getXaTransaction().isSetTransactionCaching(); 189 } 190 191 public void setTransactionXACachingTransaction(boolean set) { 192 if(set) { 193 setTransactionXA(true); 194 if(!getManager().getXaTransaction().isSetTransactionCaching()) { 195 getManager().getXaTransaction().addNewTransactionCaching(); 196 pcs.firePropertyChange("transactionXACachingTransaction", !set, set); 197 } 198 } else { 199 if(isTransactionXA() && getManager().getXaTransaction().isSetTransactionCaching()) { 200 getManager().getXaTransaction().unsetTransactionCaching(); 201 pcs.firePropertyChange("transactionXACachingTransaction", !set, set); 202 } 203 } 204 } 205 206 public boolean isTransactionXACachingThread() { 207 return isTransactionXA() && getManager().getXaTransaction().isSetThreadCaching(); 208 } 209 210 public void setTransactionXACachingThread(boolean set) { 211 if(set) { 212 setTransactionXA(true); 213 if(!getManager().getXaTransaction().isSetThreadCaching()) { 214 getManager().getXaTransaction().addNewThreadCaching(); 215 pcs.firePropertyChange("transactionXACachingThread", !set, set); 216 } 217 } else { 218 if(isTransactionXA() && getManager().getXaTransaction().isSetThreadCaching()) { 219 getManager().getXaTransaction().unsetThreadCaching(); 220 pcs.firePropertyChange("transactionXACachingThread", !set, set); 221 } 222 } 223 } 224 225 public boolean isPoolNone() { 226 return getManager().isSetNoPool(); 227 } 228 229 public void setPoolNone(boolean set) { 230 if(set) { 231 if(!getManager().isSetNoPool()) { 232 getManager().addNewNoPool(); 233 pcs.firePropertyChange("poolNone", !set, set); 234 } 235 if(getPoolSingle() != null) setPoolSingle(null); 236 if(getPoolPartitioned() != null) setPoolPartitioned(null); 237 } else { 238 if(getManager().isSetNoPool()) { 239 getManager().unsetNoPool(); 240 pcs.firePropertyChange("poolNone", !set, set); 241 } 242 if(getPoolSingle() == null && getPoolPartitioned() == null) { 243 setPoolSingle(new SinglePool()); 244 } 245 } 246 } 247 248 public SinglePool getPoolSingle() { 249 return singlePool; 250 } 251 252 public void setPoolSingle(SinglePool pool) { 253 SinglePool old = getPoolSingle(); 254 if(pool != null) { 255 singlePool = pool; 256 if(!getManager().isSetSinglePool()) { 257 getManager().addNewSinglePool(); 258 } 259 singlePool.configure(getManager().getSinglePool()); 260 pcs.firePropertyChange("poolSingle", old, pool); 261 if(isPoolNone()) setPoolNone(false); 262 if(getPoolPartitioned() != null) setPoolPartitioned(null); 263 } else { 264 if(getManager().isSetSinglePool()) { 265 getManager().unsetSinglePool(); 266 pcs.firePropertyChange("poolSingle", old, pool); 267 } 268 } 269 } 270 271 public PartitionedPool getPoolPartitioned() { 272 return partitionedPool; 273 } 274 275 public void setPoolPartitioned(PartitionedPool pool) { 276 PartitionedPool old = getPoolPartitioned(); 277 if(pool != null) { 278 partitionedPool = pool; 279 if(!getManager().isSetPartitionedPool()) { 280 getManager().addNewPartitionedPool(); 281 } 282 partitionedPool.configure(getManager().getPartitionedPool()); 283 pcs.firePropertyChange("poolPartitioned", old, pool); 284 if(isPoolNone()) setPoolNone(false); 285 if(getPoolSingle() != null) setPoolSingle(null); 286 } else { 287 if(getManager().isSetPartitionedPool()) { 288 getManager().unsetPartitionedPool(); 289 pcs.firePropertyChange("poolPartitioned", old, pool); 290 } 291 } 292 } 293 294 296 protected SchemaTypeLoader getSchemaTypeLoader() { 297 return Connector15DCBRoot.SCHEMA_TYPE_LOADER; 298 } 299 } 300 | Popular Tags |