dain 2004/09/28 14:53:11
Modified: modules/core/src/java/org/openejb/deployment
OpenEJBModuleBuilder.java
Log:
Modified module builders to return the object name of the module j2ee management
object
ObjectNames are used as the basis of the TargetModuleID to create a hierarchy or
deployed modules
Split createModule method of module builder into a version for stand alone modules
and a version for modules contained in an ear
Revision Changes Path
1.33 +33 -21
openejb/modules/core/src/java/org/openejb/deployment/OpenEJBModuleBuilder.java
Index: OpenEJBModuleBuilder.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/deployment/OpenEJBModuleBuilder.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- OpenEJBModuleBuilder.java 28 Sep 2004 07:09:39 -0000 1.32
+++ OpenEJBModuleBuilder.java 28 Sep 2004 18:53:11 -0000 1.33
@@ -123,24 +123,38 @@
return securityBuilder;
}
- public Module createModule(String name, Object plan, JarFile moduleFile, URL
ejbJarXmlUrl, String targetPath) throws DeploymentException {
+ public Module createModule(File plan, JarFile moduleFile) throws
DeploymentException {
+ return createModule(plan, moduleFile, "war", null, true);
+ }
+
+ public Module createModule(Object plan, JarFile moduleFile, String targetPath,
URL specDDUrl) throws DeploymentException {
+ return createModule(plan, moduleFile, targetPath, specDDUrl, false);
+ }
+
+ private Module createModule(Object plan, JarFile moduleFile, String targetPath,
URL specDDUrl, boolean standAlone) throws DeploymentException {
+ assert moduleFile != null: "moduleFile is null";
+ assert targetPath != null: "targetPath is null";
+ assert !targetPath.endsWith("/"): "targetPath must not end with a '/'";
+
String specDD;
EjbJarType ejbJar;
try {
- if (ejbJarXmlUrl == null) {
- ejbJarXmlUrl = JarUtil.createJarURL(moduleFile,
"META-INF/ejb-jar.xml");
+ if (specDDUrl == null) {
+ specDDUrl = JarUtil.createJarURL(moduleFile,
"META-INF/ejb-jar.xml");
}
- specDD = IOUtil.readAll(ejbJarXmlUrl);
+ // read in the entire specDD as a string, we need this for
getDeploymentDescriptor
+ // on the J2ee management object
+ specDD = IOUtil.readAll(specDDUrl);
- // check if we have an alt spec dd
+ // parse it
EjbJarDocument ejbJarDoc =
SchemaConversionUtils.convertToEJBSchema(SchemaConversionUtils.parse(specDD));
ejbJar = ejbJarDoc.getEjbJar();
} catch (Exception e) {
return null;
}
- OpenejbOpenejbJarType openejbJar = getOpenejbJar(plan, moduleFile, name,
ejbJar);
+ OpenejbOpenejbJarType openejbJar = getOpenejbJar(plan, moduleFile,
standAlone, targetPath, ejbJar);
// get the ids from either the application plan or for a stand alone module
from the specific deployer
URI configId = null;
@@ -159,21 +173,10 @@
}
}
- URI moduleURI;
- if (targetPath != null) {
- moduleURI = URI.create(targetPath);
- if (targetPath.endsWith("/")) {
- throw new DeploymentException("targetPath must not end with a '/'");
- }
- } else {
- targetPath = "ejb.jar";
- moduleURI = URI.create("");
- }
-
- return new EJBModule(name, configId, parentId, moduleURI, moduleFile,
targetPath, ejbJar, openejbJar, specDD);
+ return new EJBModule(standAlone, configId, parentId, moduleFile,
targetPath, ejbJar, openejbJar, specDD);
}
- OpenejbOpenejbJarType getOpenejbJar(Object plan, JarFile moduleFile, String
name, EjbJarType ejbJar) throws DeploymentException {
+ OpenejbOpenejbJarType getOpenejbJar(Object plan, JarFile moduleFile, boolean
standAlone, String targetPath, EjbJarType ejbJar) throws DeploymentException {
OpenejbOpenejbJarType openejbJar = null;
try {
// load the openejb-jar.xml from either the supplied plan or from the
earFile
@@ -203,7 +206,15 @@
openejbJar = (OpenejbOpenejbJarType)
SchemaConversionUtils.convertToGeronimoNamingSchema(openejbJar);
SchemaConversionUtils.validateDD(openejbJar);
} else {
- openejbJar = createDefaultPlan(name, ejbJar);
+ String path;
+ if (standAlone) {
+ // default configId is based on the moduleFile name
+ path = new File(moduleFile.getName()).getName();
+ } else {
+ // default configId is based on the module uri from the
application.xml
+ path = targetPath;
+ }
+ openejbJar = createDefaultPlan(path, ejbJar);
}
} catch (XmlException e) {
throw new DeploymentException(e);
@@ -293,7 +304,7 @@
return sessionBuilder;
}
- public void addGBeans(EARContext earContext, Module module, ClassLoader cl)
throws DeploymentException {
+ public String addGBeans(EARContext earContext, Module module, ClassLoader cl)
throws DeploymentException {
EJBModule ejbModule = (EJBModule) module;
OpenejbOpenejbJarType openejbEjbJar = (OpenejbOpenejbJarType)
module.getVendorDD();
EjbJarType ejbJar = (EjbJarType) module.getSpecDD();
@@ -382,6 +393,7 @@
mdbBuilder.buildBeans(earContext, module, cl, ejbModule, openejbBeans,
transactionPolicyHelper, security, enterpriseBeans);
+ return ejbModuleObjectName.getCanonicalName();
}
public Object createEJBProxyFactory(String containerId, boolean isSessionBean,
String remoteInterfaceName, String homeInterfaceName, String localInterfaceName,
String localHomeInterfaceName, ClassLoader cl) throws DeploymentException {