1 23 24 29 30 package com.sun.enterprise.deployment.runtime; 31 32 import java.util.ArrayList ; 33 import java.util.StringTokenizer ; 34 import java.util.logging.Level ; 35 36 37 import com.sun.enterprise.deployment.Application; 38 import com.sun.enterprise.deployment.EjbDescriptor; 39 import com.sun.enterprise.deployment.MethodDescriptor; 40 import com.sun.enterprise.deployment.DescriptorConstants; 41 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor; 42 import com.sun.enterprise.deployment.util.DOLUtils; 43 44 63 public class IASEjbExtraDescriptors extends RuntimeDescriptor { 64 65 public static final String AVAILABILITY_ENABLED = 66 "AvailabilityEnabled"; 67 68 private boolean isReadOnlyBean; 69 70 77 private int refreshPeriodInSeconds; 78 79 84 private int jmsMaxMessagesLoad; 85 86 private MdbConnectionFactoryDescriptor mdbConnectionFactory; 87 88 92 private String commitOption = null; 93 94 98 private BeanPoolDescriptor beanPool; 99 100 103 private BeanCacheDescriptor beanCache; 104 105 private FlushAtEndOfMethodDescriptor flushMethodDescriptor = null; 106 107 private CheckpointAtEndOfMethodDescriptor checkpointMethodDescriptor = null; 108 109 private String checkpointedMethods = null; 110 111 114 private Boolean passByReference = null; 115 116 117 121 private EjbDescriptor ejbDescriptor = null; 122 123 127 private int cmtTimeoutInSeconds = 0; 128 129 132 private String useThreadPoolId; 133 134 private final static String METHODS_DELIM = ";"; 136 private final static String PARAMS_DELIM = ","; 137 private final static String LEFT_PAREN = "("; 138 private final static String RIGHT_PAREN = ")"; 139 private final static String PARAM_DELIM = " "; 140 141 144 public IASEjbExtraDescriptors() { 145 jmsMaxMessagesLoad = 1; 146 isReadOnlyBean = false; 147 refreshPeriodInSeconds = DescriptorConstants.REFRESH_PERIOD_IN_SECONDS_DEFAULT; } 149 150 154 public BeanCacheDescriptor getBeanCache() { 155 return beanCache; 156 } 157 158 162 public void setBeanCache(BeanCacheDescriptor beanCache) { 163 this.beanCache = beanCache; 164 } 165 166 170 public BeanPoolDescriptor getBeanPool() { 171 return beanPool; 172 } 173 174 178 public void setBeanPool(BeanPoolDescriptor beanPool) { 179 this.beanPool = beanPool; 180 } 181 182 186 public FlushAtEndOfMethodDescriptor getFlushAtEndOfMethodDescriptor() { 187 return flushMethodDescriptor; 188 } 189 190 194 public void setFlushAtEndOfMethodDescriptor( 195 FlushAtEndOfMethodDescriptor flushMethodDescriptor) { 196 this.flushMethodDescriptor = flushMethodDescriptor; 197 } 198 199 203 public CheckpointAtEndOfMethodDescriptor 204 getCheckpointAtEndOfMethodDescriptor() { 205 return checkpointMethodDescriptor; 206 } 207 208 213 public void setCheckpointAtEndOfMethodDescriptor( 214 CheckpointAtEndOfMethodDescriptor checkpointMethodDescriptor) { 215 this.checkpointMethodDescriptor = checkpointMethodDescriptor; 216 } 217 218 222 public String getCheckpointedMethods() { 223 return checkpointedMethods; 224 } 225 226 230 public void setCheckpointedMethods(String checkpointedMethods) { 231 this.checkpointedMethods = checkpointedMethods; 232 } 233 234 238 public java.lang.String getCommitOption() { 239 return commitOption; 240 } 241 242 246 public void setCommitOption(java.lang.String commitOption) { 247 this.commitOption = commitOption; 248 } 249 250 254 public int getCmtTimeoutInSeconds() { 255 return this.cmtTimeoutInSeconds; 256 } 257 258 262 public void setCmtTimeoutInSeconds(int val) { 263 this.cmtTimeoutInSeconds = val; 264 } 265 266 270 public String getUseThreadPoolId() { 271 return this.useThreadPoolId; 272 } 273 274 278 public void setUseThreadPoolId(String val) { 279 this.useThreadPoolId = val; 280 } 281 282 286 public boolean isIsReadOnlyBean() { 287 return isReadOnlyBean; 288 } 289 290 294 public void setIsReadOnlyBean(boolean isReadOnlyBean) { 295 this.isReadOnlyBean = isReadOnlyBean; 296 } 297 298 302 public int getJmsMaxMessagesLoad() { 303 return jmsMaxMessagesLoad; 304 } 305 306 310 public void setJmsMaxMessagesLoad(int jmsMaxMessagesLoad) { 311 this.jmsMaxMessagesLoad = jmsMaxMessagesLoad; 312 } 313 314 318 public MdbConnectionFactoryDescriptor getMdbConnectionFactory() { 319 return mdbConnectionFactory; 320 } 321 322 326 public void setMdbConnectionFactory( 327 MdbConnectionFactoryDescriptor mdbConnectionFactory) { 328 329 this.mdbConnectionFactory = mdbConnectionFactory; 330 } 331 332 336 public int getRefreshPeriodInSeconds() { 337 return refreshPeriodInSeconds; 338 } 339 340 345 public void setRefreshPeriodInSeconds(int refreshPeriodInSeconds) { 346 this.refreshPeriodInSeconds = refreshPeriodInSeconds; 347 } 348 349 355 public boolean getPassByReference() { 356 boolean passByReference = false; 358 if (this.isPassByReferenceDefined()) { 360 passByReference = this.passByReference.booleanValue(); 361 } else { 364 ejbDescriptor = this.getEjbDescriptor(); 365 if (ejbDescriptor != null) { 366 Application application = ejbDescriptor.getApplication(); 367 if (application != null) { 368 if (application.isPassByReferenceDefined()) { 369 passByReference = application.getPassByReference(); 370 } 371 } 372 } 373 } 374 375 return passByReference; 376 } 377 378 382 public void setPassByReference(boolean passByReference) { 383 this.passByReference = Boolean.valueOf(passByReference); 384 } 385 386 390 public void setPassByReference(Boolean passByReference) { 391 this.passByReference = passByReference; 392 } 393 394 399 public boolean isPassByReferenceDefined() { 400 boolean passByReferenceDefined = false; 401 if (this.passByReference != null) { 402 passByReferenceDefined = true; 403 } 404 return passByReferenceDefined; 405 } 406 407 412 public EjbDescriptor getEjbDescriptor() { 413 return this.ejbDescriptor; 414 } 415 416 420 public void setEjbDescriptor(EjbDescriptor ejbDescriptor) { 421 this.ejbDescriptor = ejbDescriptor; 422 } 423 424 430 public boolean isFlushEnabledFor(MethodDescriptor methodDesc) { 431 if (flushMethodDescriptor != null) { 432 return flushMethodDescriptor.isFlushEnabledFor(methodDesc); 433 } 434 return false; 435 } 436 437 451 public void parseCheckpointedMethods(EjbDescriptor ejbDesc) { 452 if (checkpointedMethods == null || 453 checkpointedMethods.trim().length() == 0) { 454 return; 455 } 456 if (checkpointMethodDescriptor == null) { 457 checkpointMethodDescriptor = 458 new CheckpointAtEndOfMethodDescriptor(); 459 setCheckpointAtEndOfMethodDescriptor(checkpointMethodDescriptor); 460 checkpointMethodDescriptor.setEjbDescriptor(ejbDesc); 461 } 462 StringTokenizer methodsTokenizer = 463 new StringTokenizer (checkpointedMethods, METHODS_DELIM); 464 while (methodsTokenizer.hasMoreTokens()) { 465 String method = methodsTokenizer.nextToken().trim(); 467 if (method.length() == 0) { 468 continue; 469 } 470 MethodDescriptor methodDescriptor = 471 parseCheckpointedMethod(method); 472 if (methodDescriptor != null) { 473 checkpointMethodDescriptor.getMethodDescriptors().add( 474 methodDescriptor); 475 } 476 } 477 } 478 479 480 private MethodDescriptor parseCheckpointedMethod (String method) { 482 String methodName, methodParams; 483 ArrayList paramTypeList = new ArrayList (); 484 try { 485 if ( method.indexOf(LEFT_PAREN) != -1 && 486 method.indexOf(RIGHT_PAREN) != -1 ) { 487 int pos = method.indexOf(LEFT_PAREN); 488 int pos2 = method.indexOf(RIGHT_PAREN); 489 methodName = method.substring(0, pos).trim(); 491 if (pos < pos2-1) { 493 methodParams = method.substring(pos+1, pos2).trim(); 494 StringTokenizer paramsTokenizer = 495 new StringTokenizer (methodParams, PARAMS_DELIM); 496 while (paramsTokenizer.hasMoreTokens()) { 497 String param = paramsTokenizer.nextToken().trim(); 499 if (param.length() == 0) { 500 continue; 501 } 502 StringTokenizer paramTokenizer = 503 new StringTokenizer (param, PARAM_DELIM); 504 while (paramTokenizer.hasMoreTokens()) { 505 String paramType = 506 paramTokenizer.nextToken().trim(); 507 if (paramType.length() != 0) { 508 paramTypeList.add(paramType); 509 break; 511 } 512 } 513 } 514 } 515 if (paramTypeList.size() > 0) { 516 String [] paramTypeArray = (String [])paramTypeList.toArray( 517 new String [paramTypeList.size()]); 518 return new MethodDescriptor(methodName, null, 519 paramTypeArray, null); 520 } else { 521 return new MethodDescriptor(methodName, null, null, null); 522 } 523 } else { 524 DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment_badformat_checkpointedmethods", new Object [] {method}); 525 return null; 526 } 527 } catch (Exception e) { 528 e.printStackTrace(); 529 DOLUtils.getDefaultLogger().log(Level.WARNING, "enterprise.deployment_badformat_checkpointedmethods", new Object [] {method}); 532 return null; 533 } 534 } 535 } 536 | Popular Tags |