Lines 474-526
Link Here
|
474 |
ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, "DDBean from wrong tree in ensureResourceDefined: " + ddBean); // NOI18N |
474 |
ErrorManager.getDefault().log(ErrorManager.INFORMATIONAL, "DDBean from wrong tree in ensureResourceDefined: " + ddBean); // NOI18N |
475 |
} |
475 |
} |
476 |
} else if("entity".equals(type)) { //NOI18N |
476 |
} else if("entity".equals(type)) { //NOI18N |
477 |
// Find the DConfigBean for this ddBean. This is actually quite complicated since |
477 |
ensureResourceDefinedForEjb(ddBean, null); |
478 |
// the DDBean passed in is from j2eeserver, not from the DDBean tree used and managed |
478 |
} |
479 |
// by the plugin. |
479 |
} |
480 |
BaseEjb theEjbDCB = getEjbDConfigBean(ddBean); |
480 |
|
481 |
|
481 |
public void ensureResourceDefinedForEjb(DDBean ddBean, String jndiName) { |
482 |
if(theEjbDCB == null) { |
482 |
// Find the DConfigBean for this ddBean. This is actually quite complicated since |
483 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("EJB DConfigBean cannot be found for DDBean: " + ddBean)); // NOI18N |
483 |
// the DDBean passed in is from j2eeserver, not from the DDBean tree used and managed |
|
|
484 |
// by the plugin. |
485 |
BaseEjb theEjbDCB = getEjbDConfigBean(ddBean); |
486 |
|
487 |
if(theEjbDCB == null) { |
488 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("EJB DConfigBean cannot be found for DDBean: " + ddBean)); // NOI18N |
489 |
return; |
490 |
} |
491 |
|
492 |
if(theEjbDCB instanceof CmpEntityEjb) { |
493 |
ResourceConfiguratorInterface rci = getResourceConfigurator(); |
494 |
CmpEntityEjb cmpEjbDCB = (CmpEntityEjb) theEjbDCB; |
495 |
|
496 |
if(resourceDir == null) { |
497 |
// Unable to create JDBC data source for CMP. |
498 |
// JNDI name of CMP resource field not set. |
499 |
postResourceError(NbBundle.getMessage(SunONEDeploymentConfiguration.class, |
500 |
"ERR_NoCmpOrJdbcDataSource", cmpEjbDCB.getEjbName())); // NOI18N |
484 |
return; |
501 |
return; |
485 |
} |
502 |
} |
486 |
|
503 |
|
487 |
if(theEjbDCB instanceof CmpEntityEjb) { |
504 |
if (jndiName == null) { |
488 |
ResourceConfiguratorInterface rci = getResourceConfigurator(); |
|
|
489 |
CmpEntityEjb cmpEjbDCB = (CmpEntityEjb) theEjbDCB; |
490 |
|
491 |
if(resourceDir == null) { |
492 |
// Unable to create JDBC data source for CMP. |
493 |
// JNDI name of CMP resource field not set. |
494 |
postResourceError(NbBundle.getMessage(SunONEDeploymentConfiguration.class, |
495 |
"ERR_NoCmpOrJdbcDataSource", cmpEjbDCB.getEjbName())); // NOI18N |
496 |
return; |
497 |
} |
498 |
|
499 |
String description = getField(ddBean, "description"); //NOI18N |
505 |
String description = getField(ddBean, "description"); //NOI18N |
500 |
String jndiName = rci.createJDBCDataSourceForCmp(cmpEjbDCB.getEjbName(), description, resourceDir); |
506 |
jndiName = rci.createJDBCDataSourceForCmp(cmpEjbDCB.getEjbName(), description, resourceDir); |
501 |
|
507 |
} |
502 |
// Set the CmpResource jndi-name if not already defined. |
508 |
|
503 |
if(jndiName != null) { |
509 |
// Set the CmpResource jndi-name if not already defined. |
504 |
Base parentDCB = cmpEjbDCB.getParent(); |
510 |
if(jndiName != null) { |
505 |
if(parentDCB instanceof EjbJarRoot) { |
511 |
Base parentDCB = cmpEjbDCB.getParent(); |
506 |
EjbJarRoot ejbJarRoot = (EjbJarRoot) parentDCB; |
512 |
if(parentDCB instanceof EjbJarRoot) { |
507 |
CmpResource cmpResource = null; |
513 |
EjbJarRoot ejbJarRoot = (EjbJarRoot) parentDCB; |
508 |
if(ejbJarRoot.getCmpResource() == null) { |
514 |
CmpResource cmpResource = null; |
509 |
cmpResource = getStorageFactory().createCmpResource(); |
515 |
if(ejbJarRoot.getCmpResource() == null) { |
510 |
} else { |
516 |
cmpResource = getStorageFactory().createCmpResource(); |
511 |
cmpResource = (CmpResource)ejbJarRoot.getCmpResource().clone(); |
|
|
512 |
} |
513 |
cmpResource.setJndiName(jndiName); |
514 |
try { |
515 |
ejbJarRoot.setCmpResource(cmpResource); |
516 |
} catch(PropertyVetoException ex) { |
517 |
// Should never happen |
518 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); |
519 |
} |
520 |
} else { |
517 |
} else { |
|
|
518 |
cmpResource = (CmpResource)ejbJarRoot.getCmpResource().clone(); |
519 |
} |
520 |
cmpResource.setJndiName(jndiName); |
521 |
try { |
522 |
ejbJarRoot.setCmpResource(cmpResource); |
523 |
} catch(PropertyVetoException ex) { |
521 |
// Should never happen |
524 |
// Should never happen |
522 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("CmpEntityBean DConfigBean parent is of wrong type: " + parentDCB)); // NOI18N |
525 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); |
523 |
} |
526 |
} |
|
|
527 |
} else { |
528 |
// Should never happen |
529 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("CmpEntityBean DConfigBean parent is of wrong type: " + parentDCB)); // NOI18N |
524 |
} |
530 |
} |
525 |
} |
531 |
} |
526 |
} |
532 |
} |