1 22 package org.jboss.metadata; 23 24 import java.util.Collection ; 25 import java.util.Iterator ; 26 import java.util.LinkedList ; 27 import java.util.List ; 28 29 import org.jboss.deployment.DeploymentException; 30 import org.jboss.mx.util.ObjectNameFactory; 31 import org.w3c.dom.Element ; 32 33 39 public class ConfigurationMetaData extends MetaData 40 { 41 public static final String CMP_2x_13 = "Standard CMP 2.x EntityBean"; 43 public static final String CMP_1x_13 = "Standard CMP EntityBean"; 44 public static final String BMP_13 = "Standard BMP EntityBean"; 45 public static final String STATELESS_13 = "Standard Stateless SessionBean"; 46 public static final String STATEFUL_13 = "Standard Stateful SessionBean"; 47 public static final String MESSAGE_DRIVEN_13 = "Standard Message Driven Bean"; 48 public static final String MESSAGE_INFLOW_DRIVEN = "Standard Message Inflow Driven Bean"; 49 50 public static final String CLUSTERED_CMP_2x_13 = "Clustered CMP 2.x EntityBean"; 51 public static final String CLUSTERED_CMP_1x_13 = "Clustered CMP EntityBean"; 52 public static final String CLUSTERED_BMP_13 = "Clustered BMP EntityBean"; 53 public static final String CLUSTERED_STATEFUL_13 = "Clustered Stateful SessionBean"; 54 public static final String CLUSTERED_STATELESS_13 = "Clustered Stateless SessionBean"; 55 56 public static final byte A_COMMIT_OPTION = 0; 57 public static final byte B_COMMIT_OPTION = 1; 58 public static final byte C_COMMIT_OPTION = 2; 59 60 public static final byte D_COMMIT_OPTION = 3; 61 public static final String [] commitOptionStrings = {"A", "B", "C", "D"}; 62 63 private String name; 65 private String instancePool; 66 private String instanceCache; 67 private String persistenceManager; 68 private String webClassLoader = "org.jboss.web.WebClassLoader"; 69 private String lockClass = "org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock"; 70 private byte commitOption; 71 private long optionDRefreshRate = 30000; 72 private boolean callLogging; 73 private boolean syncOnCommitOnly = false; 74 75 private boolean insertAfterEjbPostCreate = false; 76 77 private String securityDomain; 78 79 private String [] invokerNames; 80 81 private Element containerPoolConf; 82 83 private Element containerCacheConf; 84 85 private Element containerInterceptorsConf; 86 87 private Collection depends = new LinkedList (); 88 89 private ClusterConfigMetaData clusterConfig = null; 90 91 private boolean ejbStoreForClean; 92 94 private boolean storeNotFlushed = true; 95 96 98 public ConfigurationMetaData() 100 { 101 } 102 103 public ConfigurationMetaData(String name) 104 { 105 this.name = name; 106 } 107 108 110 public String getName() 111 { 112 return name; 113 } 114 115 public String getInstancePool() 116 { 117 return instancePool; 118 } 119 120 public String getInstanceCache() 121 { 122 return instanceCache; 123 } 124 125 public String getPersistenceManager() 126 { 127 return persistenceManager; 128 } 129 130 public String getSecurityDomain() 131 { 132 return securityDomain; 133 } 134 135 public String [] getInvokers() 136 { 137 return invokerNames; 138 } 139 140 public String getWebClassLoader() 141 { 142 return webClassLoader; 143 } 144 145 public String getLockClass() 146 { 147 return lockClass; 148 } 149 150 public Element getContainerPoolConf() 151 { 152 return containerPoolConf; 153 } 154 155 public Element getContainerCacheConf() 156 { 157 return containerCacheConf; 158 } 159 160 public String getDefaultInvokerName() 161 { 162 if (invokerNames.length == 0) 163 throw new IllegalStateException ("No invokers defined"); 164 return invokerNames[0]; 165 } 166 167 public Element getContainerInterceptorsConf() 168 { 169 return containerInterceptorsConf; 170 } 171 172 public boolean getCallLogging() 173 { 174 return callLogging; 175 } 176 177 public boolean getSyncOnCommitOnly() 178 { 179 return syncOnCommitOnly; 180 } 181 182 public boolean isInsertAfterEjbPostCreate() 183 { 184 return insertAfterEjbPostCreate; 185 } 186 187 public boolean isEjbStoreForClean() 188 { 189 return this.ejbStoreForClean; 190 } 191 192 public boolean isStoreNotFlushed() 193 { 194 return storeNotFlushed; 195 } 196 197 public byte getCommitOption() 198 { 199 return commitOption; 200 } 201 202 public long getOptionDRefreshRate() 203 { 204 return optionDRefreshRate; 205 } 206 207 public ClusterConfigMetaData getClusterConfigMetaData() 208 { 209 return this.clusterConfig; 210 } 211 212 public Collection getDepends() 213 { 214 return depends; 215 } 216 217 public void setName(String name) 218 { 219 this.name = name; 220 } 221 222 public void setInstancePool(String instancePool) 223 { 224 this.instancePool = instancePool; 225 } 226 227 public void setInstanceCache(String instanceCache) 228 { 229 this.instanceCache = instanceCache; 230 } 231 232 public void setPersistenceManager(String persistenceManager) 233 { 234 this.persistenceManager = persistenceManager; 235 } 236 237 public void setWebClassLoader(String webClassLoader) 238 { 239 this.webClassLoader = webClassLoader; 240 } 241 242 public void setCommitOption(String commitOption) 243 { 244 try 245 { 246 this.commitOption = stringToCommitOption(commitOption); 247 } 248 catch(DeploymentException e) 249 { 250 throw new IllegalStateException (e.getMessage()); 251 } 252 } 253 254 public void setOptionDRefreshRate(long optionDRefreshRate) 255 { 256 this.optionDRefreshRate = optionDRefreshRate; 257 } 258 259 public void setCallLogging(boolean callLogging) 260 { 261 this.callLogging = callLogging; 262 } 263 264 public void setSyncOnCommitOnly(boolean syncOnCommitOnly) 265 { 266 this.syncOnCommitOnly = syncOnCommitOnly; 267 } 268 269 public void setInsertAfterEjbPostCreate(boolean insertAfterEjbPostCreate) 270 { 271 this.insertAfterEjbPostCreate = insertAfterEjbPostCreate; 272 } 273 274 public void setSecurityDomain(String securityDomain) 275 { 276 this.securityDomain = securityDomain; 277 } 278 279 public void setInvokerNames(String [] invokerNames) 280 { 281 this.invokerNames = invokerNames; 282 } 283 284 public void setContainerPoolConf(Element containerPoolConf) 285 { 286 this.containerPoolConf = containerPoolConf; 287 } 288 289 public void setContainerCacheConf(Element containerCacheConf) 290 { 291 this.containerCacheConf = containerCacheConf; 292 } 293 294 public void setContainerInterceptorsConf(Element containerInterceptorsConf) 295 { 296 this.containerInterceptorsConf = containerInterceptorsConf; 297 } 298 299 public void setClusterConfig(ClusterConfigMetaData clusterConfig) 300 { 301 this.clusterConfig = clusterConfig; 302 } 303 304 public void setEjbStoreForClean(boolean ejbStoreForClean) 305 { 306 this.ejbStoreForClean = ejbStoreForClean; 307 } 308 309 public void setStoreNotFlushed(boolean storeNotFlushed) 310 { 311 this.storeNotFlushed = storeNotFlushed; 312 } 313 314 public void setLockClass(String lockClass) 315 { 316 this.lockClass = lockClass; 317 } 318 319 public void importJbossXml(Element element) throws DeploymentException 320 { 321 322 325 callLogging = Boolean.valueOf(getElementContent(getOptionalChild(element, "call-logging"), String.valueOf(callLogging))).booleanValue(); 327 328 syncOnCommitOnly = Boolean.valueOf(getElementContent(getOptionalChild(element, "sync-on-commit-only"), String.valueOf(syncOnCommitOnly))).booleanValue(); 330 331 insertAfterEjbPostCreate = Boolean.valueOf(getElementContent(getOptionalChild(element, "insert-after-ejb-post-create"), String.valueOf(insertAfterEjbPostCreate))).booleanValue(); 333 334 ejbStoreForClean = Boolean.valueOf(getElementContent(getOptionalChild(element, "call-ejb-store-on-clean"), String.valueOf(ejbStoreForClean))).booleanValue(); 336 337 storeNotFlushed = Boolean.valueOf(getElementContent(getOptionalChild(element, "store-not-flushed"), String.valueOf(storeNotFlushed))).booleanValue(); 339 340 instancePool = getElementContent(getOptionalChild(element, "instance-pool"), instancePool); 342 343 instanceCache = getElementContent(getOptionalChild(element, "instance-cache"), instanceCache); 345 346 persistenceManager = getElementContent(getOptionalChild(element, "persistence-manager"), persistenceManager); 348 349 webClassLoader = getElementContent(getOptionalChild(element, "web-class-loader"), webClassLoader); 351 352 lockClass = getElementContent(getOptionalChild(element, "locking-policy"), lockClass); 354 355 securityDomain = getElementContent(getOptionalChild(element, "security-domain"), securityDomain); 357 358 List invokers=new java.util.ArrayList (); 360 361 for (Iterator invokerElements = getChildrenByTagName(element, "invoker-proxy-binding-name"); invokerElements.hasNext();) 362 { 363 Element invokerElement = (Element ) invokerElements.next(); 364 String invokerName = getElementContent(invokerElement); 365 invokers.add(invokerName); 366 } invokerNames=(String []) invokers.toArray(new String [invokers.size()]); 368 369 String commit = getElementContent(getOptionalChild(element, "commit-option"), commitOptionToString(commitOption)); 371 372 commitOption = stringToCommitOption(commit); 373 374 String refresh = getElementContent(getOptionalChild(element, "optiond-refresh-rate"), 376 Long.toString(optionDRefreshRate / 1000)); 377 optionDRefreshRate = stringToRefreshRate(refresh); 378 379 382 containerInterceptorsConf = getOptionalChild(element, "container-interceptors", containerInterceptorsConf); 384 385 containerPoolConf = getOptionalChild(element, "container-pool-conf", containerPoolConf); 387 388 containerCacheConf = getOptionalChild(element, "container-cache-conf", containerCacheConf); 390 391 for (Iterator dependsElements = getChildrenByTagName(element, "depends"); dependsElements.hasNext();) 393 { 394 Element dependsElement = (Element ) dependsElements.next(); 395 String dependsName = getElementContent(dependsElement); 396 depends.add(ObjectNameFactory.create(dependsName)); 397 } 399 Element clusterConfigElement = getOptionalChild(element, "cluster-config"); 401 if (clusterConfigElement != null) 402 { 403 clusterConfig = new ClusterConfigMetaData(); 404 clusterConfig.importJbossXml(clusterConfigElement); 405 } 406 } 407 408 410 412 private static String commitOptionToString(byte commitOption) 414 throws DeploymentException 415 { 416 try 417 { 418 return commitOptionStrings[commitOption]; 419 } 420 catch (ArrayIndexOutOfBoundsException e) 421 { 422 throw new DeploymentException("Invalid commit option: " + commitOption); 423 } 424 } 425 426 private static byte stringToCommitOption(String commitOption) 427 throws DeploymentException 428 { 429 for (byte i = 0; i < commitOptionStrings.length; ++i) 430 if (commitOptionStrings[i].equals(commitOption)) 431 return i; 432 433 throw new DeploymentException("Invalid commit option: '" + commitOption + "'"); 434 } 435 436 441 private static long stringToRefreshRate(String refreshRate) 442 throws DeploymentException 443 { 444 try 445 { 446 long rate = Long.parseLong(refreshRate); 447 rate *= 1000; 449 return rate; 450 } 451 catch (Exception e) 452 { 453 throw new DeploymentException("Invalid optiond-refresh-rate '" 454 + refreshRate + "'. Should be a number"); 455 } 456 457 } 458 459 } 461 | Popular Tags |