gdamour 2004/07/21 20:22:53
Modified: modules/deployment/src/java/org/apache/geronimo/deployment DeploymentContext.java modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment EARConfigBuilder.java EARContext.java modules/deployment/src/java/org/apache/geronimo/deployment/service ServiceConfigBuilder.java modules/kernel/src/java/org/apache/geronimo/kernel/config ConfigurationManagerImpl.java Configuration.java ConfigurationInfo.java modules/connector/src/test/org/apache/geronimo/connector/deployment RAR_1_5ConfigBuilderTest.java RAR_1_0ConfigBuilderTest.java modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment EARContextTest.java Added: modules/kernel/src/java/org/apache/geronimo/kernel/config ConfigurationModuleType.java Log: Adds a new attribute to Configuration defining its type (WAR, RAR et cetera). This is used to query the configurations defined by a server by providing a type. Revision Changes Path 1.14 +13 -2 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java Index: DeploymentContext.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- DeploymentContext.java 12 Jul 2004 06:07:52 -0000 1.13 +++ DeploymentContext.java 22 Jul 2004 03:22:53 -0000 1.14 @@ -47,6 +47,7 @@ import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.config.Configuration; import org.apache.geronimo.kernel.config.ConfigurationManager; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.repository.Repository; /** @@ -54,6 +55,10 @@ */ public class DeploymentContext { private final URI configID; + /** + * Identifies the type of configuration (WAR, RAR, EAR et cetera) + */ + private final ConfigurationModuleType type; private final Kernel kernel; private final GBeanMBean config; private final Map gbeans = new HashMap(); @@ -66,8 +71,9 @@ private final ClassLoader parentCL; private final Collection tmpfiles = new ArrayList(); - public DeploymentContext(JarOutputStream jos, URI id, URI parentID, Kernel kernel) throws MalformedObjectNameException, DeploymentException { + public DeploymentContext(JarOutputStream jos, URI id, ConfigurationModuleType type, URI parentID, Kernel kernel) throws MalformedObjectNameException, DeploymentException { this.configID = id; + this.type = type; outputStreams.addLast(jos); this.kernel = kernel; @@ -75,6 +81,7 @@ try { config.setAttribute("ID", id); + config.setAttribute("type", type); config.setAttribute("parentID", parentID); } catch (Exception e) { // we created this GBean ... @@ -119,6 +126,10 @@ return configID; } + public ConfigurationModuleType getType() { + return type; + } + private JarOutputStream getJos() { if (outputStreams.isEmpty()) { throw new IllegalStateException(); 1.14 +30 -1 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- EARConfigBuilder.java 18 Jul 2004 22:04:27 -0000 1.13 +++ EARConfigBuilder.java 22 Jul 2004 03:22:53 -0000 1.14 @@ -52,6 +52,7 @@ import org.apache.geronimo.gbean.jmx.GBeanMBean; import org.apache.geronimo.j2ee.management.impl.J2EEApplicationImpl; import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.repository.Repository; import org.apache.geronimo.xbeans.geronimo.j2ee.GerApplicationDocument; import org.apache.geronimo.xbeans.geronimo.j2ee.GerApplicationType; @@ -241,6 +242,7 @@ try { // get the ids from either the application plan or for a stand alone module from the specific deployer URI configId = getConfigId(plan); + ConfigurationModuleType type = getType(plan); URI parentId = getParentId(plan); // get the modules either the application plan or for a stand alone module from the specific deployer @@ -261,6 +263,7 @@ try { earContext = new EARContext(os, configId, + type, parentId, kernel, j2eeDomainName, @@ -489,6 +492,32 @@ if (connectorConfigBuilder != null) { if (connectorConfigBuilder.canHandlePlan(plan)) { return connectorConfigBuilder.getConfigId(plan); + } + } + + throw new DeploymentException("Could not determine config id"); + } + + private ConfigurationModuleType getType(XmlObject plan) throws DeploymentException { + if (plan instanceof GerApplicationDocument) { + return ConfigurationModuleType.EAR; + } + + if (webConfigBuilder != null) { + if (webConfigBuilder.canHandlePlan(plan)) { + return ConfigurationModuleType.WAR; + } + } + + if (ejbConfigBuilder != null) { + if (ejbConfigBuilder.canHandlePlan(plan)) { + return ConfigurationModuleType.EJB; + } + } + + if (connectorConfigBuilder != null) { + if (connectorConfigBuilder.canHandlePlan(plan)) { + return ConfigurationModuleType.RAR; } } 1.7 +4 -3 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- EARContext.java 18 Jul 2004 22:04:27 -0000 1.6 +++ EARContext.java 22 Jul 2004 03:22:53 -0000 1.7 @@ -29,6 +29,7 @@ import org.apache.geronimo.deployment.DeploymentContext; import org.apache.geronimo.deployment.DeploymentException; import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; /** * @version $Revision$ $Date$ @@ -51,8 +52,8 @@ private final ObjectName transactedTimerName; private final ObjectName nonTransactedTimerName; - public EARContext(JarOutputStream jos, URI id, URI parentID, Kernel kernel, String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, ObjectName transactionContextManagerObjectName, ObjectName connectionTrackerObjectName, ObjectName transactedTimerName, ObjectName nonTransactedTimerName) throws MalformedObjectNameException, DeploymentException { - super(jos, id, parentID, kernel); + public EARContext(JarOutputStream jos, URI id, ConfigurationModuleType moduleType, URI parentID, Kernel kernel, String j2eeDomainName, String j2eeServerName, String j2eeApplicationName, ObjectName transactionContextManagerObjectName, ObjectName connectionTrackerObjectName, ObjectName transactedTimerName, ObjectName nonTransactedTimerName) throws MalformedObjectNameException, DeploymentException { + super(jos, id, moduleType, parentID, kernel); this.j2eeDomainName = j2eeDomainName; this.j2eeServerName = j2eeServerName; 1.16 +3 -2 incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Index: ServiceConfigBuilder.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ServiceConfigBuilder.java 5 Jun 2004 01:40:09 -0000 1.15 +++ ServiceConfigBuilder.java 22 Jul 2004 03:22:53 -0000 1.16 @@ -44,6 +44,7 @@ import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.repository.Repository; import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.XmlBeans; @@ -121,7 +122,7 @@ DeploymentContext context = null; try { - context = new DeploymentContext(os, configID, parentID, kernel); + context = new DeploymentContext(os, configID, ConfigurationModuleType.SERVICE, parentID, kernel); } catch (MalformedObjectNameException e) { throw new DeploymentException(e); } 1.11 +13 -3 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java Index: ConfigurationManagerImpl.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ConfigurationManagerImpl.java 12 Jul 2004 06:07:52 -0000 1.10 +++ ConfigurationManagerImpl.java 22 Jul 2004 03:22:53 -0000 1.11 @@ -26,6 +26,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; + import javax.management.InstanceNotFoundException; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -86,9 +87,18 @@ state = null; } } else { - state = null; + // If the configuration is not loaded by the kernel + // and defined by the store, then it is stopped. + state = State.STOPPED; + } + ConfigurationModuleType type = null; + try { + GBeanMBean bean = store.getConfiguration(configID); + type = (ConfigurationModuleType) bean.getAttribute("type"); + } catch (Exception e) { + log.error(store + " defines configID " + configID + " which can not be loaded."); } - result.add(new ConfigurationInfo(storeName, configID, state)); + result.add(new ConfigurationInfo(storeName, configID, state, type)); } return result; } 1.28 +19 -2 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java Index: Configuration.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- Configuration.java 12 Jul 2004 06:07:52 -0000 1.27 +++ Configuration.java 22 Jul 2004 03:22:53 -0000 1.28 @@ -88,6 +88,10 @@ private final Kernel kernel; private final ObjectName objectName; private final URI id; + /** + * Identifies the type of configuration (WAR, RAR et cetera) + */ + private final ConfigurationModuleType moduleType; private final URI parentID; private final ConfigurationParent parent; private final List classPath; @@ -106,16 +110,18 @@ * only used publically during the deployment process for initial configuration. * * @param id the unique ID of this Configuration + * @param moduleType the module type identifier * @param parent the parent Configuration; may be null * @param classPath a List<URI> of locations that define the codebase for this Configuration * @param gbeanState a byte array contain the Java Serialized form of the GBeans in this Configuration * @param repositories a Collection<Repository> of repositories used to resolve dependencies * @param dependencies a List<URI> of dependencies */ - public Configuration(Kernel kernel, String objectName, URI id, URI parentID, ConfigurationParent parent, List classPath, byte[] gbeanState, Collection repositories, List dependencies) { + public Configuration(Kernel kernel, String objectName, URI id, ConfigurationModuleType moduleType, URI parentID, ConfigurationParent parent, List classPath, byte[] gbeanState, Collection repositories, List dependencies) { this.kernel = kernel; this.objectName = JMXUtil.getObjectName(objectName); this.id = id; + this.moduleType = moduleType; this.parentID = parentID; this.parent = parent; this.gbeanState = gbeanState; @@ -242,6 +248,15 @@ } /** + * Gets the type of the configuration (WAR, RAR et cetera) + * + * @return Type of the configuration. + */ + public ConfigurationModuleType getModuleType() { + return moduleType; + } + + /** * Return the URL that is used to resolve relative classpath locations * * @return the base URL for the classpath @@ -381,6 +396,7 @@ infoFactory.addAttribute("kernel", Kernel.class, false); infoFactory.addAttribute("objectName", String.class, false); infoFactory.addAttribute("ID", URI.class, true); + infoFactory.addAttribute("type", ConfigurationModuleType.class, true); infoFactory.addAttribute("parentID", URI.class, true); infoFactory.addAttribute("classPath", List.class, true); infoFactory.addAttribute("dependencies", List.class, true); @@ -395,6 +411,7 @@ "kernel", "objectName", "ID", + "type", "parentID", "Parent", "classPath", 1.2 +9 -2 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java Index: ConfigurationInfo.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ConfigurationInfo.java 2 Jun 2004 19:50:41 -0000 1.1 +++ ConfigurationInfo.java 22 Jul 2004 03:22:53 -0000 1.2 @@ -31,11 +31,13 @@ private final ObjectName storeName; private final URI configID; private final State state; + private final ConfigurationModuleType type; - public ConfigurationInfo(ObjectName storeName, URI configID, State state) { + public ConfigurationInfo(ObjectName storeName, URI configID, State state, ConfigurationModuleType type) { this.storeName = storeName; this.configID = configID; this.state = state; + this.type = type; } public ObjectName getStoreName() { @@ -49,4 +51,9 @@ public State getState() { return state; } + + public ConfigurationModuleType getType() { + return type; + } + } 1.1 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationModuleType.java Index: ConfigurationModuleType.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.geronimo.kernel.config; import java.io.Serializable; /** * Configuration types. * * @version $Revision: 1.1 $ $Date: 2004/07/22 03:22:53 $ */ public class ConfigurationModuleType implements Serializable { public static final ConfigurationModuleType EAR = new ConfigurationModuleType("EAR", 0); public static final ConfigurationModuleType EJB = new ConfigurationModuleType("EJB", 1); public static final ConfigurationModuleType CAR = new ConfigurationModuleType("CAR", 2); public static final ConfigurationModuleType RAR = new ConfigurationModuleType("RAR", 3); public static final ConfigurationModuleType WAR = new ConfigurationModuleType("WAR", 4); public static final ConfigurationModuleType SERVICE = new ConfigurationModuleType("SERVICE", 5); private static final ConfigurationModuleType[] fromInt = {EAR, EJB, CAR, RAR, WAR, SERVICE}; private final String name; private final int value; public static ConfigurationModuleType getFromValue(int index) { if (index < 0 || index >= fromInt.length) { return null; } return fromInt[index]; } public static ConfigurationModuleType getFromValue(Integer index) { return getFromValue(index.intValue()); } /** * This constructor is intentionally public: this class is not a type-safe * enumeration. */ public ConfigurationModuleType(String name, int value) { this.name = name; this.value = value; } public String getName() { return name; } /** * Gets the identifier of this type. For a configuration associated to * a J2EE ModuleType, this value MUST be equal to ModuleType.getValue(). * * @return */ public int getValue() { return value; } public String toString() { return name; } private Object readResolve() { return fromInt[value]; } } 1.16 +3 -1 incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java Index: RAR_1_5ConfigBuilderTest.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilderTest.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- RAR_1_5ConfigBuilderTest.java 18 Jul 2004 22:08:58 -0000 1.15 +++ RAR_1_5ConfigBuilderTest.java 22 Jul 2004 03:22:53 -0000 1.16 @@ -49,6 +49,7 @@ import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.config.Configuration; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.management.State; import org.apache.geronimo.system.configuration.LocalConfigStore; import org.apache.geronimo.system.serverinfo.ServerInfo; @@ -112,6 +113,7 @@ try { EARContext earContext = new EARContext(new JarOutputStream(new FileOutputStream(carFile)), configId, + ConfigurationModuleType.RAR, parentId, null, j2eeDomainName, 1.11 +3 -1 incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java Index: RAR_1_0ConfigBuilderTest.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- RAR_1_0ConfigBuilderTest.java 18 Jul 2004 22:08:58 -0000 1.10 +++ RAR_1_0ConfigBuilderTest.java 22 Jul 2004 03:22:53 -0000 1.11 @@ -46,6 +46,7 @@ import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.config.Configuration; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; import org.apache.geronimo.kernel.management.State; import org.apache.geronimo.system.configuration.LocalConfigStore; import org.apache.geronimo.system.serverinfo.ServerInfo; @@ -109,6 +110,7 @@ try { EARContext earContext = new EARContext(new JarOutputStream(new FileOutputStream(carFile)), configId, + ConfigurationModuleType.RAR, parentId, null, j2eeDomainName, 1.4 +4 -1 incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARContextTest.java Index: EARContextTest.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARContextTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- EARContextTest.java 18 Jul 2004 22:04:27 -0000 1.3 +++ EARContextTest.java 22 Jul 2004 03:22:53 -0000 1.4 @@ -23,6 +23,8 @@ import javax.management.ObjectName; +import org.apache.geronimo.kernel.config.ConfigurationModuleType; + import junit.framework.TestCase; /** @@ -131,6 +133,7 @@ carFile = File.createTempFile("EARTest", ".car"); earContext = new EARContext(new JarOutputStream(new FileOutputStream(carFile)), URI.create("configId"), + ConfigurationModuleType.EAR, URI.create("parentId"), null, "j2eeDomain",