1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean; 26 27 import org.netbeans.modules.j2ee.sun.dd.api.DDProvider; 28 import org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException; 29 30 import org.netbeans.modules.j2ee.sun.dd.api.app.SunApplication; 31 import org.netbeans.modules.j2ee.sun.dd.api.app.Web; 32 import org.netbeans.modules.j2ee.sun.dd.api.client.SunApplicationClient; 33 34 import org.netbeans.modules.j2ee.sun.dd.api.ejb.SunEjbJar; 35 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Cmp; 36 import org.netbeans.modules.j2ee.sun.dd.api.ejb.CmpResource; 37 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Ejb; 38 import org.netbeans.modules.j2ee.sun.dd.api.ejb.EnterpriseBeans; 39 import org.netbeans.modules.j2ee.sun.dd.api.ejb.ActivationConfig; 40 import org.netbeans.modules.j2ee.sun.dd.api.ejb.ActivationConfigProperty; 41 import org.netbeans.modules.j2ee.sun.dd.api.ejb.MdbConnectionFactory; 42 import org.netbeans.modules.j2ee.sun.dd.api.ejb.MdbResourceAdapter; 43 import org.netbeans.modules.j2ee.sun.dd.api.ejb.AsContext; 44 import org.netbeans.modules.j2ee.sun.dd.api.ejb.BeanCache; 45 import org.netbeans.modules.j2ee.sun.dd.api.ejb.BeanPool; 46 import org.netbeans.modules.j2ee.sun.dd.api.ejb.IorSecurityConfig; 47 import org.netbeans.modules.j2ee.sun.dd.api.ejb.SasContext; 48 import org.netbeans.modules.j2ee.sun.dd.api.ejb.TransportConfig; 49 import org.netbeans.modules.j2ee.sun.dd.api.ejb.PmInuse; 50 import org.netbeans.modules.j2ee.sun.dd.api.ejb.PmDescriptor; 51 import org.netbeans.modules.j2ee.sun.dd.api.ejb.PmDescriptors; 52 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Finder; 53 import org.netbeans.modules.j2ee.sun.dd.api.ejb.OneOneFinders; 54 import org.netbeans.modules.j2ee.sun.dd.api.ejb.PropertyElement; 55 56 import org.netbeans.modules.j2ee.sun.dd.api.web.SunWebApp; 57 import org.netbeans.modules.j2ee.sun.dd.api.web.Servlet; 58 import org.netbeans.modules.j2ee.sun.dd.api.web.JspConfig; 59 import org.netbeans.modules.j2ee.sun.dd.api.web.LocaleCharsetInfo; 60 import org.netbeans.modules.j2ee.sun.dd.api.web.LocaleCharsetMap; 61 import org.netbeans.modules.j2ee.sun.dd.api.web.WebProperty; 62 import org.netbeans.modules.j2ee.sun.dd.api.web.Cache; 63 import org.netbeans.modules.j2ee.sun.dd.api.web.CacheMapping; 64 import org.netbeans.modules.j2ee.sun.dd.api.web.CacheHelper; 65 import org.netbeans.modules.j2ee.sun.dd.api.web.ConstraintField; 66 import org.netbeans.modules.j2ee.sun.dd.api.web.DefaultHelper; 67 import org.netbeans.modules.j2ee.sun.dd.api.web.SessionConfig; 68 import org.netbeans.modules.j2ee.sun.dd.api.web.SessionManager; 69 import org.netbeans.modules.j2ee.sun.dd.api.web.ManagerProperties; 70 import org.netbeans.modules.j2ee.sun.dd.api.web.StoreProperties; 71 import org.netbeans.modules.j2ee.sun.dd.api.web.SessionProperties; 72 import org.netbeans.modules.j2ee.sun.dd.api.web.CookieProperties; 73 74 import org.netbeans.modules.j2ee.sun.dd.api.common.DefaultResourcePrincipal; 75 import org.netbeans.modules.j2ee.sun.dd.api.common.EjbRef; 76 import org.netbeans.modules.j2ee.sun.dd.api.common.LoginConfig; 77 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageDestination; 78 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageDestinationRef; 79 import org.netbeans.modules.j2ee.sun.dd.api.common.PortInfo; 80 import org.netbeans.modules.j2ee.sun.dd.api.common.WsdlPort; 81 import org.netbeans.modules.j2ee.sun.dd.api.common.CallProperty; 82 import org.netbeans.modules.j2ee.sun.dd.api.common.StubProperty; 83 import org.netbeans.modules.j2ee.sun.dd.api.common.ResourceEnvRef; 84 import org.netbeans.modules.j2ee.sun.dd.api.common.ResourceRef; 85 import org.netbeans.modules.j2ee.sun.dd.api.common.ServiceRef; 86 import org.netbeans.modules.j2ee.sun.dd.api.common.SecurityRoleMapping; 87 import org.netbeans.modules.j2ee.sun.dd.api.common.WebserviceEndpoint; 88 import org.netbeans.modules.j2ee.sun.dd.api.common.WebserviceDescription; 89 90 import org.netbeans.modules.j2ee.sun.dd.api.common.JavaMethod; 91 import org.netbeans.modules.j2ee.sun.dd.api.common.Message; 92 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageSecurity; 93 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageSecurityBinding; 94 import org.netbeans.modules.j2ee.sun.dd.api.common.MethodParams; 95 import org.netbeans.modules.j2ee.sun.dd.api.ejb.CheckpointAtEndOfMethod; 96 import org.netbeans.modules.j2ee.sun.dd.api.ejb.FlushAtEndOfMethod; 97 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Method; 98 import org.netbeans.modules.j2ee.sun.dd.api.ejb.PrefetchDisabled; 99 import org.netbeans.modules.j2ee.sun.dd.api.ejb.QueryMethod; 100 import org.openide.ErrorManager; 101 102 111 public class StorageBeanFactory { 112 113 private static StorageBeanFactory ASDD_7_0_FACTORY; 114 private static StorageBeanFactory ASDD_8_0_FACTORY; 115 private static StorageBeanFactory ASDD_8_1_FACTORY; 116 private static StorageBeanFactory ASDD_9_0_FACTORY; 117 118 static { 119 try { 120 ASDD_7_0_FACTORY = new StorageBeanFactory(ASDDVersion.SUN_APPSERVER_7_0); 121 } catch(Exception ex) { 122 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 123 } 124 try { 125 ASDD_8_0_FACTORY = new StorageBeanFactory(ASDDVersion.SUN_APPSERVER_8_0); 126 } catch(Exception ex) { 127 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 128 } 129 try { 130 ASDD_8_1_FACTORY = new StorageBeanFactory(ASDDVersion.SUN_APPSERVER_8_1); 131 } catch(Exception ex) { 132 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 133 } 134 try { 135 ASDD_9_0_FACTORY = new StorageBeanFactory(ASDDVersion.SUN_APPSERVER_9_0); 136 } catch(Exception ex) { 137 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 138 } 139 } 140 141 143 public static StorageBeanFactory getStorageBeanFactory(ASDDVersion asVersion) { 144 StorageBeanFactory result = ASDD_9_0_FACTORY; 146 if(ASDDVersion.SUN_APPSERVER_9_0.equals(asVersion)) { 147 result = ASDD_9_0_FACTORY; 148 } else if(ASDDVersion.SUN_APPSERVER_8_1.equals(asVersion)) { 149 result = ASDD_8_1_FACTORY; 150 } else if(ASDDVersion.SUN_APPSERVER_8_0.equals(asVersion)) { 151 result = ASDD_8_0_FACTORY; 152 } else if(ASDDVersion.SUN_APPSERVER_7_0.equals(asVersion)) { 153 result = ASDD_7_0_FACTORY; 154 } 155 156 return result; 157 } 158 159 private DDProvider provider; 161 162 private ASDDVersion appServerVersion; 164 165 private SunApplication sunApplication; 169 170 private SunApplicationClient sunAppClient; 172 173 private SunEjbJar sunEjbJar; 175 private EnterpriseBeans enterpriseBeans; 176 private Ejb ejb; 177 private WebserviceEndpoint ejbHostedWebserviceEndpoint; 178 private MdbResourceAdapter mdbResourceAdapter; 179 private ActivationConfig activationConfig; 180 private IorSecurityConfig iorSecurityConfig; 181 private PmDescriptors pmDescriptors; 182 private Cmp cmp; 183 private OneOneFinders oneOneFinders; 184 private CmpResource cmpResource; 185 186 private SunWebApp sunWebApp; 188 private Servlet servlet; 189 private Cache webAppCache; 190 private CacheMapping cacheMapping; 191 private SessionConfig sessionConfig; 192 private SessionManager sessionManager; 193 private LocaleCharsetInfo localeCharsetInfo; 194 private WebserviceEndpoint webHostedWebserviceEndpoint; 195 196 private ResourceRef resourceRef; 198 private ServiceRef serviceRef; 199 private PortInfo portInfo; 200 201 private MessageSecurityBinding messageSecurityBinding; 202 private MessageSecurity messageSecurity; 203 private Message message; 204 private FlushAtEndOfMethod flushAtEndOfMethod; 205 private Method method; 206 private PrefetchDisabled prefetchDisabled; 207 208 private StorageBeanFactory(ASDDVersion asVersion) { 209 appServerVersion = asVersion; 210 provider = DDProvider.getDefault(); 211 212 sunApplication = (SunApplication) provider.newGraph(SunApplication.class, asVersion.getApplicationVersionAsString()); 213 sunEjbJar = (SunEjbJar) provider.newGraph(SunEjbJar.class, asVersion.getEjbJarVersionAsString()); 214 sunWebApp = (SunWebApp) provider.newGraph(SunWebApp.class, asVersion.getWebAppVersionAsString()); 215 sunAppClient = (SunApplicationClient) provider.newGraph(SunApplicationClient.class, asVersion.getAppClientVersionAsString()); 216 217 initSubFields(); 218 } 219 220 private void initSubFields() { 221 enterpriseBeans = sunEjbJar.newEnterpriseBeans(); 222 ejb = enterpriseBeans.newEjb(); 223 mdbResourceAdapter = ejb.newMdbResourceAdapter(); 224 if(mdbResourceAdapter != null) { 225 activationConfig = mdbResourceAdapter.newActivationConfig(); 226 } 227 iorSecurityConfig = ejb.newIorSecurityConfig(); 228 pmDescriptors = enterpriseBeans.newPmDescriptors(); 229 cmpResource = enterpriseBeans.newCmpResource(); 230 cmp = ejb.newCmp(); 231 oneOneFinders = cmp.newOneOneFinders(); 232 233 try { 234 prefetchDisabled = cmp.newPrefetchDisabled(); 235 } catch(VersionNotSupportedException e){ 236 } 237 238 servlet = sunWebApp.newServlet(); 239 webAppCache = sunWebApp.newCache(); 240 cacheMapping = webAppCache.newCacheMapping(); 241 sessionConfig = sunWebApp.newSessionConfig(); 242 sessionManager = sessionConfig.newSessionManager(); 243 localeCharsetInfo = sunWebApp.newLocaleCharsetInfo(); 244 webHostedWebserviceEndpoint = servlet.newWebserviceEndpoint(); 245 246 resourceRef = sunWebApp.newResourceRef(); 247 serviceRef = sunWebApp.newServiceRef(); 248 if(serviceRef != null) { 249 portInfo = serviceRef.newPortInfo(); 250 } 251 ejbHostedWebserviceEndpoint = ejb.newWebserviceEndpoint(); 252 253 try { 254 if(ejbHostedWebserviceEndpoint != null) { 255 messageSecurityBinding = ejbHostedWebserviceEndpoint.newMessageSecurityBinding(); 256 messageSecurity = messageSecurityBinding.newMessageSecurity(); 257 message = messageSecurity.newMessage(); 258 } 259 flushAtEndOfMethod = ejb.newFlushAtEndOfMethod(); 260 method = flushAtEndOfMethod.newMethod(); 261 } catch(VersionNotSupportedException e){ 262 } 263 } 264 265 public SunApplicationClient createSunApplicationClient() { 267 return (SunApplicationClient) provider.newGraph( 268 SunApplicationClient.class, appServerVersion.getAppClientVersionAsString()); 269 } 270 271 public SunApplication createSunApplication() { 273 return (SunApplication) provider.newGraph( 274 SunApplication.class, appServerVersion.getApplicationVersionAsString()); 275 } 276 277 public Web createWeb() { 278 return sunApplication.newWeb(); 279 } 280 281 public SunEjbJar createSunEjbJar() { 283 return (SunEjbJar) provider.newGraph( 284 SunEjbJar.class, appServerVersion.getEjbJarVersionAsString()); 285 } 286 287 public EnterpriseBeans createEnterpriseBeans() { 288 return sunEjbJar.newEnterpriseBeans(); 289 } 290 291 public Ejb createEjb() { 292 return enterpriseBeans.newEjb(); 293 } 294 295 public Cmp createCmp() { 296 return ejb.newCmp(); 297 } 298 299 public CmpResource createCmpResource() { 300 return enterpriseBeans.newCmpResource(); 301 } 302 303 public BeanPool createBeanPool() { 304 return ejb.newBeanPool(); 305 } 306 307 public BeanCache createBeanCache() { 308 return ejb.newBeanCache(); 309 } 310 311 public ActivationConfig createActivationConfig() { 312 return mdbResourceAdapter.newActivationConfig(); 313 } 314 315 public ActivationConfigProperty createActivationConfigProperty() { 316 return activationConfig.newActivationConfigProperty(); 317 } 318 319 public MdbConnectionFactory createMdbConnectionFactory() { 320 return ejb.newMdbConnectionFactory(); 321 } 322 323 public MdbResourceAdapter createMdbResourceAdapter() { 324 return ejb.newMdbResourceAdapter(); 325 } 326 327 public IorSecurityConfig createIorSecurityConfig() { 328 return ejb.newIorSecurityConfig(); 329 } 330 331 public AsContext createAsContext() { 332 return iorSecurityConfig.newAsContext(); 333 } 334 335 public TransportConfig createTransportConfig() { 336 return iorSecurityConfig.newTransportConfig(); 337 } 338 339 public SasContext createSasContext() { 340 return iorSecurityConfig.newSasContext(); 341 } 342 343 public DefaultResourcePrincipal createDefaultResourcePrincipal() { 344 return resourceRef.newDefaultResourcePrincipal(); 345 } 346 347 public PmInuse createPmInuse() { 348 return pmDescriptors.newPmInuse(); 349 } 350 351 public PmDescriptor createPmDescriptor() { 352 return pmDescriptors.newPmDescriptor(); 353 } 354 355 public PmDescriptors createPmDescriptors() { 356 return enterpriseBeans.newPmDescriptors(); 357 } 358 359 public PropertyElement createPropertyElement() { 360 return cmpResource.newPropertyElement(); 361 } 362 363 public Finder createFinder() { 364 return oneOneFinders.newFinder(); 365 } 366 367 public SunWebApp createSunWebApp() { 369 return (SunWebApp) provider.newGraph( 370 SunWebApp.class, appServerVersion.getWebAppVersionAsString()); 371 } 372 373 public Servlet createServlet() { 374 return sunWebApp.newServlet(); 375 } 376 377 public JspConfig createJspConfig() { 378 return sunWebApp.newJspConfig(); 379 } 380 381 public LocaleCharsetInfo createLocaleCharsetInfo() { 382 return sunWebApp.newLocaleCharsetInfo(); 383 } 384 385 public LocaleCharsetMap createLocaleCharsetMap() { 386 return localeCharsetInfo.newLocaleCharsetMap(); 387 } 388 389 public WebProperty createWebProperty() { 390 return sunWebApp.newWebProperty(); 391 } 392 393 public Cache createCache() { 394 return sunWebApp.newCache(); 395 } 396 397 public Cache createCache_NoDefaults() { 398 Cache cache = createCache(); 399 400 cache.setMaxEntries(null); 402 cache.setEnabled(null); 403 cache.setTimeoutInSeconds(null); 404 405 return cache; 406 } 407 408 public CacheMapping createCacheMapping() { 409 return webAppCache.newCacheMapping(); 410 } 411 412 public CacheMapping createCacheMapping_NoDefaults() { 413 CacheMapping cacheMapping = createCacheMapping(); 414 415 cacheMapping.setTimeoutScope(null); 417 cacheMapping.setRefreshFieldScope(null); 418 419 return cacheMapping; 420 } 421 422 public ConstraintField createConstraintField() { 423 return cacheMapping.newConstraintField(); 424 } 425 426 public DefaultHelper createDefaultHelper() { 427 return webAppCache.newDefaultHelper(); 428 } 429 430 public CacheHelper createCacheHelper() { 431 return webAppCache.newCacheHelper(); 432 } 433 434 public SessionConfig createSessionConfig() { 435 return sunWebApp.newSessionConfig(); 436 } 437 438 public SessionManager createSessionManager() { 439 return sessionConfig.newSessionManager(); 440 } 441 442 public ManagerProperties createManagerProperties() { 443 return sessionManager.newManagerProperties(); 444 } 445 446 public StoreProperties createStoreProperties() { 447 return sessionManager.newStoreProperties(); 448 } 449 450 public SessionProperties createSessionProperties() { 451 return sessionConfig.newSessionProperties(); 452 } 453 454 public CookieProperties createCookieProperties() { 455 return sessionConfig.newCookieProperties(); 456 } 457 458 460 public EjbRef createEjbRef() { 466 return sunWebApp.newEjbRef(); 467 } 468 469 public MessageDestination createMessageDestination() { 470 return sunWebApp.newMessageDestination(); 471 } 472 473 public MessageDestinationRef createMessageDestinationRef() { 474 try { 475 return sunWebApp.newMessageDestinationRef(); 476 } catch (VersionNotSupportedException ex) { 477 } 478 return null; 479 } 480 481 public PortInfo createPortInfo() { 482 return serviceRef.newPortInfo(); 483 } 484 485 public CallProperty createCallProperty() { 486 return portInfo.newCallProperty(); 487 } 488 489 public StubProperty createStubProperty() { 490 return portInfo.newStubProperty(); 491 } 492 493 public ResourceEnvRef createResourceEnvRef() { 494 return sunWebApp.newResourceEnvRef(); 495 } 496 497 public ResourceRef createResourceRef() { 498 return sunWebApp.newResourceRef(); 499 } 500 501 public SecurityRoleMapping createSecurityRoleMapping() { 502 return sunWebApp.newSecurityRoleMapping(); 503 } 504 505 public ServiceRef createServiceRef() { 506 return sunWebApp.newServiceRef(); 507 } 508 509 public WebserviceDescription createWebserviceDescription() { 510 return sunWebApp.newWebserviceDescription(); 511 } 512 513 public WebserviceEndpoint createWebHostedWebserviceEndpoint() { 514 WebserviceEndpoint endpoint = servlet.newWebserviceEndpoint(); 516 return endpoint; 519 } 520 521 public WebserviceEndpoint createEjbHostedWebserviceEndpoint() { 522 WebserviceEndpoint endpoint = ejb.newWebserviceEndpoint(); 524 return endpoint; 527 } 528 529 public LoginConfig createWebHostedLoginConfig() { 530 return webHostedWebserviceEndpoint.newLoginConfig(); 531 } 532 533 public LoginConfig createEjbHostedLoginConfig() { 534 return ejbHostedWebserviceEndpoint.newLoginConfig(); 535 } 536 537 public WsdlPort createWsdlPort() { 538 return portInfo.newWsdlPort(); 539 } 540 541 public JavaMethod createJavaMethod() { 542 return message.newJavaMethod(); 543 } 544 545 public Message createMessage() { 546 return messageSecurity.newMessage(); 547 } 548 549 550 public MessageSecurityBinding createMessageSecurityBinding() { 551 try { 552 return ejbHostedWebserviceEndpoint.newMessageSecurityBinding(); 553 } catch(VersionNotSupportedException ex){ 554 } 555 return null; 556 } 557 558 public MethodParams createMethodParams() { 559 return method.newMethodParams(); 560 } 561 562 public MessageSecurity createMessageSecurity() { 563 return messageSecurityBinding.newMessageSecurity(); 564 } 565 566 567 public FlushAtEndOfMethod createFlushAtEndOfMethod() { 568 try { 569 return ejb.newFlushAtEndOfMethod(); 570 } catch(VersionNotSupportedException ex){ 571 } 572 return null; 573 } 574 575 576 public CheckpointAtEndOfMethod createCheckpointAtEndOfMethod() { 577 try { 578 return ejb.newCheckpointAtEndOfMethod(); 579 } catch(VersionNotSupportedException ex){ 580 } 581 return null; 582 } 583 584 585 public Method createMethod() { 586 return flushAtEndOfMethod.newMethod(); 587 } 588 589 590 public PrefetchDisabled createPrefetchDisabled() { 591 try { 592 return cmp.newPrefetchDisabled(); 593 } catch(VersionNotSupportedException e){ 594 } 595 return null; 596 } 597 598 599 public QueryMethod createQueryMethod() { 600 return prefetchDisabled.newQueryMethod(); 601 } 602 } 603 | Popular Tags |