geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r887507 - in /geronimo/server/trunk/plugins: aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/ connector-1_6/geronimo-connector-bui...
Date Sat, 05 Dec 2009 06:24:28 GMT
Author: gawor
Date: Sat Dec  5 06:24:26 2009
New Revision: 887507

URL: http://svn.apache.org/viewvc?rev=887507&view=rev
Log:
GERONIMO-4975: Simplify integrating new ModuleBuilders with EARConfigBuilder

Removed:
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/UnavailableModuleBuilder.java
Modified:
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java
    geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/SwitchingModuleBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
    geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java
Sat Dec  5 06:24:26 2009
@@ -216,4 +216,11 @@
         return null;
     }
 
+    public int getPriority() {
+        return 50;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return AriesAppModule.class.isAssignableFrom(moduleType);
+    }
 }

Modified: geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Sat Dec  5 06:24:26 2009
@@ -839,6 +839,14 @@
         return GERAPPCLIENT_NAMESPACE;
     }
 
+    public int getPriority() {
+        return 40;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return AppClientModule.class.isAssignableFrom(moduleType);
+    }
+    
     public void addManifestClassPath(DeploymentContext deploymentContext, JarFile earFile,
JarFile jarFile, URI jarFileLocation) throws DeploymentException {
         Manifest manifest;
         try {

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Sat Dec  5 06:24:26 2009
@@ -536,6 +536,14 @@
         return GERCONNECTOR_NAMESPACE;
     }
 
+    public int getPriority() {
+        return 30;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return ConnectorModule.class.isAssignableFrom(moduleType);
+    }
+    
     private void addConnectorGBeans(EARContext earContext, AbstractName jcaResourceName,
GBeanData resourceAdapterModuleData, ConnectorType connector, GerConnectorType geronimoConnector,
Bundle bundle) throws DeploymentException {
         ResourceadapterType resourceadapter = connector.getResourceadapter();
 

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
Sat Dec  5 06:24:26 2009
@@ -22,6 +22,7 @@
 import java.net.URL;
 import java.sql.Connection;
 import java.sql.Statement;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -29,7 +30,6 @@
 import java.util.HashMap;
 import java.util.jar.JarFile;
 
-import javax.naming.Reference;
 import javax.sql.DataSource;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.DeploymentContext;
@@ -41,7 +41,6 @@
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.j2ee.deployment.ActivationSpecInfoLocator;
 import org.apache.geronimo.j2ee.deployment.EARConfigBuilder;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
@@ -90,22 +89,6 @@
     private Environment defaultEnvironment;
     private ConfigurationStore configurationStore = new MockConfigStore();
     private MockRepository repository;
-
-    private ActivationSpecInfoLocator activationSpecInfoLocator = new ActivationSpecInfoLocator()
{
-
-        public Reference createResourceRef(AbstractNameQuery containerId, Class iface, Configuration
configuration) {
-            return null;
-        }
-
-        public Reference createAdminObjectRef(AbstractNameQuery containerId, Class iface,
Configuration configuration) {
-            return null;
-        }
-
-        public GBeanData locateActivationSpecInfo(AbstractNameQuery nameQuery, String messageListenerInterface,
Configuration configuration) {
-            return null;
-        }
-    };
-
     private Kernel kernel;
     private ConfigurationManager configurationManager;
     private static final Naming naming = new Jsr77Naming();
@@ -122,17 +105,15 @@
             rarFile = DeploymentUtil.createJarFile(new File(BASEDIR, "target/test-ear-noger.ear"));
             GBeanBuilder serviceBuilder = new GBeanBuilder(null, null);
 //            EARConfigBuilder configBuilder = new EARConfigBuilder(defaultEnvironment, transactionContextManagerName,
connectionTrackerName, null, null, null, new AbstractNameQuery(serverName, J2EEServerImpl.GBEAN_INFO.getInterfaces()),
null, null, ejbReferenceBuilder, null,
+            List<ModuleBuilder> builders = new ArrayList<ModuleBuilder>();
+            builders.add(new ConnectorModuleBuilder(defaultEnvironment, defaultMaxSize, defaultMinSize,
defaultBlockingTimeoutMilliseconds, defaultidleTimeoutMinutes, defaultXATransactionCaching,
defaultXAThreadCaching, defaultWorkManagerName, Collections.<NamespaceDrivenBuilder>singleton(serviceBuilder)));
             EARConfigBuilder configBuilder = new EARConfigBuilder(defaultEnvironment,
                     transactionManagerName,
                     connectionTrackerName,
                     null,
                     new AbstractNameQuery(serverName, J2EEServerImpl.GBEAN_INFO.getInterfaces()),
                     Collections.singleton(repository),
-                    null,
-                    null,
-                    new ConnectorModuleBuilder(defaultEnvironment, defaultMaxSize, defaultMinSize,
defaultBlockingTimeoutMilliseconds, defaultidleTimeoutMinutes, defaultXATransactionCaching,
defaultXAThreadCaching, defaultWorkManagerName, Collections.<NamespaceDrivenBuilder>singleton(serviceBuilder)),
-                    activationSpecInfoLocator,
-                    null,
+                    builders, 
                     serviceBuilder,
                     null,
                     kernel.getNaming(),

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Sat Dec  5 06:24:26 2009
@@ -24,6 +24,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -60,7 +61,6 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.ReferencePatterns;
-import org.apache.geronimo.gbean.SingleElementCollection;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamReference;
@@ -123,11 +123,7 @@
 
     private final ConfigurationManager configurationManager;
     private final Collection<? extends Repository> repositories;
-    private final SingleElementCollection ejbConfigBuilder;
-    private final SingleElementCollection webConfigBuilder;
-    private final SingleElementCollection connectorConfigBuilder;
-    private final SingleElementCollection appClientConfigBuilder;
-    private final SingleElementCollection resourceReferenceBuilder;
+    private final Collection<ModuleBuilder> moduleBuilders;
     private final NamespaceDrivenBuilderCollection serviceBuilders;
     private final Collection<ModuleBuilderExtension> persistenceUnitBuilders;
 
@@ -154,57 +150,13 @@
         }
     };
 
-//    static {
-//        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(EARConfigBuilder.class,
NameFactory.CONFIG_BUILDER);
-//        infoBuilder.addAttribute("defaultEnvironment", Environment.class, true, true);
-//        infoBuilder.addAttribute("transactionManagerAbstractName", AbstractNameQuery.class,
true);
-//        infoBuilder.addAttribute("connectionTrackerAbstractName", AbstractNameQuery.class,
true);
-//        infoBuilder.addAttribute("corbaGBeanAbstractName", AbstractNameQuery.class, true);
-//        infoBuilder.addAttribute("serverName", AbstractNameQuery.class, true);
-//
-//        infoBuilder.addReference("Repositories", Repository.class, "Repository");
-//        infoBuilder.addReference("EJBConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("WebConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("ConnectorConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("ActivationSpecInfoLocator", ActivationSpecInfoLocator.class,
NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("AppClientConfigBuilder", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("PersistenceUnitBuilders", ModuleBuilderExtension.class,
NameFactory.MODULE_BUILDER);
-//        infoBuilder.addReference("ArtifactResolvers", ArtifactResolver.class, "ArtifactResolver");
-//
-//        infoBuilder.addAttribute("kernel", Kernel.class, false);
-//
-//        infoBuilder.setConstructor(new String[]{
-//                "defaultEnvironment",
-//                "transactionManagerAbstractName",
-//                "connectionTrackerAbstractName",
-//                "corbaGBeanAbstractName",
-//                "serverName",
-//                "Repositories",
-//                "EJBConfigBuilder",
-//                "WebConfigBuilder",
-//                "ConnectorConfigBuilder",
-//                "ActivationSpecInfoLocator",
-//                "AppClientConfigBuilder",
-//                "ServiceBuilders",
-//                "PersistenceUnitBuilders",
-//                "ArtifactResolvers",
-//                "kernel"
-//        });
-//
-//    }
-
     public EARConfigBuilder(@ParamAttribute(name = "defaultEnvironment") Environment defaultEnvironment,
                             @ParamAttribute(name = "transactionManagerAbstractName") AbstractNameQuery
transactionManagerAbstractName,
                             @ParamAttribute(name = "connectionTrackerAbstractName") AbstractNameQuery
connectionTrackerAbstractName,
                             @ParamAttribute(name = "corbaGBeanAbstractName") AbstractNameQuery
corbaGBeanAbstractName,
                             @ParamAttribute(name = "serverName") AbstractNameQuery serverName,
                             @ParamReference(name = "Repositories", namingType = "Repository")Collection<?
extends Repository> repositories,
-                            @ParamReference(name = "EJBConfigBuilder", namingType = NameFactory.MODULE_BUILDER)Collection<ModuleBuilder>
ejbConfigBuilder,
-                            @ParamReference(name = "WebConfigBuilder", namingType = NameFactory.MODULE_BUILDER)Collection<ModuleBuilder>
webConfigBuilder,
-                            @ParamReference(name = "ConnectorConfigBuilder", namingType =
NameFactory.MODULE_BUILDER)Collection<ModuleBuilder> connectorConfigBuilder,
-                            @ParamReference(name = "ActivationSpecInfoLocator", namingType
= NameFactory.MODULE_BUILDER)Collection<ModuleBuilder> resourceReferenceBuilder,
-                            @ParamReference(name = "AppClientConfigBuilder", namingType =
NameFactory.MODULE_BUILDER)Collection<ModuleBuilder> appClientConfigBuilder,
+                            @ParamReference(name = "ModuleBuilders", namingType = NameFactory.MODULE_BUILDER)Collection<ModuleBuilder>
moduleBuilders,
                             @ParamReference(name = "ServiceBuilders", namingType = NameFactory.MODULE_BUILDER)Collection<NamespaceDrivenBuilder>
serviceBuilders,
                             @ParamReference(name = "PersistenceUnitBuilders", namingType
= NameFactory.MODULE_BUILDER)Collection<ModuleBuilderExtension> persistenceUnitBuilders,
                             @ParamReference(name = "ArtifactResolvers", namingType = "ArtifactResolver")Collection<?
extends ArtifactResolver> artifactResolvers,
@@ -217,11 +169,7 @@
                 serverName,
                 ConfigurationUtil.getConfigurationManager(kernel),
                 repositories,
-                new SingleElementCollection<ModuleBuilder>(ejbConfigBuilder),
-                new SingleElementCollection<ModuleBuilder>(webConfigBuilder),
-                new SingleElementCollection<ModuleBuilder>(connectorConfigBuilder),
-                new SingleElementCollection<ModuleBuilder>(resourceReferenceBuilder),
-                new SingleElementCollection<ModuleBuilder>(appClientConfigBuilder),
+                moduleBuilders,
                 serviceBuilders,
                 persistenceUnitBuilders,
                 kernel.getNaming(), artifactResolvers,
@@ -234,11 +182,7 @@
                             AbstractNameQuery corbaGBeanAbstractName,
                             AbstractNameQuery serverName,
                             Collection<? extends Repository> repositories,
-                            ModuleBuilder ejbConfigBuilder,
-                            ModuleBuilder webConfigBuilder,
-                            ModuleBuilder connectorConfigBuilder,
-                            ActivationSpecInfoLocator activationSpecInfoLocator,
-                            ModuleBuilder appClientConfigBuilder,
+                            Collection<ModuleBuilder> moduleBuilders,
                             NamespaceDrivenBuilder serviceBuilder,
                             ModuleBuilderExtension persistenceUnitBuilder,
                             Naming naming,
@@ -250,11 +194,7 @@
                 serverName,
                 null,
                 repositories,
-                new SingleElementCollection<ModuleBuilder>(ejbConfigBuilder),
-                new SingleElementCollection<ModuleBuilder>(webConfigBuilder),
-                new SingleElementCollection<ModuleBuilder>(connectorConfigBuilder),
-                new SingleElementCollection<ActivationSpecInfoLocator>(activationSpecInfoLocator),
-                new SingleElementCollection<ModuleBuilder>(appClientConfigBuilder),
+                moduleBuilders, 
                 serviceBuilder == null ? Collections.<NamespaceDrivenBuilder>emptySet()
: Collections.singleton(serviceBuilder),
                 persistenceUnitBuilder == null ? Collections.<ModuleBuilderExtension>emptySet()
: Collections.singleton(persistenceUnitBuilder),
                 naming,
@@ -269,11 +209,7 @@
                              AbstractNameQuery serverName,
                              ConfigurationManager configurationManager,
                              Collection<? extends Repository> repositories,
-                             SingleElementCollection ejbConfigBuilder,
-                             SingleElementCollection webConfigBuilder,
-                             SingleElementCollection connectorConfigBuilder,
-                             SingleElementCollection resourceReferenceBuilder,
-                             SingleElementCollection appClientConfigBuilder,
+                             Collection<ModuleBuilder> moduleBuilders, 
                              Collection<NamespaceDrivenBuilder> serviceBuilders,
                              Collection<ModuleBuilderExtension> persistenceUnitBuilders,
                              Naming naming,
@@ -283,11 +219,7 @@
         this.repositories = repositories;
         this.defaultEnvironment = defaultEnvironment;
 
-        this.ejbConfigBuilder = ejbConfigBuilder;
-        this.resourceReferenceBuilder = resourceReferenceBuilder;
-        this.webConfigBuilder = webConfigBuilder;
-        this.connectorConfigBuilder = connectorConfigBuilder;
-        this.appClientConfigBuilder = appClientConfigBuilder;
+        this.moduleBuilders = moduleBuilders;
         this.serviceBuilders = new NamespaceDrivenBuilderCollection(serviceBuilders);
         this.persistenceUnitBuilders = persistenceUnitBuilders;
 
@@ -315,21 +247,21 @@
     public AbstractNameQuery getCorbaGBeanName() {
         return corbaGBeanObjectName;
     }
-
+    
     private ModuleBuilder getEjbConfigBuilder() {
-        return (ModuleBuilder) ejbConfigBuilder.getElement();
+        return getModuleBuilder(EJBModule.class);
     }
-
+        
     private ModuleBuilder getWebConfigBuilder() {
-        return (ModuleBuilder) webConfigBuilder.getElement();
+        return getModuleBuilder(WebModule.class);
     }
-
+        
     private ModuleBuilder getConnectorConfigBuilder() {
-        return (ModuleBuilder) connectorConfigBuilder.getElement();
+        return getModuleBuilder(ConnectorModule.class);
     }
-
+        
     private ModuleBuilder getAppClientConfigBuilder() {
-        return (ModuleBuilder) appClientConfigBuilder.getElement();
+        return getModuleBuilder(AppClientModule.class);
     }
 
     public Object getDeploymentPlan(File planFile, JarFile jarFile, ModuleIDBuilder idBuilder)
throws DeploymentException {
@@ -347,18 +279,13 @@
 
         // get the modules either the application plan or for a stand alone module from the
specific deployer
         Module module = null;
-        if (getWebConfigBuilder() != null) {
-            module = getWebConfigBuilder().createModule(planFile, jarFile, naming, idBuilder);
-        }
-        if (module == null && getEjbConfigBuilder() != null) {
-            module = getEjbConfigBuilder().createModule(planFile, jarFile, naming, idBuilder);
-        }
-        if (module == null && getConnectorConfigBuilder() != null) {
-            module = getConnectorConfigBuilder().createModule(planFile, jarFile, naming,
idBuilder);
-        }
-        if (module == null && getAppClientConfigBuilder() != null) {
-            module = getAppClientConfigBuilder().createModule(planFile, jarFile, naming,
idBuilder);
+        for (ModuleBuilder moduleBuilder : getSortedModuleBuilders()) {
+            module = moduleBuilder.createModule(planFile, jarFile, naming, idBuilder);
+            if (module != null) {
+                break;
+            }
         }
+
         if (module == null) {
             return null;
         }
@@ -1136,29 +1063,45 @@
         return null;
     }
 
+    private List<ModuleBuilder> getSortedModuleBuilders() {
+        List<ModuleBuilder> list = new ArrayList<ModuleBuilder>(moduleBuilders);
+        Collections.sort(list, new ModuleBuilderComparator());
+        return list;        
+    }
+    
+    private static class ModuleBuilderComparator implements Comparator<ModuleBuilder>
{
+        public int compare(ModuleBuilder o1, ModuleBuilder o2) {
+            return o1.getPriority() - o2.getPriority();
+        }
+    }
+    
+    private ModuleBuilder getModuleBuilder(Class module) {
+        for (ModuleBuilder builder : moduleBuilders) {
+            if (builder.supportsModule(module)) {
+                return builder;
+            }
+        }
+        return null;
+    }
+    
     private ModuleBuilder getBuilder(Module module) throws DeploymentException {
-        if (module instanceof EJBModule) {
-            if (getEjbConfigBuilder() == null) {
+        ModuleBuilder builder = getModuleBuilder(module.getClass());
+        
+        if (builder == null) {
+            if (module instanceof EJBModule) {
                 throw new DeploymentException("Cannot deploy ejb application; No ejb deployer
defined: " + module.getModuleURI());
-            }
-            return getEjbConfigBuilder();
-        } else if (module instanceof WebModule) {
-            if (getWebConfigBuilder() == null) {
+            } else if (module instanceof WebModule) {
                 throw new DeploymentException("Cannot deploy web application; No war deployer
defined: " + module.getModuleURI());
-            }
-            return getWebConfigBuilder();
-        } else if (module instanceof ConnectorModule) {
-            if (getConnectorConfigBuilder() == null) {
+            } else if (module instanceof ConnectorModule) {
                 throw new DeploymentException("Cannot deploy resource adapter; No rar deployer
defined: " + module.getModuleURI());
-            }
-            return getConnectorConfigBuilder();
-        } else if (module instanceof AppClientModule) {
-            if (getAppClientConfigBuilder() == null) {
+            } else if (module instanceof AppClientModule) {
                 throw new DeploymentException("Cannot deploy app client; No app client deployer
defined: " + module.getModuleURI());
+            } else {
+                throw new DeploymentException("Cannot deploy application; No deployer for
module: " + module.getModuleURI());
             }
-            return getAppClientConfigBuilder();
-        }
-        throw new IllegalArgumentException("Unknown module type: " + module.getClass().getName());
+        } 
+        
+        return builder;
     }
 
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
Sat Dec  5 06:24:26 2009
@@ -33,6 +33,9 @@
  * @version $Rev:386276 $ $Date$
  */
 public interface ModuleBuilder {
+    
+    int NORMAL_PRIORITY = 50;
+    
     Module createModule(File plan, JarFile moduleFile, Naming naming, ModuleIDBuilder idBuilder)
throws DeploymentException;
 
     Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl,
Environment environment, Object moduleContextInfo, AbstractName earName, Naming naming, ModuleIDBuilder
idBuilder) throws DeploymentException;
@@ -44,4 +47,15 @@
     void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection repository)
throws DeploymentException;
 
     String getSchemaNamespace();
+    
+    /**
+     * Returns sort order priority.  Lower numbers indicate higher priority.
+     */
+    int getPriority();
+    
+    /**
+     * Returns true if this ModuleBuilder creates and installs module of the specified type.

+     *  
+     */
+    boolean supportsModule(Class moduleType);
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/SwitchingModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/SwitchingModuleBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/SwitchingModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/SwitchingModuleBuilder.java
Sat Dec  5 06:24:26 2009
@@ -50,9 +50,14 @@
 
     private final Map namespaceToBuilderMap = new HashMap();
 
+    private Class supportedModuleType;
+    private int priority = NORMAL_PRIORITY;
     private String defaultNamespace;
 
-    public SwitchingModuleBuilder(Collection builders) {
+    public SwitchingModuleBuilder(Collection builders, String supportedModule, int priority)
throws Exception {
+        this.supportedModuleType = SwitchingModuleBuilder.class.getClassLoader().loadClass(supportedModule);
+        this.priority = priority;
+        
         ReferenceCollection buildersCollection = (ReferenceCollection) builders;
         buildersCollection.addReferenceCollectionListener(new ReferenceCollectionListener()
{
             public void memberAdded(ReferenceCollectionEvent event) {
@@ -170,15 +175,25 @@
         return null;
     }
 
+    public int getPriority() {
+        return priority;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return supportedModuleType.isAssignableFrom(moduleType);
+    }
+    
     public static final GBeanInfo GBEAN_INFO;
 
     static {
         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(SwitchingModuleBuilder.class,
NameFactory.MODULE_BUILDER);
         infoBuilder.addAttribute("defaultNamespace", String.class, true, true);
+        infoBuilder.addAttribute("supportedModule", String.class, true, true);
+        infoBuilder.addAttribute("priority", int.class, true, true);
         infoBuilder.addReference("ModuleBuilders", ModuleBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addInterface(ModuleBuilder.class);
 
-        infoBuilder.setConstructor(new String[] {"ModuleBuilders"});
+        infoBuilder.setConstructor(new String[] {"ModuleBuilders", "supportedModule","priority"});
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }
 

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTestSupport.java
Sat Dec  5 06:24:26 2009
@@ -16,8 +16,10 @@
  */
 package org.apache.geronimo.j2ee.deployment;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.HashSet;
@@ -72,10 +74,6 @@
     
     protected static MockConnectorConfigBuilder connectorConfigBuilder = new MockConnectorConfigBuilder();
     
-    protected static ActivationSpecInfoLocator activationSpecInfoLocator = connectorConfigBuilder;
-    
-    protected static ModuleBuilder appClientConfigBuilder = null;
-    
     protected final static ModuleIDBuilder idBuilder = new ModuleIDBuilder();
     
     protected static final NamespaceDrivenBuilder securityBuilder = null;
@@ -106,7 +104,6 @@
     
     protected static final AbstractName raModuleName = naming.createChildName(earName, "rar",
NameFactory.RESOURCE_ADAPTER_MODULE);
 
-
     protected Map<String, Artifact> locations = new HashMap<String, Artifact>();
 
     protected Environment defaultParentId;
@@ -136,6 +133,14 @@
         defaultParentId.addDependency(new Artifact("org.apache.geronimo.tests", "test", "1",
"car"), ImportType.ALL);
     }
 
+    private List<ModuleBuilder> getBuilders(ModuleBuilder...builders) {
+        List<ModuleBuilder> b = new ArrayList<ModuleBuilder>();
+        for (ModuleBuilder builder : builders) {
+            b.add(builder);
+        }
+        return b;
+    }
+    
     public void testBuildConfiguration() throws Exception {
         ConfigurationData configurationData = null;
         DeploymentContext context = null;
@@ -146,11 +151,9 @@
                     corbaGBeanAbstractNameQuery,
                     null,
                     Collections.singleton(repository),
-                    ejbConfigBuilder,
-                    webConfigBuilder,
-                    connectorConfigBuilder,
-                    activationSpecInfoLocator,
-                    appClientConfigBuilder,
+                    getBuilders(ejbConfigBuilder,
+                                webConfigBuilder,
+                                connectorConfigBuilder),              
                     serviceBuilder,
                     persistenceUnitBuilder,
                     naming,
@@ -177,11 +180,9 @@
                 corbaGBeanAbstractNameQuery,
                 null,
                 null,
-                ejbConfigBuilder,
-                webConfigBuilder,
-                connectorConfigBuilder,
-                activationSpecInfoLocator,
-                appClientConfigBuilder,
+                getBuilders(ejbConfigBuilder,
+                            webConfigBuilder,
+                            connectorConfigBuilder),
                 serviceBuilder,
                 persistenceUnitBuilder,
                 naming, artifactResolvers, bundleContext);
@@ -212,11 +213,9 @@
                 corbaGBeanAbstractNameQuery,
                 null,
                 null,
-                ejbConfigBuilder,
-                webConfigBuilder,
-                connectorConfigBuilder,
-                activationSpecInfoLocator,
-                appClientConfigBuilder,
+                getBuilders(ejbConfigBuilder,
+                            webConfigBuilder,
+                            connectorConfigBuilder),
                 serviceBuilder,
                 persistenceUnitBuilder,
                 naming, artifactResolvers, bundleContext);
@@ -247,11 +246,9 @@
                 corbaGBeanAbstractNameQuery,
                 null,
                 null,
-                ejbConfigBuilder,
-                webConfigBuilder,
-                connectorConfigBuilder,
-                activationSpecInfoLocator,
-                appClientConfigBuilder,
+                getBuilders(ejbConfigBuilder,
+                            webConfigBuilder,
+                            connectorConfigBuilder),
                 serviceBuilder,
                 persistenceUnitBuilder,
                 naming, artifactResolvers, bundleContext);
@@ -282,11 +279,9 @@
                 corbaGBeanAbstractNameQuery,
                 null,
                 null,
-                ejbConfigBuilder,
-                webConfigBuilder,
-                connectorConfigBuilder,
-                activationSpecInfoLocator,
-                appClientConfigBuilder,
+                getBuilders(ejbConfigBuilder,
+                            webConfigBuilder,
+                            connectorConfigBuilder),
                 serviceBuilder,
                 persistenceUnitBuilder,
                 naming, artifactResolvers, bundleContext);
@@ -317,11 +312,8 @@
                 corbaGBeanAbstractNameQuery,
                 null,
                 null,
-                null,
-                webConfigBuilder,
-                connectorConfigBuilder,
-                activationSpecInfoLocator,
-                appClientConfigBuilder,
+                getBuilders(webConfigBuilder,
+                            connectorConfigBuilder),
                 serviceBuilder,
                 persistenceUnitBuilder,
                 naming, artifactResolvers, bundleContext);
@@ -353,11 +345,8 @@
                 corbaGBeanAbstractNameQuery,
                 null,
                 null,
-                ejbConfigBuilder,
-                null,
-                connectorConfigBuilder,
-                activationSpecInfoLocator,
-                appClientConfigBuilder,
+                getBuilders(ejbConfigBuilder,
+                            connectorConfigBuilder),
                 serviceBuilder,
                 persistenceUnitBuilder,
                 naming, artifactResolvers, bundleContext);
@@ -388,11 +377,8 @@
                 corbaGBeanAbstractNameQuery,
                 null,
                 null,
-                ejbConfigBuilder,
-                webConfigBuilder,
-                null,
-                activationSpecInfoLocator,
-                appClientConfigBuilder,
+                getBuilders(ejbConfigBuilder,
+                             webConfigBuilder),
                 serviceBuilder,
                 persistenceUnitBuilder,
                 naming, artifactResolvers, bundleContext);

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
Sat Dec  5 06:24:26 2009
@@ -114,4 +114,12 @@
     public GBeanData locateConnectionFactoryInfo(GBeanData resourceAdapterModuleData, String
connectionFactoryInterfaceName) throws DeploymentException {
         return null;
     }
+
+    public int getPriority() {
+        return NORMAL_PRIORITY;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return ConnectorModule.class.isAssignableFrom(moduleType);
+    }
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
Sat Dec  5 06:24:26 2009
@@ -83,4 +83,12 @@
         return null;
     }
 
+    public int getPriority() {
+        return NORMAL_PRIORITY;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return EJBModule.class.isAssignableFrom(moduleType);
+    }
+
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/test/java/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
Sat Dec  5 06:24:26 2009
@@ -88,4 +88,12 @@
         return null;
     }
 
+    public int getPriority() {
+        return NORMAL_PRIORITY;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return WebModule.class.isAssignableFrom(moduleType);
+    }
+
 }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
Sat Dec  5 06:24:26 2009
@@ -746,6 +746,14 @@
         webModuleData.setReferencePattern("TrackedConnectionAssociator", moduleContext.getConnectionTrackerName());
     }
 
+    public int getPriority() {
+        return 10;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return WebModule.class.isAssignableFrom(moduleType);
+    }
+    
     private static class InternWrapper implements XMLStreamReader {
         private final XMLStreamReader delegate;
 

Modified: geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/j2ee/j2ee-deployer/src/main/plan/plan.xml Sat Dec  5 06:24:26
2009
@@ -28,9 +28,6 @@
         <reference name="Repositories">
             <!--<gbean-name>*:name=Repository,*</gbean-name>-->
         </reference>
-        <reference name="WebConfigBuilder">
-            <name>WebBuilder</name>
-        </reference>
         <references name="ServiceBuilders">
             <pattern>
                 <name>GBeanBuilder</name>
@@ -44,23 +41,21 @@
                 <name>PersistenceUnitBuilder</name>
             </pattern>
         </references>
-        <references name="EJBConfigBuilder">
+        <references name="ModuleBuilders">
+            <pattern>
+                <name>WebBuilder</name>
+            </pattern>
             <pattern>
                 <name>EJBBuilder</name>
             </pattern>
             <pattern>
-                <name>UnavailableEJBBuilder</name>
+                <name>ConnectorBuilder</name>
             </pattern>
-        </references>
-        <reference name="ConnectorConfigBuilder">
-            <name>ConnectorBuilder</name>
-        </reference>
-        <references name="AppClientConfigBuilder">
             <pattern>
                 <name>AppClientBuilder</name>
             </pattern>
             <pattern>
-                <name>UnavailableAppClientBuilder</name>
+                <name>AriesAppBuilder</name>
             </pattern>
         </references>
         <reference name="ArtifactResolvers">
@@ -82,6 +77,8 @@
     <!-- web switching builder -->
     <gbean name="WebBuilder" class="org.apache.geronimo.j2ee.deployment.SwitchingModuleBuilder">
         <attribute name="defaultNamespace">http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-${geronimoSchemaVersion}</attribute>
+        <attribute name="supportedModule">org.apache.geronimo.j2ee.deployment.WebModule</attribute>
+        <attribute name="priority">10</attribute>
         <references name="ModuleBuilders">
             <pattern>
                 <name>JettyWebBuilder</name>

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java?rev=887507&r1=887506&r2=887507&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
Sat Dec  5 06:24:26 2009
@@ -898,6 +898,14 @@
         return new AbstractNameQuery(artifact, nameMap, (Set) null);
     }
 
+    public int getPriority() {
+        return 20;
+    }
+    
+    public boolean supportsModule(Class moduleType) {
+        return EjbModule.class.isAssignableFrom(moduleType);
+    }
+    
     public static class EarData {
         private final Map<String, EjbModule> ejbModules = new TreeMap<String, EjbModule>();
         private final Map<String, EjbJarInfo> ejbJars = new TreeMap<String, EjbJarInfo>();



Mime
View raw message