geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r674396 - in /geronimo/server/branches/2.1: framework/modules/geronimo-common/src/main/java/org/apache/geronimo/common/propertyeditor/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ framework/modules/geronimo-ker...
Date Mon, 07 Jul 2008 04:38:56 GMT
Author: gdamour
Date: Sun Jul  6 21:38:55 2008
New Revision: 674396

URL: http://svn.apache.org/viewvc?rev=674396&view=rev
Log:
Port change set r674385:674386 from trunk to this branch.

Fix a classloader clash happening when a WADI clustered application is
deployed: Tribes classes were loaded by the configurations
org.apache.geronimo.configs/tomcat6//car and 
org.apache.geronimo.configs/wadi-clustering//car and should only be loaded
by the wadi-clustering configuration.

Add a org.apache.geronimo.configs/tomcat6-no-ha//car configuration, which
imports org.apache.geronimo.configs/tomcat6//car and hides the Tribes classes.
When a WADI clustered application is built, the tomcat6 configuration is 
removed from the clustered application ancestor list and replaced by 
tomcat6-no-ha. Tribes classes are now loaded by wadi-clustering.


Added:
    geronimo/server/branches/2.1/framework/modules/geronimo-common/src/main/java/org/apache/geronimo/common/propertyeditor/ArtifactEditor.java
      - copied unchanged from r674386, geronimo/server/trunk/framework/modules/geronimo-common/src/main/java/org/apache/geronimo/common/propertyeditor/ArtifactEditor.java
    geronimo/server/branches/2.1/plugins/tomcat/tomcat6-no-ha/
      - copied from r674386, geronimo/server/trunk/plugins/tomcat/tomcat6-no-ha/
    geronimo/server/branches/2.1/plugins/tomcat/tomcat6-no-ha/pom.xml
      - copied unchanged from r674386, geronimo/server/trunk/plugins/tomcat/tomcat6-no-ha/pom.xml
    geronimo/server/branches/2.1/plugins/tomcat/tomcat6-no-ha/src/
      - copied from r674386, geronimo/server/trunk/plugins/tomcat/tomcat6-no-ha/src/
    geronimo/server/branches/2.1/plugins/tomcat/tomcat6-no-ha/src/main/
      - copied from r674386, geronimo/server/trunk/plugins/tomcat/tomcat6-no-ha/src/main/
    geronimo/server/branches/2.1/plugins/tomcat/tomcat6-no-ha/src/main/plan/
      - copied from r674386, geronimo/server/trunk/plugins/tomcat/tomcat6-no-ha/src/main/plan/
    geronimo/server/branches/2.1/plugins/tomcat/tomcat6-no-ha/src/main/plan/plan.xml
      - copied unchanged from r674386, geronimo/server/trunk/plugins/tomcat/tomcat6-no-ha/src/main/plan/plan.xml
Modified:
    geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractNameQuery.java
    geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Artifact.java
    geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
    geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java
    geronimo/server/branches/2.1/plugins/tomcat/pom.xml
    geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-builder-wadi/src/main/plan/plan.xml
    geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-wadi/pom.xml

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractNameQuery.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractNameQuery.java?rev=674396&r1=674395&r2=674396&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractNameQuery.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/AbstractNameQuery.java
Sun Jul  6 21:38:55 2008
@@ -99,24 +99,7 @@
 //        if (artifactString == null) throw new IllegalArgumentException("uri does not contain
a path part used for the artifact");
 
         if (artifactString != null && artifactString.length() > 0) {
-            List artifactParts = split(artifactString, '/');
-            if (artifactParts.size() != 4) {
-                throw new IllegalArgumentException("uri path must be in the form [groupId]/[artifactId]/[version]/[type]
: " + artifactString);
-            }
-
-            String groupId = (String) artifactParts.get(0);
-            if (groupId.length() == 0) groupId = null;
-
-            String artifactId = (String) artifactParts.get(1);
-            if (artifactId.length() == 0) artifactId = null;
-
-            String version = (String) artifactParts.get(2);
-            if (version.length() == 0) version = null;
-
-            String type = (String) artifactParts.get(3);
-            if (type.length() == 0) type = null;
-
-            artifact = new Artifact(groupId, artifactId, version, type);
+            artifact = Artifact.createPartial(artifactString);
         } else {
             artifact = null;
         }

Modified: geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Artifact.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Artifact.java?rev=674396&r1=674395&r2=674396&view=diff
==============================================================================
--- geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Artifact.java
(original)
+++ geronimo/server/branches/2.1/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/Artifact.java
Sun Jul  6 21:38:55 2008
@@ -58,7 +58,7 @@
     private static Artifact create(String id, boolean requireArtifactId) {
         String[] parts = id.split("/", -1);
         if (parts.length != 4) {
-            throw new IllegalArgumentException("Invalid id: " + id);
+            throw new IllegalArgumentException("id must be in the form [groupId]/[artifactId]/[version]/[type]
: " + id);
         }
         for (int i = 0; i < parts.length; i++) {
             if (parts[i].equals("")) {

Modified: geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java?rev=674396&r1=674395&r2=674396&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
(original)
+++ geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/main/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilder.java
Sun Jul  6 21:38:55 2008
@@ -21,8 +21,11 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
 import javax.xml.namespace.QName;
@@ -42,6 +45,8 @@
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Dependency;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.schema.SchemaConversionUtils;
@@ -73,6 +78,7 @@
     private final int defaultNumPartitions;
     private final AbstractNameQuery defaultBackingStrategyFactoryName;
     private final AbstractNameQuery defaultClusterName;
+    private final Artifact artifactToRemoveFromEnvironment;
     private final Environment defaultEnvironment;
 
     public WADITomcatClusteringBuilder(int defaultSweepInterval,
@@ -80,6 +86,7 @@
             int defaultNumPartitions,
             AbstractNameQuery defaultBackingStrategyFactoryName,
             AbstractNameQuery defaultClusterName,
+			Artifact artifactToRemoveFromEnvironment,
             Environment defaultEnvironment) {
         if (defaultSweepInterval < 1) {
             throw new IllegalArgumentException("defaultSweepInterval is lower than 1");
@@ -91,6 +98,8 @@
             throw new IllegalArgumentException("defaultBackingStrategyFactoryName is required");
         } else if (null == defaultClusterName) {
             throw new IllegalArgumentException("defaultClusterName is required");
+        } else if (null == artifactToRemoveFromEnvironment) {
+            throw new IllegalArgumentException("artifactToRemoveFromEnvironment is required");
         } else if (null == defaultEnvironment) {
             throw new IllegalArgumentException("defaultEnvironment is required");
         }
@@ -99,11 +108,13 @@
         this.defaultNumPartitions = defaultNumPartitions;
         this.defaultBackingStrategyFactoryName = defaultBackingStrategyFactoryName;
         this.defaultClusterName = defaultClusterName;
+        this.artifactToRemoveFromEnvironment = artifactToRemoveFromEnvironment;
         this.defaultEnvironment = defaultEnvironment;
     }
 
     public void buildEnvironment(XmlObject container, Environment environment) throws DeploymentException
{
         if (getWadiClusterConfig(container) != null) {
+            filterDependencies(environment);
             EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
         }
     }
@@ -123,6 +134,19 @@
         }
     }
 
+    protected void filterDependencies(Environment environment) {
+        List<Dependency> dependencies = environment.getDependencies();
+        dependencies = new ArrayList<Dependency>(dependencies);
+        for (Iterator<Dependency> iterator = dependencies.iterator(); iterator.hasNext();)
{
+            Dependency dependency = iterator.next();
+            Artifact dependencyArtifact = dependency.getArtifact();
+            if (artifactToRemoveFromEnvironment.matches(dependencyArtifact)) {
+                iterator.remove();
+            }
+        }
+        environment.setDependencies(dependencies);
+    }
+
     protected GBeanData extractWebModule(DeploymentContext moduleContext) throws DeploymentException
{
         Configuration configuration = moduleContext.getConfiguration();
         AbstractNameQuery webModuleQuery = new AbstractNameQuery(configuration.getId(),
@@ -300,6 +324,7 @@
     public static final String GBEAN_ATTR_DFT_NUM_PARTITIONS = "defaultNumPartitions";
     public static final String GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME = "defaultBackingStrategyFactoryName";
     public static final String GBEAN_ATTR_DFT_CLUSTER_NAME = "defaultClusterName";
+    public static final String GBEAN_ATTR_ARTIFACT_TO_REMOVE = "artifactToRemoveFromEnvironment";
     public static final String GBEAN_ATTR_DFT_ENVIRONMENT = "defaultEnvironment";
 
     static {
@@ -312,6 +337,7 @@
         infoBuilder.addAttribute(GBEAN_ATTR_DFT_NUM_PARTITIONS, int.class, true);
         infoBuilder.addAttribute(GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME, AbstractNameQuery.class,
true);
         infoBuilder.addAttribute(GBEAN_ATTR_DFT_CLUSTER_NAME, AbstractNameQuery.class, true);
+        infoBuilder.addAttribute(GBEAN_ATTR_ARTIFACT_TO_REMOVE, Artifact.class, true);
         infoBuilder.addAttribute(GBEAN_ATTR_DFT_ENVIRONMENT, Environment.class, true);
 
         infoBuilder.setConstructor(new String[]{GBEAN_ATTR_DFT_SWEEP_INTERVAL,
@@ -319,6 +345,7 @@
                 GBEAN_ATTR_DFT_NUM_PARTITIONS,
                 GBEAN_ATTR_DFT_BACKING_STRATEGY_FACTORY_NAME,
                 GBEAN_ATTR_DFT_CLUSTER_NAME,
+				GBEAN_ATTR_ARTIFACT_TO_REMOVE,
                 GBEAN_ATTR_DFT_ENVIRONMENT});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();

Modified: geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java?rev=674396&r1=674395&r2=674396&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java
(original)
+++ geronimo/server/branches/2.1/plugins/tomcat/geronimo-tomcat6-clustering-builder-wadi/src/test/java/org/apache/geronimo/tomcat/cluster/wadi/builder/WADITomcatClusteringBuilderTest.java
Sun Jul  6 21:38:55 2008
@@ -24,6 +24,7 @@
 import java.net.URISyntaxException;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -41,7 +42,9 @@
 import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Dependency;
 import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.ImportType;
 import org.apache.geronimo.tomcat.TomcatWebAppContext;
 import org.apache.geronimo.tomcat.cluster.ClusteredManagerRetriever;
 import org.apache.geronimo.tomcat.cluster.wadi.WADIClusteredValveRetriever;
@@ -64,40 +67,48 @@
     private AbstractNameQuery backingStrategyFactoryQuery;
     private WADITomcatClusteringBuilder builder;
     private Artifact artifact;
+    private Artifact artifactToRemove;
     private Map<AbstractName, GBeanData> addedGBeanData;
     private String contextPath;
+    private Artifact dependencyToMerge;
 
     @Override
     protected void setUp() throws Exception {
         artifact = new Artifact("groupId", "artifactId", "2.0", "car");
+        artifactToRemove = new Artifact("groupId", "artifactToRemoveId", (String) null, "car");
         clusterNameQuery = new AbstractNameQuery(artifact, Collections.singletonMap("name",
"ClusterName"));
         backingStrategyFactoryQuery = new AbstractNameQuery(BackingStrategyFactory.class.getName());
         contextPath = "/test-path";
         addedGBeanData = new HashMap<AbstractName, GBeanData>();
         
-        builder = new WADITomcatClusteringBuilder(1,
-            2,
-            3,
-            backingStrategyFactoryQuery,
-            clusterNameQuery,
-            new Environment()) {
-            @Override
-            protected GBeanData extractWebModule(DeploymentContext moduleContext) throws
DeploymentException {
-                GBeanData gbeanData = new GBeanData(TomcatWebAppContext.GBEAN_INFO);
-                gbeanData.setAttribute("contextPath", contextPath);
-                return gbeanData;
-            }
-            @Override
-            protected AbstractName newGBeanName(DeploymentContext moduleContext, String name)
{
-                return newGBeanNameFor(name);
-            }
-            @Override
-            protected void addGBean(DeploymentContext moduleContext, GBeanData beanData)
throws GBeanAlreadyExistsException {
-                addedGBeanData.put(beanData.getAbstractName(), beanData);
-            }
-        };
+        Environment defaultEnvironment = new Environment();
+        dependencyToMerge = new Artifact("groupId", "artifactToMergeId", "2.0", "car");
+        defaultEnvironment.addDependency(new Dependency(dependencyToMerge, ImportType.ALL));
+        builder = new MockedEnvironment(1,
+                2,
+                3,
+                backingStrategyFactoryQuery,
+                clusterNameQuery,
+                artifactToRemove,
+                defaultEnvironment);
         
-        new NamespaceDrivenBuilderCollection(Collections.singleton(builder), GerClusteringDocument.type.getDocumentElementName());
+        new NamespaceDrivenBuilderCollection(Collections.singleton(builder),
+                GerClusteringDocument.type.getDocumentElementName());
+    }
+    
+    public void testBuiltEnvironmentDoesNotContainArtifactToRemove() throws Exception {
+        XmlObject container = newContainer("testBuiltGBeans");
+
+        Environment environment = new Environment();
+        environment.addDependency(new Dependency(new Artifact(artifactToRemove.getGroupId(),
+                artifactToRemove.getArtifactId(),
+                "2.0",
+                artifactToRemove.getType()), ImportType.ALL));
+        builder.buildEnvironment(container, environment);
+        
+        List<Dependency> dependencies = environment.getDependencies();
+        assertEquals(1, dependencies.size());
+        assertEquals(dependencyToMerge, dependencies.get(0).getArtifact());
     }
     
     public void testBuiltGBeans() throws Exception {
@@ -193,4 +204,40 @@
         return container;
     }
 
+    private final class MockedEnvironment extends WADITomcatClusteringBuilder {
+
+        private MockedEnvironment(int defaultSweepInterval,
+                int defaultSessionTimeout,
+                int defaultNumPartitions,
+                AbstractNameQuery defaultBackingStrategyFactoryName,
+                AbstractNameQuery defaultClusterName,
+                Artifact artifactToRemoveFromEnvironment,
+                Environment defaultEnvironment) {
+            super(defaultSweepInterval,
+                    defaultSessionTimeout,
+                    defaultNumPartitions,
+                    defaultBackingStrategyFactoryName,
+                    defaultClusterName,
+                    artifactToRemoveFromEnvironment,
+                    defaultEnvironment);
+        }
+
+        @Override
+        protected GBeanData extractWebModule(DeploymentContext moduleContext) throws DeploymentException
{
+            GBeanData gbeanData = new GBeanData(TomcatWebAppContext.GBEAN_INFO);
+            gbeanData.setAttribute("contextPath", contextPath);
+            return gbeanData;
+        }
+
+        @Override
+        protected AbstractName newGBeanName(DeploymentContext moduleContext, String name)
{
+            return newGBeanNameFor(name);
+        }
+
+        @Override
+        protected void addGBean(DeploymentContext moduleContext, GBeanData beanData) throws
GBeanAlreadyExistsException {
+            addedGBeanData.put(beanData.getAbstractName(), beanData);
+        }
+    }
+
 }

Modified: geronimo/server/branches/2.1/plugins/tomcat/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/tomcat/pom.xml?rev=674396&r1=674395&r2=674396&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/tomcat/pom.xml (original)
+++ geronimo/server/branches/2.1/plugins/tomcat/pom.xml Sun Jul  6 21:38:55 2008
@@ -40,6 +40,7 @@
         <module>geronimo-tomcat6</module>
         <module>geronimo-tomcat6-builder</module>
         <module>tomcat6</module>
+        <module>tomcat6-no-ha</module>
         <module>tomcat6-deployer</module>
         <module>geronimo-tomcat6-clustering-wadi</module>
         <module>geronimo-tomcat6-clustering-builder-wadi</module>

Modified: geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-builder-wadi/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-builder-wadi/src/main/plan/plan.xml?rev=674396&r1=674395&r2=674396&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-builder-wadi/src/main/plan/plan.xml
(original)
+++ geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-builder-wadi/src/main/plan/plan.xml
Sun Jul  6 21:38:55 2008
@@ -26,6 +26,7 @@
         <attribute name="defaultNumPartitions">24</attribute>
         <attribute name="defaultBackingStrategyFactoryName">?name=DefaultBackingStrategyFactory</attribute>
         <attribute name="defaultClusterName">?name=DefaultCluster</attribute>
+        <attribute name="artifactToRemoveFromEnvironment">org.apache.geronimo.configs/tomcat6//car</attribute>
         <xml-attribute name="defaultEnvironment">
             <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
                 <dependencies>

Modified: geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-wadi/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-wadi/pom.xml?rev=674396&r1=674395&r2=674396&view=diff
==============================================================================
--- geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-wadi/pom.xml (original)
+++ geronimo/server/branches/2.1/plugins/tomcat/tomcat6-clustering-wadi/pom.xml Sun Jul  6
21:38:55 2008
@@ -44,7 +44,7 @@
 
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
-            <artifactId>tomcat6</artifactId>
+            <artifactId>tomcat6-no-ha</artifactId>
             <version>${version}</version>
             <type>car</type>
         </dependency>



Mime
View raw message