You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2004/05/26 05:20:50 UTC
cvs commit: incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment EARConfigBuilder.java EARContext.java
dain 2004/05/25 20:20:49
Modified: modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment
EARConfigBuilder.java EARContext.java
Log:
Added helper methods to EARContext
Revision Changes Path
1.2 +13 -22 incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Index: EARConfigBuilder.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EARConfigBuilder.java 19 May 2004 20:53:59 -0000 1.1
+++ EARConfigBuilder.java 26 May 2004 03:20:49 -0000 1.2
@@ -166,9 +166,9 @@
// Create the output ear context
JarOutputStream os = new JarOutputStream(new BufferedOutputStream(fos));
- EARContext context = null;
+ EARContext earContext = null;
try {
- context = new EARContext(os, configId, parentId, kernel, j2eeDomainName, j2eeServerName, applicationName);
+ earContext = new EARContext(os, configId, parentId, kernel, j2eeDomainName, j2eeServerName, applicationName);
} catch (MalformedObjectNameException e) {
throw new DeploymentException(e);
}
@@ -177,50 +177,41 @@
for (Enumeration enum = earFile.entries(); enum.hasMoreElements();) {
ZipEntry entry = (ZipEntry) enum.nextElement();
if (!moduleLocations.contains(entry.getName())) {
- context.addFile(URI.create(entry.getName()), earFile.getInputStream(entry));
+ earContext.addFile(URI.create(entry.getName()), earFile.getInputStream(entry));
}
}
// each module installs it's files into the output context.. this is differenct for each module type
for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
Module module = (Module) iterator.next();
- getBuilder(module).installModule(earFile, context, module);
+ getBuilder(module).installModule(earFile, earContext, module);
}
- // give each module a chance to populate the context now that a classloader is available
- ClassLoader cl = context.getClassLoader(repository);
+ // give each module a chance to populate the earContext now that a classloader is available
+ ClassLoader cl = earContext.getClassLoader(repository);
for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
Module module = (Module) iterator.next();
- getBuilder(module).initContext(context, module, cl);
+ getBuilder(module).initContext(earContext, module, cl);
}
// Create the J2EEApplication managed object
- GBeanMBean gbean = new GBeanMBean(J2EEApplicationImpl.GBEAN_INFO);
if (application != null) {
+ GBeanMBean gbean = new GBeanMBean(J2EEApplicationImpl.GBEAN_INFO);
try {
gbean.setAttribute("deploymentDescriptor", application.toString());
} catch (Exception e) {
throw new DeploymentException("Error initializing J2EEApplication managed object");
}
+ gbean.setReferencePatterns("j2eeServer", Collections.singleton(j2eeServer));
+ earContext.addGBean(earContext.getApplicationObjectName(), gbean);
}
- gbean.setReferencePatterns("j2eeServer", Collections.singleton(j2eeServer));
- Properties hashMap = new Properties();
- hashMap.put("j2eeType", "J2EEApplication");
- hashMap.put("name", applicationName);
- hashMap.put("J2EEServer", j2eeServerName);
- try {
- context.addGBean(new ObjectName(j2eeDomainName, hashMap), gbean);
- } catch (MalformedObjectNameException e) {
- throw new DeploymentException("Invalid J2EEServer name", e);
- }
-
// each module can now add it's GBeans
for (Iterator iterator = modules.iterator(); iterator.hasNext();) {
Module module = (Module) iterator.next();
- getBuilder(module).addGBeans(context, module, cl);
+ getBuilder(module).addGBeans(earContext, module, cl);
}
- context.close();
+ earContext.close();
os.flush();
} finally {
if (earFile != null) {
1.2 +49 -4 incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java
Index: EARContext.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EARContext.java 19 May 2004 20:53:59 -0000 1.1
+++ EARContext.java 26 May 2004 03:20:49 -0000 1.2
@@ -20,8 +20,10 @@
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
import java.util.jar.JarOutputStream;
import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
import org.apache.geronimo.deployment.DeploymentContext;
import org.apache.geronimo.deployment.DeploymentException;
@@ -33,15 +35,46 @@
public class EARContext extends DeploymentContext {
private final Map ejbRefs = new HashMap();
private final Map ejbLocalRefs = new HashMap();
- private String j2eeDomainName;
- private String j2eeServerName;
- private String j2eeApplicationName;
+ private final String j2eeDomainName;
+ private final String j2eeServerName;
+ private final String j2eeApplicationName;
+ private final ObjectName domainObjectName;
+ private final ObjectName serverObjectName;
+ private final ObjectName applicationObjectName;
public EARContext(JarOutputStream jos, URI id, URI parentID, Kernel kernel, String j2eeDomainName, String j2eeServerName, String j2eeApplicationName) throws MalformedObjectNameException, DeploymentException {
super(jos, id, parentID, kernel);
this.j2eeDomainName = j2eeDomainName;
this.j2eeServerName = j2eeServerName;
this.j2eeApplicationName = j2eeApplicationName;
+
+ Properties domainNameProps = new Properties();
+ domainNameProps.put("j2eeType", "J2EEDomain");
+ domainNameProps.put("name", j2eeDomainName);
+ try {
+ domainObjectName = new ObjectName(j2eeDomainName, domainNameProps);
+ } catch (MalformedObjectNameException e) {
+ throw new DeploymentException("Unable to construct J2EEDomain ObjectName", e);
+ }
+
+ Properties serverNameProps = new Properties();
+ serverNameProps.put("j2eeType", "J2EEServer");
+ serverNameProps.put("name", j2eeServerName);
+ try {
+ serverObjectName = new ObjectName(j2eeDomainName, serverNameProps);
+ } catch (MalformedObjectNameException e) {
+ throw new DeploymentException("Unable to construct J2EEServer ObjectName", e);
+ }
+
+ Properties applicationNameProps = new Properties();
+ applicationNameProps.put("j2eeType", "J2EEApplication");
+ applicationNameProps.put("name", j2eeApplicationName);
+ applicationNameProps.put("J2EEServer", j2eeServerName);
+ try {
+ applicationObjectName = new ObjectName(j2eeDomainName, applicationNameProps);
+ } catch (MalformedObjectNameException e) {
+ throw new DeploymentException("Unable to construct J2EEApplication ObjectName", e);
+ }
}
public String getJ2EEDomainName() {
@@ -54,6 +87,18 @@
public String getJ2EEApplicationName() {
return j2eeApplicationName;
+ }
+
+ public ObjectName getDomainObjectName() {
+ return domainObjectName;
+ }
+
+ public ObjectName getServerObjectName() {
+ return serverObjectName;
+ }
+
+ public ObjectName getApplicationObjectName() {
+ return applicationObjectName;
}
public void addEJBRef(URI modulePath, String name, Object reference) throws DeploymentException {