geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r378406 [2/2] - in /geronimo/branches/configid: modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ modules/client-builder/src/java/org/apache/geronimo/client/builder/ modules/client-builder/src/test-resources/plans/ modules/cli...
Date Fri, 17 Feb 2006 00:35:09 GMT
Modified: geronimo/branches/configid/modules/jetty-builder/src/test-resources/plans/plan4.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/jetty-builder/src/test-resources/plans/plan4.xml?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/jetty-builder/src/test-resources/plans/plan4.xml (original)
+++ geronimo/branches/configid/modules/jetty-builder/src/test-resources/plans/plan4.xml Thu Feb 16 16:35:03 2006
@@ -3,11 +3,10 @@
     <environment>
         <configId>
             <groupId>foo</groupId>
-            <type>car</type>
             <artifactId>bar</artifactId>
             <version>1</version>
+            <type>car</type>
         </configId>
-        <classloader></classloader>
     </environment>
 
     <context-priority-classloader>true</context-priority-classloader>

Modified: geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java (original)
+++ geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java Thu Feb 16 16:35:03 2006
@@ -40,7 +40,7 @@
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinatorGBean;
 import org.apache.geronimo.deployment.DeploymentContext;
-import org.apache.geronimo.deployment.Environment;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.deployment.util.UnpackedJarFile;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -84,6 +84,9 @@
  * @version $Rev$ $Date$
  */
 public class JettyModuleBuilderTest extends TestCase {
+    private String DOMAIN_NAME = "geronimo.test";
+    private String SERVER_NAME = "geronimo";
+    private String BASE_NAME = DOMAIN_NAME + ":J2EEServer=" + SERVER_NAME;
 
     protected Kernel kernel;
     private GBeanData container;
@@ -101,10 +104,12 @@
     private ObjectName tcmName;
     private GBeanData tcm;
     private ClassLoader cl;
-    private J2eeContext moduleContext = new J2eeContextImpl("jetty.test", "test", "null", NameFactory.WEB_MODULE, "jettyTest", null, null);
+    private J2eeContext moduleContext = new J2eeContextImpl(DOMAIN_NAME, SERVER_NAME, "null", NameFactory.WEB_MODULE, "jettyTest", null, null);
     private JettyModuleBuilder builder;
     private File basedir = new File(System.getProperty("basedir", "."));
-    private List parentId = Arrays.asList(new Artifact[] {Artifact.create("geronimo/Foo/1/car")});
+    private String PARENT_ARTIFACT_ID = "geronimo/Foo/1/car";
+    private String ARTIFACT_ID = "unknown/war4/1/car";
+    private List parentId = Arrays.asList(new Artifact[] {Artifact.create(PARENT_ARTIFACT_ID)});
     private Environment defaultEnvironment = new Environment();
 
     public void testDeployWar4() throws Exception {
@@ -133,15 +138,14 @@
         if (kernel.getGBeanState(configData.getName()) != State.RUNNING_INDEX) {
             fail("gbean not started: " + configData.getName());
         }
-        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(ObjectName.getInstance("test:J2EEApplication=null,J2EEServer=server,j2eeType=WebModule,name=unknown/war4/1/car")));
-        Set names = kernel.listGBeans(ObjectName.getInstance("test:J2EEApplication=null,J2EEServer=bar,WebModule=war4,*"));
+        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(ObjectName.getInstance(BASE_NAME + ",J2EEApplication=null,j2eeType=WebModule,name=" + ARTIFACT_ID)));
+        Set names = kernel.listGBeans(ObjectName.getInstance(DOMAIN_NAME + ":J2EEApplication=null,WebModule=" + ARTIFACT_ID + ",*"));
         System.out.println("Object names: " + names);
         for (Iterator iterator = names.iterator(); iterator.hasNext();) {
             ObjectName objectName = (ObjectName) iterator.next();
             assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(objectName));
         }
-        GBeanData filterMapping2Data = kernel.getGBeanData(ObjectName.getInstance("test:J2EEApplication=null,J2EEServer=server,Servlet=Servlet1,WebFilter=Filter2,WebModule=unknown/war4/1/car,j2eeType=WebFilterMapping"));
-//        assertEquals(Collections.singleton(ObjectName.getInstance("test:J2EEApplication=null,J2EEServer=bar,Servlet=Servlet1,WebFilter=Filter1,WebModule=war4,j2eeType=WebFilterMapping")), filterMapping2Data.getReferencePatterns("Previous"));
+        GBeanData filterMapping2Data = kernel.getGBeanData(ObjectName.getInstance(BASE_NAME + ",J2EEApplication=null,Servlet=Servlet1,WebFilter=Filter2,WebModule=" + ARTIFACT_ID + ",j2eeType=WebFilterMapping"));
 
         kernel.stopGBean(configName);
         kernel.unloadGBean(configName);
@@ -245,6 +249,7 @@
     }
 
     protected void setUp() throws Exception {
+        defaultEnvironment.getProperties().put(NameFactory.JSR77_BASE_NAME_PROPERTY, BASE_NAME);
         cl = this.getClass().getClassLoader();
         containerName = NameFactory.getWebComponentName(null, null, null, null, "jettyContainer", "WebResource", moduleContext);
         connectorName = NameFactory.getWebComponentName(null, null, null, null, "jettyConnector", "WebResource", moduleContext);

Modified: geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java (original)
+++ geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java Thu Feb 16 16:35:03 2006
@@ -1,7 +1,6 @@
 package org.apache.geronimo.jetty.deployment;
 
 import java.io.File;
-import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -15,13 +14,12 @@
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.deployment.xbeans.ArtifactType;
-import org.apache.geronimo.deployment.Environment;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
-import org.apache.geronimo.xbeans.geronimo.web.GerWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.config.GerJettyDocument;
@@ -123,7 +121,6 @@
         configId.setArtifactId("a");
         configId.setVersion("1");
         configId.setType("car");
-        environmentType.addNewClassloader();
     }
 
     public void testContextPriorityClassloader() throws Exception {

Copied: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java (from r377836, geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/Environment.java)
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java?p2=geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java&p1=geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/Environment.java&r1=377836&r2=378406&rev=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/Environment.java (original)
+++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java Thu Feb 16 16:35:03 2006
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.deployment;
+package org.apache.geronimo.kernel.repository;
 
 import org.apache.geronimo.kernel.repository.Artifact;
 
@@ -35,7 +35,7 @@
 
     private Artifact configId;
 
-    private final Map nameKeys = new HashMap();
+    private final Map properties = new HashMap();
 
     private final LinkedHashSet imports = new LinkedHashSet();
     private final LinkedHashSet references = new LinkedHashSet();
@@ -59,17 +59,17 @@
         this.configId = configId;
     }
 
-    public Map getNameKeys() {
-        return nameKeys;
+    public Map getProperties() {
+        return properties;
     }
 
-    public void addNameKeys(Map nameKeys) {
-        this.nameKeys.putAll(nameKeys);
+    public void addProperties(Map nameKeys) {
+        this.properties.putAll(nameKeys);
     }
 
-    public void setNameKeys(Map nameKeys) {
-        this.nameKeys.clear();
-        addNameKeys(nameKeys);
+    public void setProperties(Map properties) {
+        this.properties.clear();
+        addProperties(properties);
     }
 
     public LinkedHashSet getImports() {

Modified: geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java (original)
+++ geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/EnvironmentBuilder.java Thu Feb 16 16:35:03 2006
@@ -18,13 +18,15 @@
 package org.apache.geronimo.deployment.service;
 
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.deployment.Environment;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.deployment.xbeans.ArtifactType;
 import org.apache.geronimo.deployment.xbeans.ClassFilterType;
-import org.apache.geronimo.deployment.xbeans.ClassloaderType;
 import org.apache.geronimo.deployment.xbeans.EnvironmentDocument;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
-import org.apache.geronimo.deployment.xbeans.NameKeyType;
+import org.apache.geronimo.deployment.xbeans.PropertyType;
+import org.apache.geronimo.deployment.xbeans.ImportType;
+import org.apache.geronimo.deployment.xbeans.PropertiesType;
+import org.apache.geronimo.deployment.xbeans.DependenciesType;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.xmlbeans.XmlException;
@@ -37,6 +39,8 @@
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
  * @version $Rev:$ $Date:$
@@ -51,35 +55,58 @@
             environment.setConfigId(toArtifact(environmentType.getConfigId()));
         }
 
-        NameKeyType[] nameKeyArray = environmentType.getNameKeyArray();
-        Map nameKeyMap = new HashMap();
-        for (int i = 0; i < nameKeyArray.length; i++) {
-            NameKeyType nameKey = nameKeyArray[i];
-            String key = nameKey.getKey().trim();
-            String value = nameKey.getValue().trim();
-            nameKeyMap.put(key, value);
-        }
-        environment.setNameKeys(nameKeyMap);
-
-        if (environmentType.isSetClassloader()) {
-            ClassloaderType classloaderType = environmentType.getClassloader();
-            environment.setImports(toArtifacts(classloaderType.getImportArray()));
-            environment.setDependencies(toArtifacts(classloaderType.getDependencyArray()));
-            environment.setIncludes(toArtifacts(classloaderType.getIncludeArray()));
-
-            environment.setInverseClassloading(classloaderType.isSetInverseClassloading());
-            environment.setSuppressDefaultEnvironment(classloaderType.isSetSuppressDefaultEnvironment());
-            environment.setHiddenClasses(toFilters(classloaderType.getHiddenClassesArray()));
-            environment.setNonOverrideableClasses(toFilters(classloaderType.getNonOverridableClassesArray()));
-        }
-        environment.setReferences(toArtifacts(environmentType.getReferenceArray()));
+        Map propertiesMap = new HashMap();
+        if (environmentType.isSetProperties()) {
+            PropertyType[] propertiesArray = environmentType.getProperties().getPropertyArray();
+            for (int i = 0; i < propertiesArray.length; i++) {
+                PropertyType property = propertiesArray[i];
+                String key = property.getName().trim();
+                String value = property.getValue().trim();
+                propertiesMap.put(key, value);
+            }
+        }
+        environment.setProperties(propertiesMap);
+
+        if (environmentType.isSetDependencies()) {
+            ArtifactType[] dependencyArray = environmentType.getDependencies().getDependencyArray();
+            Collection dependencies = new LinkedHashSet();
+            Collection imports = new LinkedHashSet();
+            Collection references = new LinkedHashSet();
+            for (int i = 0; i < dependencyArray.length; i++) {
+                ArtifactType artifactType = dependencyArray[i];
+                Artifact artifact = toArtifact(artifactType);
+                if (artifact.getType() == null) {
+                    artifact.setType("jar");
+                }
+                String type = artifact.getType();
+                if (type.equals("jar")) {
+                    dependencies.add(artifact);
+                } else if (type.equals("car")) {
+                    if ("classes".equals(artifactType.getImport())) {
+                        throw new IllegalArgumentException("classes-only dependency on car files not yet supported");
+                    } else if ("services".equals(artifactType.getImport())) {
+                        references.add(artifact);
+                    } else {
+                        imports.add(artifact);
+                    }
+                }
+            }
+            environment.setImports(imports);
+            environment.setDependencies(dependencies);
+            environment.setReferences(references);
+
+        }
+        environment.setInverseClassloading(environmentType.isSetInverseClassloading());
+        environment.setSuppressDefaultEnvironment(environmentType.isSetSuppressDefaultEnvironment());
+        environment.setHiddenClasses(toFilters(environmentType.getHiddenClassesArray()));
+        environment.setNonOverrideableClasses(toFilters(environmentType.getNonOverridableClassesArray()));
 
         return environment;
     }
 
     public static void mergeEnvironments(Environment environment, Environment additionalEnvironment) {
         if (additionalEnvironment != null) {
-            environment.addNameKeys(additionalEnvironment.getNameKeys());
+            environment.addProperties(additionalEnvironment.getProperties());
             environment.addImports(additionalEnvironment.getImports());
             environment.addDependencies(additionalEnvironment.getDependencies());
             environment.addIncludes(additionalEnvironment.getIncludes());
@@ -99,29 +126,36 @@
 
     public static EnvironmentType buildEnvironmentType(Environment environment) {
         EnvironmentType environmentType = EnvironmentType.Factory.newInstance();
-        ArtifactType configId = environmentType.addNewConfigId();
-        toArtifactType(configId, environment.getConfigId());
-        for (Iterator iterator = environment.getNameKeys().entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String key = (String) entry.getKey();
-            String value = (String) entry.getValue();
-            NameKeyType nameKeyType = environmentType.addNewNameKey();
-            nameKeyType.setKey(key);
-            nameKeyType.setValue(value);
-        }
-        ClassloaderType classloaderType = environmentType.addNewClassloader();
-        classloaderType.setImportArray(toArtifactTypes(environment.getImports()));
-        classloaderType.setIncludeArray(toArtifactTypes(environment.getIncludes()));
-        classloaderType.setDependencyArray(toArtifactTypes(environment.getDependencies()));
+        ArtifactType configId = toArtifactType(environment.getConfigId(), null);
+        environmentType.setConfigId(configId);
+
+        if (environment.getProperties().size() >0) {
+            PropertiesType propertiesType = environmentType.addNewProperties();
+            for (Iterator iterator = environment.getProperties().entrySet().iterator(); iterator.hasNext();) {
+                Map.Entry entry = (Map.Entry) iterator.next();
+                String name = (String) entry.getKey();
+                String value = (String) entry.getValue();
+                PropertyType propertyType = propertiesType.addNewProperty();
+                propertyType.setName(name);
+                propertyType.setValue(value);
+            }
+        }
+        List dependencies = new ArrayList();
+        toArtifactTypes(environment.getImports(), null, dependencies);
+//        toArtifactTypes(environment.getIncludes(), null, dependencies));
+        toArtifactTypes(environment.getDependencies(), null, dependencies);
+        toArtifactTypes(environment.getReferences(), ImportType.SERVICES, dependencies);
+        ArtifactType[] artifactTypes = (ArtifactType[]) dependencies.toArray(new ArtifactType[dependencies.size()]);
+        DependenciesType dependenciesType = environmentType.addNewDependencies();
+        dependenciesType.setDependencyArray(artifactTypes);
         if (environment.isInverseClassloading()) {
-            classloaderType.addNewInverseClassloading();
+            environmentType.addNewInverseClassloading();
         }
         if (environment.isSuppressDefaultEnvironment()) {
-            classloaderType.addNewSuppressDefaultEnvironment();
+            environmentType.addNewSuppressDefaultEnvironment();
         }
-        classloaderType.setHiddenClassesArray(toFilterType(environment.getHiddenClasses()));
-        classloaderType.setNonOverridableClassesArray(toFilterType(environment.getNonOverrideableClasses()));
-        environmentType.setReferenceArray(toArtifactTypes(environment.getReferences()));
+        environmentType.setHiddenClassesArray(toFilterType(environment.getHiddenClasses()));
+        environmentType.setNonOverridableClassesArray(toFilterType(environment.getNonOverrideableClasses()));
         return environmentType;
     }
 
@@ -137,19 +171,16 @@
         return classFilters;
     }
 
-    private static ArtifactType[] toArtifactTypes(Collection artifacts) {
-        ArtifactType[] artifactTypes = new ArtifactType[artifacts.size()];
-        int i = 0;
+    private static void toArtifactTypes(Collection artifacts, ImportType.Enum importType, List dependencies) {
         for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
             Artifact artifact = (Artifact) iterator.next();
-            ArtifactType artifactType = ArtifactType.Factory.newInstance();
-            toArtifactType(artifactType, artifact);
-            artifactTypes[i++] = artifactType;
+            ArtifactType artifactType = toArtifactType(artifact, importType);
+            dependencies.add(artifactType);
         }
-        return artifactTypes;
     }
 
-    private static void toArtifactType(ArtifactType artifactType, Artifact artifact) {
+    private static ArtifactType toArtifactType(Artifact artifact, ImportType.Enum importType) {
+        ArtifactType artifactType = ArtifactType.Factory.newInstance();
         if (artifact.getGroupId() != null) {
             artifactType.setGroupId(artifact.getGroupId());
         }
@@ -162,6 +193,10 @@
         if (artifact.getType() != null) {
             artifactType.setType(artifact.getType());
         }
+        if (importType != null) {
+            artifactType.setImport(importType);
+        }
+        return artifactType;
     }
 
     private static Set toFilters(ClassFilterType[] filterArray) {

Modified: geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java (original)
+++ geronimo/branches/configid/modules/service-builder/src/java/org/apache/geronimo/deployment/service/ServiceConfigBuilder.java Thu Feb 16 16:35:03 2006
@@ -20,7 +20,7 @@
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ConfigurationBuilder;
 import org.apache.geronimo.deployment.DeploymentContext;
-import org.apache.geronimo.deployment.Environment;
+import org.apache.geronimo.deployment.xbeans.ArtifactType;
 import org.apache.geronimo.deployment.xbeans.AttributeType;
 import org.apache.geronimo.deployment.xbeans.ConfigurationDocument;
 import org.apache.geronimo.deployment.xbeans.ConfigurationType;
@@ -31,19 +31,18 @@
 import org.apache.geronimo.deployment.xbeans.ReferencesType;
 import org.apache.geronimo.deployment.xbeans.ServiceDocument;
 import org.apache.geronimo.deployment.xbeans.XmlAttributeType;
-import org.apache.geronimo.deployment.xbeans.ArtifactType;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.ReferenceMap;
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
-import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContextImpl;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.xmlbeans.XmlCursor;
@@ -177,8 +176,8 @@
 
         J2eeContext j2eeContext = null;
         try {
-            j2eeContext = new J2eeContextImpl(context.getDomain(), context.getServer(), NameFactory.NULL, NameFactory.J2EE_MODULE, environment.getConfigId().toURI().toString(), null, null);
-        } catch (URISyntaxException e) {
+            j2eeContext = NameFactory.buildJ2eeContext(environment.getProperties(), NameFactory.NULL, NameFactory.J2EE_MODULE, environment.getConfigId().toString(), null, null);
+        } catch (MalformedObjectNameException e) {
             throw new DeploymentException(e);
         }
         GbeanType[] gbeans = configurationType.getGbeanArray();

Modified: geronimo/branches/configid/modules/service-builder/src/schema/geronimo-config-1.1.xsd
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/service-builder/src/schema/geronimo-config-1.1.xsd?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/service-builder/src/schema/geronimo-config-1.1.xsd (original)
+++ geronimo/branches/configid/modules/service-builder/src/schema/geronimo-config-1.1.xsd Thu Feb 16 16:35:03 2006
@@ -68,83 +68,11 @@
                     </xs:documentation>
                 </xs:annotation>
             </xs:element>
-            <xs:element name="name-key" type="sys:name-keyType" minOccurs="0" maxOccurs="unbounded"/>
-            <xs:element name="classloader" type="sys:classloaderType" minOccurs="0">
+            <xs:element name="properties" type="sys:propertiesType" minOccurs="0"/>
+            <xs:element name="dependencies" type="sys:dependenciesType" minOccurs="0">
                 <xs:annotation>
                     <xs:documentation>
-                        "classloader" holds all classloader configuration information for the configuration
-                    </xs:documentation>
-                </xs:annotation>
-            </xs:element>
-            <xs:element name="reference" type="sys:artifactType" minOccurs="0" maxOccurs="unbounded">
-                <xs:annotation>
-                    <xs:documentation>
-                        "reference" refers to a configuration that must be present to load this configuration, but
-                        which should not be a parent classloader for this configuration.
-                    </xs:documentation>
-                </xs:annotation>
-            </xs:element>
-        </xs:sequence>
-    </xs:complexType>
-
-    <xs:complexType name="name-keyType">
-        <xs:annotation>
-            <xs:documentation>
-                name-key holds a key name and value for the object-name like name for the gbeans in the configuration
-                These name-keys will be repeated in child configurations of this configuration.  Normally these
-                are domain and server for jsr-77 style object names.
-            </xs:documentation>
-        </xs:annotation>
-        <xs:sequence>
-            <xs:element name="key" type="xs:string"/>
-            <xs:element name="value" type="xs:string"/>
-        </xs:sequence>
-    </xs:complexType>
-
-    <xs:complexType name="classloaderType">
-        <xs:sequence>
-            <xs:element name="import" type="sys:artifactType" minOccurs="0" maxOccurs="unbounded">
-                <xs:annotation>
-                    <xs:documentation>
-                        "import" holds a URI, where the URI matches the configId of another configuration.
-                        That configuration will be added as a parent of this configuration (the main
-                        impact being that it's ClassLoader will be a parent of the ClassLoader for this
-                        configuration.
-
-                        Generally this URI will have the Maven form (groupId/artifactId/version/type),
-                        and you can also use the sub-elements (groupId, type, ...) accordingly.
-                        However, if you deploy a custom module with a simple configId like "Foo",
-                        you can use that as the URI value here, and in that case you could not use the
-                        subelements because you wouldn't have values for all of them.
-                    </xs:documentation>
-                </xs:annotation>
-            </xs:element>
-            <xs:element name="include" type="sys:artifactType" minOccurs="0" maxOccurs="unbounded">
-                <xs:annotation>
-                    <xs:documentation>
-                        "include" holds a URI, where the URI identifies an entry in the server's Repository.
-                        When this module is being built, the content of that repository entry will be
-                        copied into this module and added to the ClassPath of this module.  This is
-                        currently only supported for a small number of module types, and is typically used
-                        to create more "standalone" modules that don't need a populated repository to run.
-
-                        This URI must always have a form acceptable to the Repository, which currently
-                        takes Maven-style URIs (groupId/artifactId/version/type).  You can also use the
-                        sub-elements (groupId, type, ...) instead of a full URI.
-                    </xs:documentation>
-                </xs:annotation>
-            </xs:element>
-            <xs:element name="dependency" type="sys:artifactType" minOccurs="0" maxOccurs="unbounded">
-                <xs:annotation>
-                    <xs:documentation>
-                        "dependency" holds a URI, where the URI identifies an entry in the server's
-                        Repository.  That repository entry will be added to the ClassPath of this module.
-                        Essentially, this module's ClassPath points to that location in the server's
-                        repository, so that entry must be in the repository at runtime for this to work.
-
-                        This URI must always have a form acceptable to the Repository, which currently
-                        takes Maven-style URIs (groupId/artifactId/version/type).  You can also use the
-                        sub-elements (groupId, type, ...) instead of a full URI.
+                        "dependences" holds all classloader and dependency configuration information for the configuration
                     </xs:documentation>
                 </xs:annotation>
             </xs:element>
@@ -185,6 +113,42 @@
         </xs:sequence>
     </xs:complexType>
 
+    <xs:complexType name="propertiesType">
+        <xs:sequence>
+            <xs:element name="property" type="sys:propertyType" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="propertyType">
+        <xs:annotation>
+            <xs:documentation>
+                property holds name and value for the deployment system.  When written the only use for this
+                is to supply part of an object-name like name for the gbeans in the configuration
+                These name-keys will be repeated in child configurations of this configuration.  Normally these
+                are domain and server for jsr-77 style object names.
+            </xs:documentation>
+        </xs:annotation>
+        <xs:sequence>
+            <xs:element name="name" type="xs:string"/>
+            <xs:element name="value" type="xs:string"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="dependenciesType">
+        <xs:sequence>
+            <xs:element name="dependency" type="sys:artifactType" minOccurs="0" maxOccurs="unbounded">
+                <xs:annotation>
+                    <xs:documentation>
+                        "dependency" holds an artifact locating an artifact in a repo or config store.
+                        Depending on the type of artifact and value of the import element, the artifact may be
+                        included in the current classpath, be loaded as a parent, may require the services
+                        in the artifact to be started, or may not be added to the classpath.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
+        </xs:sequence>
+    </xs:complexType>
+
     <xs:complexType name="emptyType"/>
 
      <xs:element name="gbean" type="sys:gbeanType">
@@ -232,20 +196,29 @@
                 corresponds to the xml:
 
                 <groupId>postgresql</groupId>
-                <type>jar</type>
                 <artifactId>postgresql-8.0-jdbc</artifactId>
                 <version>313</version>
+                <type>jar</type>
 
           ]]></xs:documentation>
         </xs:annotation>
             <xs:sequence>
                 <!-- TODO not sure if groupId can in fact be optional -->
                 <xs:element name="groupId" type="xs:string" minOccurs="0"/>
-                <xs:element name="type" type="xs:string" minOccurs="0"/>
                 <xs:element name="artifactId" type="xs:string"/>
                 <xs:element name="version" type="xs:string" minOccurs="0"/>
+                <xs:element name="type" type="xs:string" minOccurs="0"/>
+                <xs:element name="import" type="sys:importType" minOccurs="0"/>
+
             </xs:sequence>
     </xs:complexType>
+
+    <xs:simpleType name="importType">
+        <xs:restriction base="xs:string">
+            <xs:enumeration value="classes"/>
+            <xs:enumeration value="services"/>
+        </xs:restriction>
+    </xs:simpleType>
 
     <xs:complexType name="gbeanType">
         <xs:choice minOccurs="0" maxOccurs="unbounded">

Modified: geronimo/branches/configid/modules/service-builder/src/test-resources/services/plan1.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/service-builder/src/test-resources/services/plan1.xml?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/service-builder/src/test-resources/services/plan1.xml (original)
+++ geronimo/branches/configid/modules/service-builder/src/test-resources/services/plan1.xml Thu Feb 16 16:35:03 2006
@@ -24,25 +24,23 @@
     <environment>
         <configId>
             <groupId>geronimo</groupId>
-            <type>car</type>
             <artifactId>foo4</artifactId>
             <version>DEV</version>
+            <type>car</type>
         </configId>
-        <name-key>
-            <key>domain</key>
-            <value>geronimo.server</value>
-        </name-key>
-        <name-key>
-            <key>J2EEServer</key>
-            <value>geronimo</value>
-        </name-key>
-        <classloader>
-            <import>
+        <properties>
+            <property>
+                <name>domain</name>
+                <value>geronimo.server</value>
+            </property>
+        </properties>
+        <dependencies>
+            <dependency>
                 <groupId>geronimo</groupId>
-                <type>car</type>
                 <artifactId>foo4</artifactId>
                 <version>DEV</version>
-            </import>
+                <type>car</type>
+            </dependency>
 
             <dependency>
                 <groupId>geronimo</groupId>
@@ -62,7 +60,7 @@
                 </version>
             </dependency>
 
-        </classloader>
+        </dependencies>
     </environment>
     <gbean gbeanName="geronimo.test:name=MyMockGMBean" class="org.apache.geronimo.deployment.MockGBean">
         <attribute name="value">1234</attribute>

Modified: geronimo/branches/configid/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java (original)
+++ geronimo/branches/configid/modules/service-builder/src/test/org/apache/geronimo/deployment/service/ServiceConfigBuilderTest.java Thu Feb 16 16:35:03 2006
@@ -18,7 +18,7 @@
 
 import junit.framework.TestCase;
 import org.apache.geronimo.deployment.DeploymentContext;
-import org.apache.geronimo.deployment.Environment;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.deployment.FooBarBean;
 import org.apache.geronimo.deployment.xbeans.ConfigurationDocument;
 import org.apache.geronimo.deployment.xbeans.ConfigurationType;

Modified: geronimo/branches/configid/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/branches/configid/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Thu Feb 16 16:35:03 2006
@@ -47,7 +47,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.deployment.Environment;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.service.ServiceConfigBuilder;
 import org.apache.geronimo.deployment.util.DeploymentUtil;

Modified: geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war1/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war1/WEB-INF/geronimo-web.xml?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war1/WEB-INF/geronimo-web.xml (original)
+++ geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war1/WEB-INF/geronimo-web.xml Thu Feb 16 16:35:03 2006
@@ -17,9 +17,7 @@
 -->
 
 <tomcat:web-app
-    xmlns:tomcat="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
-    configId="org/apache/geronimo/tomcat/Test"
-    >
+    xmlns:tomcat="http://geronimo.apache.org/xml/ns/j2ee/web-1.1">
     <tomcat:context-root>/test</tomcat:context-root>
     <tomcat:context-priority-classloader>false</tomcat:context-priority-classloader>
     <!--

Modified: geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war3/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war3/WEB-INF/geronimo-web.xml?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war3/WEB-INF/geronimo-web.xml (original)
+++ geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war3/WEB-INF/geronimo-web.xml Thu Feb 16 16:35:03 2006
@@ -17,9 +17,8 @@
 -->
 
 <web-app
-    xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
-    xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1"
-    configId="org/apache/geronimo/test">
+    xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
+    xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1">
 
     <context-root>/test</context-root>
     <context-priority-classloader>false</context-priority-classloader>

Modified: geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-web.xml?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-web.xml (original)
+++ geronimo/branches/configid/modules/tomcat-builder/src/test-resources/deployables/war4/WEB-INF/geronimo-web.xml Thu Feb 16 16:35:03 2006
@@ -21,11 +21,10 @@
     <environment>
         <configId>
             <groupId>foo</groupId>
-            <type>car</type>
             <artifactId>bar</artifactId>
             <version>1</version>
+            <type>car</type>
         </configId>
-        <classloader></classloader>
     </environment>
 
     <context-root>/test</context-root>

Modified: geronimo/branches/configid/modules/tomcat-builder/src/test-resources/plans/plan1.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/tomcat-builder/src/test-resources/plans/plan1.xml?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/tomcat-builder/src/test-resources/plans/plan1.xml (original)
+++ geronimo/branches/configid/modules/tomcat-builder/src/test-resources/plans/plan1.xml Thu Feb 16 16:35:03 2006
@@ -3,11 +3,10 @@
     <environment>
         <configId>
             <groupId>foo</groupId>
-            <type>car</type>
             <artifactId>bar</artifactId>
             <version>1</version>
+            <type>car</type>
         </configId>
-        <classloader></classloader>
     </environment>
     <context-priority-classloader>false</context-priority-classloader>
     <security-realm-name>public-properties-realm</security-realm-name>

Modified: geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java (original)
+++ geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java Thu Feb 16 16:35:03 2006
@@ -43,7 +43,6 @@
         ArtifactType artifactType = environmentType.addNewConfigId();
         artifactType.setArtifactId("foo");
 
-        environmentType.addNewClassloader();
         tomcatWebAppType.setContextPriorityClassloader(false);
         GerResourceRefType ref = tomcatWebAppType.addNewResourceRef();
         ref.setRefName("ref");

Modified: geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java (original)
+++ geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java Thu Feb 16 16:35:03 2006
@@ -44,7 +44,7 @@
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinatorGBean;
 import org.apache.geronimo.deployment.DeploymentContext;
-import org.apache.geronimo.deployment.Environment;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.deployment.util.UnpackedJarFile;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -92,6 +92,9 @@
  * @version $Rev$ $Date$
  */
 public class TomcatModuleBuilderTest extends TestCase {
+    private String DOMAIN_NAME = "geronimo.test";
+    private String SERVER_NAME = "geronimo";
+    private String BASE_NAME = DOMAIN_NAME + ":J2EEServer=" + SERVER_NAME;
 
     protected Kernel kernel;
 
@@ -137,8 +140,8 @@
 
     private ClassLoader cl;
 
-    private J2eeContext moduleContext = new J2eeContextImpl("tomcat.test",
-            "test", "null", NameFactory.WEB_MODULE, "Test", null, null);
+    private J2eeContext moduleContext = new J2eeContextImpl(DOMAIN_NAME,
+            SERVER_NAME, "null", NameFactory.WEB_MODULE, "Test", null, null);
 
     private TomcatModuleBuilder builder;
 
@@ -199,9 +202,8 @@
             fail("gbean not started: " + configName);
         }
 
-        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(ObjectName.getInstance("test:J2EEApplication=null,J2EEServer=server,j2eeType=WebModule,name=" + name)));
-
-        Set names = kernel.listGBeans(ObjectName.getInstance("test:J2EEApplication=null,J2EEServer=server,*"));
+        assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(ObjectName.getInstance(BASE_NAME + ",J2EEApplication=null,j2eeType=WebModule,name=" + name)));
+        Set names = kernel.listGBeans(ObjectName.getInstance(DOMAIN_NAME + ":J2EEApplication=null,WebModule=" + name + ",*"));
         System.out.println("Object names: " + names);
         for (Iterator iterator = names.iterator(); iterator.hasNext();) {
             ObjectName objectName = (ObjectName) iterator.next();
@@ -337,10 +339,9 @@
     protected void setUp() throws Exception {
         Artifact artifact = Artifact.create("test/foo/1/car");
         defaultEnvironment.setConfigId(artifact);
-        Map nameKeys = new HashMap();
-        nameKeys.put("domain", "test");
-        nameKeys.put("J2EEServer", "server");
-        defaultEnvironment.addNameKeys(nameKeys);
+        Map properties = new HashMap();
+        properties.put(NameFactory.JSR77_BASE_NAME_PROPERTY, BASE_NAME);
+        defaultEnvironment.addProperties(properties);
         cl = this.getClass().getClassLoader();
         containerName = NameFactory.getWebComponentName(null, null, null, null,
                 "tomcatContainer", "WebResource", moduleContext);

Modified: geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PlanProcessor.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PlanProcessor.java?rev=378406&r1=378405&r2=378406&view=diff
==============================================================================
--- geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PlanProcessor.java (original)
+++ geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/PlanProcessor.java Thu Feb 16 16:35:03 2006
@@ -16,16 +16,14 @@
  */
 package org.apache.geronimo.plugin.packaging;
 
-import java.io.File;
-import java.io.StringWriter;
-import java.util.Iterator;
-import java.util.List;
-import javax.xml.namespace.QName;
-
-import org.apache.commons.jelly.tags.velocity.JellyContextAdapter;
 import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.tags.velocity.JellyContextAdapter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
+import org.apache.geronimo.deployment.xbeans.ArtifactType;
+import org.apache.geronimo.deployment.xbeans.EnvironmentType;
+import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.maven.project.Dependency;
 import org.apache.maven.repository.Artifact;
 import org.apache.velocity.Template;
@@ -35,9 +33,14 @@
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
-import org.apache.geronimo.deployment.xbeans.EnvironmentType;
-import org.apache.geronimo.deployment.xbeans.ArtifactType;
-import org.apache.geronimo.deployment.xbeans.ClassloaderType;
+
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
 
 /**
  * @version $Rev$ $Date$
@@ -46,8 +49,9 @@
     private static Log log = LogFactory.getLog(PlanProcessor.class);
 
     private static final String IMPORT_PROPERTY = "geronimo.import";
-    private static final String INCLUDE_PROPERTY = "geronimo.include";
+//    private static final String INCLUDE_PROPERTY = "geronimo.include";
     private static final String DEPENDENCY_PROPERTY = "geronimo.dependency";
+    private static final String REFERENCE_PROPERTY = "geronimo.reference";
     private static final QName ENVIRONMENT_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.1", "environment");
 
     private List artifacts;
@@ -160,17 +164,17 @@
                 xmlCursor.toFirstContentToken();
                 xmlCursor.toFirstChild();
                 QName childName = xmlCursor.getName();
-                EnvironmentType environmentType;
+                Environment oldEnvironment = null;
                 if (childName.equals(ENVIRONMENT_QNAME)) {
                     XmlObject xmlObject = xmlCursor.getObject();
                     System.out.println("Expected EnvironmentType, actual: " + xmlObject.getClass().getName());
                     System.out.println(xmlObject.toString());
-                    environmentType = (EnvironmentType) xmlObject.copy().changeType(EnvironmentType.type);
+                    EnvironmentType environmentType = (EnvironmentType) xmlObject.copy().changeType(EnvironmentType.type);
+                    oldEnvironment = EnvironmentBuilder.buildEnvironment(environmentType);
                     xmlCursor.removeXml();
                 } else {
-                    environmentType = EnvironmentType.Factory.newInstance();
                     xmlCursor.beginElement(ENVIRONMENT_QNAME);
-                    XmlCursor element = environmentType.newCursor();
+                    XmlCursor element = EnvironmentType.Factory.newInstance().newCursor();
                     try {
                         element.copyXmlContents(xmlCursor);
                     } finally {
@@ -178,45 +182,21 @@
                     }
                 }
 
-                ArtifactType configId = environmentType.getConfigId();
-                if (configId == null) {
-                    configId = environmentType.addNewConfigId();
-                    configId.setGroupId(groupId);
-                    configId.setArtifactId(artifactId);
-                    configId.setVersion(version);
-                    configId.setType("car");
-                }
-
-                insertPlanElements(environmentType, IMPORT_PROPERTY, new Inserter() {
-
-                    public ArtifactType insert(EnvironmentType environmentType) {
-                        ClassloaderType classloaderType = environmentType.getClassloader();
-                        if (classloaderType == null) {
-                            classloaderType = environmentType.addNewClassloader();
-                        }
-                        return classloaderType.addNewImport();
-                    }
-                });
-                insertPlanElements(environmentType, INCLUDE_PROPERTY, new Inserter() {
+                   org.apache.geronimo.kernel.repository.Artifact configId = new org.apache.geronimo.kernel.repository.Artifact(groupId, artifactId, version, "car", true);
 
-                    public ArtifactType insert(EnvironmentType environmentType) {
-                        ClassloaderType classloaderType = environmentType.getClassloader();
-                        if (classloaderType == null) {
-                            classloaderType = environmentType.addNewClassloader();
-                        }
-                        return classloaderType.addNewInclude();
-                    }
-                });
-                insertPlanElements(environmentType, DEPENDENCY_PROPERTY, new Inserter() {
+                Collection imports = toArtifacts(IMPORT_PROPERTY);
+//                Collection includes = toArtifacts(INCLUDE_PROPERTY);
+                Collection dependencies = toArtifacts(DEPENDENCY_PROPERTY);
+                Collection references = toArtifacts(REFERENCE_PROPERTY);
+
+                Environment newEnvironment = new Environment();
+                newEnvironment.setConfigId(configId);
+                newEnvironment.setImports(imports);
+                newEnvironment.setDependencies(dependencies);
+                newEnvironment.setReferences(references);
 
-                    public ArtifactType insert(EnvironmentType environmentType) {
-                        ClassloaderType classloaderType = environmentType.getClassloader();
-                        if (classloaderType == null) {
-                            classloaderType = environmentType.addNewClassloader();
-                        }
-                        return classloaderType.addNewDependency();
-                    }
-                });
+                EnvironmentBuilder.mergeEnvironments(oldEnvironment, newEnvironment);
+                EnvironmentType environmentType = EnvironmentBuilder.buildEnvironmentType(oldEnvironment);
 
                 xmlCursor.beginElement(ENVIRONMENT_QNAME);
                 XmlCursor element = environmentType.newCursor();
@@ -247,7 +227,8 @@
         }
     }
 
-    private void insertPlanElements(EnvironmentType environmentType, String artifactProperty, Inserter inserter) {
+    private Collection toArtifacts(String artifactProperty) {
+        Collection artifactList = new LinkedHashSet();
         for (Iterator iterator = artifacts.iterator(); iterator.hasNext();) {
             Artifact artifact = (Artifact) iterator.next();
             Dependency dependency = artifact.getDependency();
@@ -256,16 +237,13 @@
                 String artifactId = dependency.getArtifactId();
                 String version = dependency.getVersion();
                 String type = dependency.getType();
-                ArtifactType artifactType = inserter.insert(environmentType);
-                artifactType.setGroupId(groupId);
-                artifactType.setArtifactId(artifactId);
-                artifactType.setVersion(version);
-                if (type != null && !"jar".equals(type)) {
-                    artifactType.setType(type);
+                if (type == null) {
+                    type = "jar";
                 }
-
+                artifactList.add(new org.apache.geronimo.kernel.repository.Artifact(groupId, artifactId,  version, type, false));
             }
         }
+        return artifactList;
     }
 
     interface Inserter {



Mime
View raw message