geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r416533 - in /geronimo/branches/dain/openejb-2.2-merge: configs/client-corba/src/plan/ configs/openejb/ modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ modules/deployment/src/java/org/apache/geronimo/deployment/...
Date Fri, 23 Jun 2006 00:44:08 GMT
Author: dain
Date: Thu Jun 22 17:44:07 2006
New Revision: 416533

URL: http://svn.apache.org/viewvc?rev=416533&view=rev
Log:
Applied GERONIMO-1960 which verifies GBean references when the final configuration data is
created in a deployment context.
Fixed broken openejb references
Server now starts and runs

Modified:
    geronimo/branches/dain/openejb-2.2-merge/configs/client-corba/src/plan/plan.xml
    geronimo/branches/dain/openejb-2.2-merge/configs/openejb/project.xml
    geronimo/branches/dain/openejb-2.2-merge/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
    geronimo/branches/dain/openejb-2.2-merge/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/branches/dain/openejb-2.2-merge/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
    geronimo/branches/dain/openejb-2.2-merge/modules/kernel/src/java/org/apache/geronimo/gbean/SingleElementCollection.java

Modified: geronimo/branches/dain/openejb-2.2-merge/configs/client-corba/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/openejb-2.2-merge/configs/client-corba/src/plan/plan.xml?rev=416533&r1=416532&r2=416533&view=diff
==============================================================================
--- geronimo/branches/dain/openejb-2.2-merge/configs/client-corba/src/plan/plan.xml (original)
+++ geronimo/branches/dain/openejb-2.2-merge/configs/client-corba/src/plan/plan.xml Thu Jun
22 17:44:07 2006
@@ -54,9 +54,9 @@
         <attribute name="props">
             com.sun.CORBA.ORBServerHost=${PlanORBSSLHost}
         </attribute>
-        <dependency>
+        <!--dependency>
             <name>SecurityService</name>
-        </dependency>
+        </dependenc-->
         <dependency>
             <name>CORBASystemProperties</name>
         </dependency>

Modified: geronimo/branches/dain/openejb-2.2-merge/configs/openejb/project.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/openejb-2.2-merge/configs/openejb/project.xml?rev=416533&r1=416532&r2=416533&view=diff
==============================================================================
--- geronimo/branches/dain/openejb-2.2-merge/configs/openejb/project.xml (original)
+++ geronimo/branches/dain/openejb-2.2-merge/configs/openejb/project.xml Thu Jun 22 17:44:07
2006
@@ -68,7 +68,7 @@
             <version>${geronimo_version}</version>
             <type>car</type>
             <properties>
-                <geronimo.dependency>true</geronimo.dependency>
+                <geronimo.import>true</geronimo.import>
             </properties>
         </dependency>
 

Modified: geronimo/branches/dain/openejb-2.2-merge/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/openejb-2.2-merge/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java?rev=416533&r1=416532&r2=416533&view=diff
==============================================================================
--- geronimo/branches/dain/openejb-2.2-merge/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
(original)
+++ geronimo/branches/dain/openejb-2.2-merge/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
Thu Jun 22 17:44:07 2006
@@ -151,7 +151,7 @@
     private Kernel kernel;
     private EditableConfigurationManager configurationManager;
     private static final Naming naming = new Jsr77Naming();
-    private static final Artifact bootId = new Artifact("test", "test", "", "car");
+    private static final Artifact bootId = new Artifact("test", "test", "42", "car");
 
     private static final AbstractNameQuery connectionTrackerName = new AbstractNameQuery(null,
Collections.singletonMap("name", "ConnectionTracker"));
     private AbstractName serverName;
@@ -176,6 +176,10 @@
                 ModuleIDBuilder idBuilder = new ModuleIDBuilder();
                 Object plan = configBuilder.getDeploymentPlan(planFile, rarFile, idBuilder);
                 context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
rarFile, idBuilder), plan, rarFile, Collections.singleton(configurationStore), artifactResolver,
configurationStore);
+
+                // add the a j2ee server so the application context reference can be resolved
+                context.addGBean("geronimo", J2EEServerImpl.GBEAN_INFO);
+
                 configData = context.getConfigurationData();
             } finally {
                 if (context != null) {

Modified: geronimo/branches/dain/openejb-2.2-merge/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/openejb-2.2-merge/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=416533&r1=416532&r2=416533&view=diff
==============================================================================
--- geronimo/branches/dain/openejb-2.2-merge/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/branches/dain/openejb-2.2-merge/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
Thu Jun 22 17:44:07 2006
@@ -48,6 +48,8 @@
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Naming;
@@ -367,7 +369,18 @@
         childConfigurationDatas.put(moduleName, configurationData);
     }
 
-    public ConfigurationData getConfigurationData() {
+    public ConfigurationData getConfigurationData() throws DeploymentException {
+        List failures = verify();
+        if (!failures.isEmpty()) {
+            StringBuffer message = new StringBuffer();
+            for (Iterator iterator = failures.iterator(); iterator.hasNext();) {
+                String failure = (String) iterator.next();
+                if (message.length() > 0) message.append("\n");
+                message.append(failure);
+            }
+            throw new DeploymentException(message.toString());
+        }
+
         ConfigurationData configurationData = new ConfigurationData(configuration.getModuleType(),
                 new LinkedHashSet(configuration.getClassPath()),
                 new ArrayList(configuration.getGBeans().values()),
@@ -381,7 +394,7 @@
             ConfigurationData ownedConfiguration = (ConfigurationData) iterator.next();
             configurationData.addOwnedConfigurations(ownedConfiguration.getId());
         }
-        
+
         return configurationData;
     }
 
@@ -391,5 +404,81 @@
 
     public List getAdditionalDeployment() {
         return additionalDeployment;
+    }
+
+    public List verify() throws DeploymentException {
+        List failures = new ArrayList();
+        for (Iterator iterator = configuration.getGBeans().entrySet().iterator(); iterator.hasNext();)
{
+            Map.Entry entry = (Map.Entry) iterator.next();
+            AbstractName name = (AbstractName) entry.getKey();
+            GBeanData gbean = (GBeanData) entry.getValue();
+
+            for (Iterator iterator1 = gbean.getReferences().entrySet().iterator(); iterator1.hasNext();)
{
+                Map.Entry referenceEntry = (Map.Entry) iterator1.next();
+                String referenceName = (String) referenceEntry.getKey();
+                ReferencePatterns referencePatterns = (ReferencePatterns) referenceEntry.getValue();
+
+                String failure = verifyReference(gbean, referenceName, referencePatterns);
+                if (failure != null) {
+                    failures.add(failure);
+                }
+            }
+
+            for (Iterator iterator1 = gbean.getDependencies().iterator(); iterator1.hasNext();)
{
+                ReferencePatterns referencePatterns = (ReferencePatterns) iterator1.next();
+                String failure = verifyDependency(name, referencePatterns);
+                if (failure != null) {
+                    failures.add(failure);
+                }
+            }
+        }
+        return failures;
+    }
+
+    private String verifyReference(GBeanData gbean, String referenceName, ReferencePatterns
referencePatterns) {
+        GReferenceInfo referenceInfo = gbean.getGBeanInfo().getReference(referenceName);
+
+        // if there is no reference info we can't verify
+        if (referenceInfo == null) return null;
+
+        // A collection valued reference doesn't need to be verified
+        if (referenceInfo.getProxyType().equals(Collection.class.getName())) return null;
+
+        if (!isVerifyReference(referencePatterns)) {
+            return "Unable to resolve reference \"" + referenceName + "\" in gbean " +
+                    gbean.getAbstractName() + " to a gbean matching the pattern " + referencePatterns.getPatterns();
+        }
+        return null;
+    }
+
+    private String verifyDependency(AbstractName name, ReferencePatterns referencePatterns)
{
+        if (!isVerifyReference(referencePatterns)) {
+            return "Unable to resolve dependency in gbean " + name +
+                    " to a gbean matching the pattern " + referencePatterns.getPatterns();
+        }
+
+        return null;
+    }
+
+    private boolean isVerifyReference(ReferencePatterns referencePatterns) {
+        // we can't verify a resolved reference since it will have a specific artifact already
set...
+        // hopefully the deployer won't generate bad resolved references
+        if (referencePatterns.isResolved()) return true;
+
+        // Do not verify the reference if it has an explicit depenency on another artifact,
because it it likely
+        // that the other artifact is not in the "environment" (if it were you wouldn't use
the long form)
+        Set patterns = referencePatterns.getPatterns();
+        for (Iterator iterator = patterns.iterator(); iterator.hasNext();) {
+            AbstractNameQuery query = (AbstractNameQuery) iterator.next();
+            if (query.getArtifact() != null) return true;
+        }
+
+        // attempt to find the bean
+        try {
+            findGBean(patterns);
+            return true;
+        } catch (GBeanNotFoundException e) {
+            return false;
+        }
     }
 }

Modified: geronimo/branches/dain/openejb-2.2-merge/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/openejb-2.2-merge/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java?rev=416533&r1=416532&r2=416533&view=diff
==============================================================================
--- geronimo/branches/dain/openejb-2.2-merge/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
(original)
+++ geronimo/branches/dain/openejb-2.2-merge/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
Thu Jun 22 17:44:07 2006
@@ -42,6 +42,7 @@
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
 import org.apache.geronimo.kernel.Jsr77Naming;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationData;
@@ -279,7 +280,7 @@
 
             Object plan = configBuilder.getDeploymentPlan(null, earFile, idBuilder);
             context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
earFile, idBuilder), plan, earFile, Collections.singleton(configStore), artifactResolver,
configStore);
-            configurationData = context.getConfigurationData();
+            configurationData = getConfigurationData(context);
         } finally {
             if (context != null) {
                 context.close();
@@ -314,7 +315,7 @@
         try {
             Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-ejb-jar.xml"),
earFile, idBuilder);
             context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
earFile, idBuilder), plan, earFile, Collections.singleton(configStore), artifactResolver,
configStore);
-            configurationData = context.getConfigurationData();
+            configurationData = getConfigurationData(context);
             fail("Should have thrown a DeploymentException");
         } catch (DeploymentException e) {
             if (e.getCause() instanceof IOException) {
@@ -354,7 +355,7 @@
         try {
             Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-war.xml"),
earFile, idBuilder);
             context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
earFile, idBuilder), plan, earFile, Collections.singleton(configStore), artifactResolver,
configStore);
-            configurationData = context.getConfigurationData();
+            configurationData = getConfigurationData(context);
             fail("Should have thrown a DeploymentException");
         } catch (DeploymentException e) {
             if (e.getCause() instanceof IOException) {
@@ -394,7 +395,7 @@
         try {
             Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-rar.xml"),
earFile, idBuilder);
             context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
earFile, idBuilder), plan, earFile, Collections.singleton(configStore), artifactResolver,
configStore);
-            configurationData = context.getConfigurationData();
+            configurationData = getConfigurationData(context);
             fail("Should have thrown a DeploymentException");
         } catch (DeploymentException e) {
             if (e.getCause() instanceof IOException) {
@@ -434,7 +435,7 @@
         try {
             Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-car.xml"),
earFile, idBuilder);
             context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
earFile, idBuilder), plan, earFile, Collections.singleton(configStore), artifactResolver,
configStore);
-            configurationData = context.getConfigurationData();
+            configurationData = getConfigurationData(context);
             fail("Should have thrown a DeploymentException");
         } catch (DeploymentException e) {
             if (e.getCause() instanceof IOException) {
@@ -475,7 +476,7 @@
         try {
             Object plan = configBuilder.getDeploymentPlan(null, earFile, idBuilder);
             context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
earFile, idBuilder), plan, earFile, Collections.singleton(configStore), artifactResolver,
configStore);
-            configurationData = context.getConfigurationData();
+            configurationData = getConfigurationData(context);
             fail("Should have thrown a DeploymentException");
         } catch (DeploymentException e) {
             // expected
@@ -513,7 +514,7 @@
         try {
             Object plan = configBuilder.getDeploymentPlan(null, earFile, idBuilder);
             context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
earFile, idBuilder), plan, earFile, Collections.singleton(configStore), artifactResolver,
configStore);
-            configurationData = context.getConfigurationData();
+            configurationData = getConfigurationData(context);
             fail("Should have thrown a DeploymentException");
         } catch (DeploymentException e) {
             // expected
@@ -551,7 +552,7 @@
         try {
             Object plan = configBuilder.getDeploymentPlan(null, earFile, idBuilder);
             context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan,
earFile, idBuilder), plan, earFile, Collections.singleton(configStore), artifactResolver,
configStore);
-            configurationData = context.getConfigurationData();
+            configurationData = getConfigurationData(context);
             fail("Should have thrown a DeploymentException");
         } catch (DeploymentException e) {
             // expected
@@ -563,6 +564,13 @@
                 DeploymentUtil.recursiveDelete(configurationData.getConfigurationDir());
             }
         }
+    }
+
+    private ConfigurationData getConfigurationData(DeploymentContext context) throws Exception
{
+        // add the a j2ee server so the application context reference can be resolved
+        context.addGBean("geronimo", J2EEServerImpl.GBEAN_INFO);
+
+        return context.getConfigurationData();
     }
 
     private static void close(Module module) {

Modified: geronimo/branches/dain/openejb-2.2-merge/modules/kernel/src/java/org/apache/geronimo/gbean/SingleElementCollection.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/openejb-2.2-merge/modules/kernel/src/java/org/apache/geronimo/gbean/SingleElementCollection.java?rev=416533&r1=416532&r2=416533&view=diff
==============================================================================
--- geronimo/branches/dain/openejb-2.2-merge/modules/kernel/src/java/org/apache/geronimo/gbean/SingleElementCollection.java
(original)
+++ geronimo/branches/dain/openejb-2.2-merge/modules/kernel/src/java/org/apache/geronimo/gbean/SingleElementCollection.java
Thu Jun 22 17:44:07 2006
@@ -38,7 +38,7 @@
 
     public SingleElementCollection(Collection collection) {
         if (collection == null) {
-            throw new IllegalArgumentException("No collection parameter supplied");
+            collection = Collections.EMPTY_SET;            
         }
 
         this.collection = collection;



Mime
View raw message