geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r556119 - in /geronimo/server/trunk/modules: geronimo-common/src/main/java/org/apache/geronimo/common/ geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ geronimo-deployment/src/main/java/org/apache/geronimo/deployment/xmlbea...
Date Fri, 13 Jul 2007 19:34:03 GMT
Author: djencks
Date: Fri Jul 13 12:34:02 2007
New Revision: 556119

URL: http://svn.apache.org/viewvc?view=rev&rev=556119
Log:
GERONIMO-3316 Better messages when manifest cp resolution encounters problems.  Also generified
some more gbean stuff

Modified:
    geronimo/server/trunk/modules/geronimo-common/src/main/java/org/apache/geronimo/common/DeploymentException.java
    geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java
    geronimo/server/trunk/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java

Modified: geronimo/server/trunk/modules/geronimo-common/src/main/java/org/apache/geronimo/common/DeploymentException.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-common/src/main/java/org/apache/geronimo/common/DeploymentException.java?view=diff&rev=556119&r1=556118&r2=556119
==============================================================================
--- geronimo/server/trunk/modules/geronimo-common/src/main/java/org/apache/geronimo/common/DeploymentException.java
(original)
+++ geronimo/server/trunk/modules/geronimo-common/src/main/java/org/apache/geronimo/common/DeploymentException.java
Fri Jul 13 12:34:02 2007
@@ -17,51 +17,97 @@
 
 package org.apache.geronimo.common;
 
+import java.util.List;
+import java.util.ArrayList;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
 
 /**
  * @version $Rev$ $Date$
  */
 public class DeploymentException extends Exception {
 
+    private final List<? extends Throwable> causes;
+
     public DeploymentException() {
+        causes = null;
     }
 
     public DeploymentException(Throwable cause) {
         super(cause);
+        causes = null;
     }
 
     public DeploymentException(String message) {
         super(message);
+        causes = null;
     }
 
     public DeploymentException(String message, Throwable cause) {
         super(message, cause);
+        causes = null;
+    }
+
+    public DeploymentException(String message, List<? extends Throwable> causes) {
+        super(message);
+        this.causes = causes;
+    }
+
+    public void printStackTrace(PrintStream ps) {
+        super.printStackTrace(ps);
+        if (causes != null) {
+            for (Throwable cause: causes) {
+                //TODO trim duplicate stack trace elements
+                cause.printStackTrace(ps);
+            }
+        }
+    }
+
+    public void printStackTrace(PrintWriter pw) {
+        super.printStackTrace(pw);
+        if (causes != null) {
+            for (Throwable cause: causes) {
+                //TODO trim duplicate stack trace elements
+                cause.printStackTrace(pw);
+            }
+        }
     }
     
     public DeploymentException cleanse() {
         if(null != getCause()) {
-            Throwable root = this;
-            CleanseException previousEx = null;
-            CleanseException rootEx = null;
-            while (null != root) {
-                Throwable e = root.getCause();
-                CleanseException exception = new CleanseException(root.getMessage(), root.toString());
-                if (null == rootEx) {
-                    rootEx = exception;
-                }
-                exception.setStackTrace(root.getStackTrace());
-                if (null != previousEx) {
-                    previousEx.initCause(exception);
-                }
-                previousEx = exception;
-                root = e;
+            return cleanse(this);
+        }
+        if (causes != null) {
+            List<CleanseException> cleansedCauses = new ArrayList<CleanseException>(causes.size());
+            for (Throwable cause: causes) {
+                CleanseException cleansed = cleanse(cause);
+                cleansedCauses.add(cleansed);
             }
-            return rootEx;
+            return new DeploymentException(getMessage(), cleansedCauses);
         }
-
         return this;
     }
-    
+
+    protected static CleanseException cleanse(Throwable root) {
+        CleanseException previousEx = null;
+        CleanseException rootEx = null;
+        while (null != root) {
+            Throwable e = root.getCause();
+            CleanseException exception = new CleanseException(root.getMessage(), root.toString());
+            if (null == rootEx) {
+                rootEx = exception;
+            }
+            exception.setStackTrace(root.getStackTrace());
+            if (null != previousEx) {
+                previousEx.initCause(exception);
+            }
+            previousEx = exception;
+            root = e;
+        }
+        return rootEx;
+    }
+
     private static class CleanseException extends DeploymentException {
         private final String toString;
         

Modified: geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java?view=diff&rev=556119&r1=556118&r2=556119
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
Fri Jul 13 12:34:02 2007
@@ -30,7 +30,6 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -167,6 +166,8 @@
 
     /**
      * @deprecated use findGBeans(pattern)
+     * @param pattern Search for gbeans whose name matches pattern.
+     * @return the set of gbeans whose name matches the pattern.
      */
     public Set<AbstractName> listGBeans(AbstractNameQuery pattern) {
         return findGBeans(pattern);
@@ -256,6 +257,7 @@
 
     interface JarFileFactory {
         JarFile newJarFile(URI relativeURI) throws IOException;
+
         String getManifestClassPath(JarFile jarFile) throws IOException;
     }
 
@@ -269,14 +271,21 @@
         public String getManifestClassPath(JarFile jarFile) throws IOException {
             Manifest manifest = jarFile.getManifest();
             if (manifest == null) {
-            return null;
+                return null;
             }
             return manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
         }
     }
 
     public void getCompleteManifestClassPath(JarFile moduleFile, URI moduleBaseUri, URI resolutionUri,
ClassPathList classpath, ModuleList exclusions) throws DeploymentException {
-         getCompleteManifestClassPath(moduleFile,  moduleBaseUri, resolutionUri, classpath,
exclusions, new DefaultJarFileFactory());
+        List<DeploymentException> problems = new ArrayList<DeploymentException>();
+        getCompleteManifestClassPath(moduleFile, moduleBaseUri, resolutionUri, classpath,
exclusions, new DefaultJarFileFactory(), problems);
+        if (!problems.isEmpty()) {
+            if (problems.size() == 1) {
+                throw problems.get(0);
+            }
+            throw new DeploymentException("Determining complete manifest classpath unsuccessful:",
problems);
+        }
     }
 
     /**
@@ -284,25 +293,26 @@
      * Used only in PersistenceUnitBuilder to figure out if a persistence.xml relates to
the starting module.  Having a classloader for
      * each ejb module would eliminate the need for this and be more elegant.
      *
-     * @param moduleFile the module that we start looking at classpaths at, in the car.
-     *
+     * @param moduleFile    the module that we start looking at classpaths at, in the car.
      * @param moduleBaseUri where the moduleFile is inside the car file.  For an (unpacked)
war this ends with / which means we also need:
-     *
-     * @param resolutionUri the uri to resolve against.  For a (packed) jar module this is
the same as moduleBaseUri.  For a war it removes the last segment.
-     *
-     * @param classpath the classpath list we are constructing.
-     *
-     * @param exclusions the paths to not investigate.  These are typically the other modules
in the ear/car file: they will have their contents processed for themselves.
-     *
-     * @param factory
-     * @throws org.apache.geronimo.common.DeploymentException if something goes wrong.
+     * @param resolutionUri the uri to resolve all entries against. For a module such as
an ejb jar that is part of the
+     *                      root ear car it is ".".  For a sub-configuration such as a war
it is the "reverse" of the path to the war file in the car.
+     *                      For instance, if the war file is foo/bar/myweb.war, the resolutionUri
is "../../..".
+     * @param classpath     the classpath list we are constructing.
+     * @param exclusions    the paths to not investigate.  These are typically the other
modules in the ear/car file: they will have their contents processed for themselves.
+     * @param factory       the factory for constructing JarFiles and the way to extract
the manifest classpath from a JarFile. Introduced to make
+     *                      testing plausible, but may be useful for in-IDE deployment.
+     * @param problems      List to save all the problems we encounter.
+     * @throws org.apache.geronimo.common.DeploymentException
+     *          if something goes wrong.
      */
-    public void getCompleteManifestClassPath(JarFile moduleFile, URI moduleBaseUri, URI resolutionUri,
ClassPathList classpath, ModuleList exclusions, JarFileFactory factory) throws DeploymentException
{
+    public void getCompleteManifestClassPath(JarFile moduleFile, URI moduleBaseUri, URI resolutionUri,
ClassPathList classpath, ModuleList exclusions, JarFileFactory factory, List<DeploymentException>
problems) throws DeploymentException {
         String manifestClassPath;
         try {
             manifestClassPath = factory.getManifestClassPath(moduleFile);
         } catch (IOException e) {
-            throw new DeploymentException("Could not read manifest: " + moduleBaseUri, e);
+            problems.add(new DeploymentException(printInfo("Could not read manifest: " +
moduleBaseUri, moduleBaseUri, classpath, exclusions), e));
+            return;
         }
 
         if (manifestClassPath == null) {
@@ -316,19 +326,23 @@
             try {
                 pathUri = new URI(path);
             } catch (URISyntaxException e) {
-                throw new DeploymentException("Invalid manifest classpath entry: module="
+ moduleBaseUri + ", path=" + path);
+                problems.add(new DeploymentException(printInfo("Invalid manifest classpath
entry, path=" + path, moduleBaseUri, classpath, exclusions)));
+                return;
             }
 
             if (!pathUri.getPath().endsWith(".jar")) {
-                throw new DeploymentException("Manifest class path entries must end with
the .jar extension (J2EE 1.4 Section 8.2): module=" + moduleBaseUri);
+                problems.add(new DeploymentException(printInfo("Manifest class path entries
must end with the .jar extension (J2EE 1.4 Section 8.2): path=" + path, moduleBaseUri, classpath,
exclusions)));
+                return;
             }
             if (pathUri.isAbsolute()) {
-                throw new DeploymentException("Manifest class path entries must be relative
(J2EE 1.4 Section 8.2): moduel=" + moduleBaseUri);
+                problems.add(new DeploymentException(printInfo("Manifest class path entries
must be relative (J2EE 1.4 Section 8.2): path=" + path, moduleBaseUri, classpath, exclusions)));
+                return;
             }
 
             URI targetUri = moduleBaseUri.resolve(pathUri);
             if (targetUri.getPath().endsWith("/")) {
-                throw new DeploymentException("target path must not end with a '/' character:
" + targetUri);
+                problems.add(new DeploymentException(printInfo("target path must not end
with a '/' character: path=" + path + ", resolved to targetURI=" + targetUri, moduleBaseUri,
classpath, exclusions)));
+                return;
             }
             String targetEntry = targetUri.toString();
             if (exclusions.contains(targetEntry)) {
@@ -346,13 +360,22 @@
             try {
                 classPathJarFile = factory.newJarFile(targetUri);
             } catch (IOException e) {
-                throw new DeploymentException("Manifest class path entries must be a valid
jar file (JAVAEE 5 Section 8.2): jarFile=" + resolvedUri + ", path=" + path, e);
+                problems.add(new DeploymentException(printInfo("Manifest class path entries
must be a valid jar file (JAVAEE 5 Section 8.2): path=" + path + ", resolved to targetURI="
+ targetUri, moduleBaseUri, classpath, exclusions), e));
+                return;
             }
 
-            getCompleteManifestClassPath(classPathJarFile, targetUri, resolutionUri, classpath,
exclusions, factory);
+            getCompleteManifestClassPath(classPathJarFile, targetUri, resolutionUri, classpath,
exclusions, factory, problems);
         }
     }
 
+    private String printInfo(String message, URI moduleBaseUri, ClassPathList classpath,
ModuleList exclusions) {
+        StringBuffer buf = new StringBuffer(message).append("\n");
+        buf.append("    looking at: ").append(moduleBaseUri);
+        buf.append("    current classpath: ").append(classpath);
+        buf.append("    ignoring modules: ").append(exclusions);
+        return buf.toString();
+    }
+
     /**
      * Import the classpath from a jar file's manifest.  The imported classpath
      * is crafted relative to <code>moduleBaseUri</code>.
@@ -500,8 +523,7 @@
                 inPlaceConfigurationDir,
                 naming);
 
-        for (Iterator iterator = additionalDeployment.iterator(); iterator.hasNext();) {
-            ConfigurationData ownedConfiguration = (ConfigurationData) iterator.next();
+        for (ConfigurationData ownedConfiguration : additionalDeployment) {
             configurationData.addOwnedConfigurations(ownedConfiguration.getId());
         }
 
@@ -522,15 +544,13 @@
 
     public List<String> verify(Configuration configuration) throws DeploymentException
{
         List<String> failures = new ArrayList<String>();
-        for (Iterator iterator = this.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();
+        for (Map.Entry<AbstractName, GBeanData> entry : this.configuration.getGBeans().entrySet())
{
+            AbstractName name = entry.getKey();
+            GBeanData gbean = entry.getValue();
+
+            for (Map.Entry<String, ReferencePatterns> referenceEntry : gbean.getReferences().entrySet())
{
+                String referenceName = referenceEntry.getKey();
+                ReferencePatterns referencePatterns = referenceEntry.getValue();
 
                 String failure = verifyReference(gbean, referenceName, referencePatterns,
configuration);
                 if (failure != null) {
@@ -538,8 +558,7 @@
                 }
             }
 
-            for (Iterator iterator1 = gbean.getDependencies().iterator(); iterator1.hasNext();)
{
-                ReferencePatterns referencePatterns = (ReferencePatterns) iterator1.next();
+            for (ReferencePatterns referencePatterns : gbean.getDependencies()) {
                 String failure = verifyDependency(name, referencePatterns, configuration);
                 if (failure != null) {
                     failures.add(failure);

Modified: geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java?view=diff&rev=556119&r1=556118&r2=556119
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java
(original)
+++ geronimo/server/trunk/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/xmlbeans/XmlBeansUtil.java
Fri Jul 13 12:34:02 2007
@@ -16,35 +16,34 @@
  */
 package org.apache.geronimo.deployment.xmlbeans;
 
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Element;
-import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.SchemaTypeLoader;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.QNameSet;
+import org.apache.xmlbeans.XmlOptions;
 import org.apache.xmlbeans.XmlValidationError;
+import org.w3c.dom.Element;
 
 /**
  * @version $Rev$ $Date$
  */
 public class XmlBeansUtil {
-    private static final Map NAMESPACE_UPDATES = new HashMap();
+    private static final Map<String, String> NAMESPACE_UPDATES = new HashMap<String,
String>();
     //TODO thread safe? conncurrentReaderMap?
-    private static final Map substitutionGroups = new HashMap();
+    private static final Map<QName, QNameSet> substitutionGroups = new HashMap<QName,
QNameSet>();
     private static final XmlObject[] NO_ELEMENTS = new XmlObject[]{};
 
     static {
@@ -151,7 +150,7 @@
     }
 
     public static void registerSubstitutionGroupElements(QName substitutionGroup, QNameSet
substitutions) {
-        QNameSet oldSubstitutions = (QNameSet) substitutionGroups.get(substitutionGroup);
+        QNameSet oldSubstitutions = substitutionGroups.get(substitutionGroup);
         if (oldSubstitutions != null) {
             substitutions = oldSubstitutions.union(substitutions);
         }
@@ -159,7 +158,7 @@
     }
 
     public static void unregisterSubstitutionGroupElements(QName substitutionGroup, QNameSet
substitutions) {
-        QNameSet oldSubstitutions = (QNameSet) substitutionGroups.get(substitutionGroup);
+        QNameSet oldSubstitutions = substitutionGroups.get(substitutionGroup);
         if (oldSubstitutions != null && substitutions != null) {
             QNameSet difference = oldSubstitutions.intersect(substitutions.inverse());
             substitutionGroups.put(substitutionGroup, difference);
@@ -167,7 +166,7 @@
     }
 
     public static QNameSet getQNameSetForSubstitutionGroup(QName substitutionGroup) {
-        return (QNameSet) substitutionGroups.get(substitutionGroup);
+        return substitutionGroups.get(substitutionGroup);
     }
 
     public static XmlObject[] selectSubstitutionGroupElements(QName substitutionGroup, XmlObject
container) {
@@ -196,11 +195,10 @@
                     Object o = iterator.next();
                     if (o instanceof XmlValidationError) {
                         XmlValidationError validationError = (XmlValidationError) o;
-                        List expected = validationError.getExpectedQNames();
+                        List<QName> expected = validationError.getExpectedQNames();
                         QName actual = validationError.getOffendingQName();
                         if (expected != null) {
-                            for (Iterator iterator1 = expected.iterator(); iterator1.hasNext();)
{
-                                QName expectedQName = (QName) iterator1.next();
+                            for (QName expectedQName : expected) {
                                 QNameSet substitutions = getQNameSetForSubstitutionGroup(expectedQName);
                                 if (substitutions != null && substitutions.contains(actual))
{
                                     iterator.remove();

Modified: geronimo/server/trunk/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java?view=diff&rev=556119&r1=556118&r2=556119
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/DeploymentContextTest.java
Fri Jul 13 12:34:02 2007
@@ -25,6 +25,7 @@
 import java.util.Map;
 import java.util.HashMap;
 import java.util.List;
+import java.util.ArrayList;
 import java.util.jar.JarFile;
 
 import javax.sql.DataSource;
@@ -54,6 +55,7 @@
 import org.apache.geronimo.kernel.repository.Version;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.common.DeploymentException;
 
 /**
  * @version $Rev$ $Date$
@@ -99,8 +101,8 @@
     private void recursiveDelete(File file) {
         if (file.isDirectory()) {
             File[] files = file.listFiles();
-            for (int i = 0; i < files.length; i++) {
-                recursiveDelete(files[i]);
+            for (File file1 : files) {
+                recursiveDelete(file1);
             }
         }
         file.delete();
@@ -154,7 +156,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory);
+        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(2, classPathList.size());
     }
 
@@ -171,7 +173,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory);
+        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(4, classPathList.size());
         assertEquals("lib1/lib1/lib1.jar", classPathList.get(0));
         assertEquals("lib2/lib2.jar", classPathList.get(1));
@@ -190,7 +192,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory);
+        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(2, classPathList.size());
         assertEquals("../lib1.jar", classPathList.get(0));
         assertEquals("../lib2.jar", classPathList.get(1));
@@ -210,7 +212,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory);
+        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(4, classPathList.size());
         assertEquals("../../../lib1/lib1/lib1.jar", classPathList.get(0));
         assertEquals("../../../lib2/lib2/lib2.jar", classPathList.get(1));
@@ -231,7 +233,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory);
+        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(4, classPathList.size());
         assertEquals("../../../lib1/lib1/lib1.jar", classPathList.get(0));
         assertEquals("../../../lib2/lib2.jar", classPathList.get(1));
@@ -254,7 +256,7 @@
         DeploymentContext.JarFileFactory factory = new MockJarFileFactory(data);
         DeploymentContext context = new DeploymentContext(new File("."), null, new Environment(Artifact.create("test/foo/1/ear")),
new AbstractName(URI.create("test/foo/1/ear?name=test")), ConfigurationModuleType.EAR, new
Jsr77Naming(), new MockConfigurationManager());
         ClassPathList classPathList = new ClassPathList();
-        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory);
+        context.getCompleteManifestClassPath(start, moduleBaseURI, resolutionURI, classPathList,
exclusions, factory, new ArrayList<DeploymentException>());
         assertEquals(2, classPathList.size());
     }
 

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java?view=diff&rev=556119&r1=556118&r2=556119
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanData.java
Fri Jul 13 12:34:02 2007
@@ -24,7 +24,6 @@
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -34,22 +33,22 @@
 public class GBeanData implements Externalizable {
     private static final long serialVersionUID = -1012491431781444074L;
 
-    private Externalizable backwardExternalizables[] = new Externalizable[] {
+    private Externalizable backwardExternalizables[] = new Externalizable[]{
             new V0Externalizable(),
             new V1Externalizable()
     };
 
     private GBeanInfo gbeanInfo;
-    private final Map attributes;
-    private final Map references;
-    private final Set dependencies;
+    private final Map<String, Object> attributes;
+    private final Map<String, ReferencePatterns> references;
+    private final Set<ReferencePatterns> dependencies;
     private AbstractName abstractName;
     private int priority;
 
     public GBeanData() {
-        attributes = new HashMap();
-        references = new HashMap();
-        dependencies = new HashSet();
+        attributes = new HashMap<String, Object>();
+        references = new HashMap<String, ReferencePatterns>();
+        dependencies = new HashSet<ReferencePatterns>();
     }
 
     public GBeanData(GBeanInfo gbeanInfo) {
@@ -65,9 +64,9 @@
 
     public GBeanData(GBeanData gbeanData) {
         setGBeanInfo(gbeanData.gbeanInfo);
-        attributes = new HashMap(gbeanData.attributes);
-        references = new HashMap(gbeanData.references);
-        dependencies = new HashSet(gbeanData.dependencies);
+        attributes = new HashMap<String, Object>(gbeanData.attributes);
+        references = new HashMap<String, ReferencePatterns>(gbeanData.references);
+        dependencies = new HashSet<ReferencePatterns>(gbeanData.dependencies);
         abstractName = gbeanData.abstractName;
     }
 
@@ -100,12 +99,12 @@
         }
     }
 
-    public Map getAttributes() {
-        return new HashMap(attributes);
+    public Map<String, Object> getAttributes() {
+        return new HashMap<String, Object>(attributes);
     }
 
-    public Set getAttributeNames() {
-        return new HashSet(attributes.keySet());
+    public Set<String> getAttributeNames() {
+        return new HashSet<String>(attributes.keySet());
     }
 
     public Object getAttribute(String name) {
@@ -116,16 +115,16 @@
         attributes.put(name, value);
     }
 
-    public Map getReferences() {
-        return new HashMap(references);
+    public Map<String, ReferencePatterns> getReferences() {
+        return new HashMap<String, ReferencePatterns>(references);
     }
 
-    public Set getReferencesNames() {
-        return new HashSet(references.keySet());
+    public Set<String> getReferencesNames() {
+        return new HashSet<String>(references.keySet());
     }
 
     public ReferencePatterns getReferencePatterns(String name) {
-        return (ReferencePatterns) references.get(name);
+        return references.get(name);
     }
 
     public void setReferencePattern(String name, AbstractNameQuery pattern) {
@@ -144,18 +143,17 @@
         references.put(name, patterns);
     }
 
-    public Set getDependencies() {
-        return new HashSet(dependencies);
+    public Set<ReferencePatterns> getDependencies() {
+        return new HashSet<ReferencePatterns>(dependencies);
     }
 
-    public void setDependencies(Set dependencies) {
+    public void setDependencies(Set<ReferencePatterns> dependencies) {
         this.dependencies.clear();
         addDependencies(dependencies);
     }
 
-    public void addDependencies(Set dependencies) {
-        for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
-            Object dependency = iterator.next();
+    public void addDependencies(Set<? extends Object> dependencies) {
+        for (Object dependency : dependencies) {
             if (dependency instanceof AbstractName) {
                 AbstractName name = (AbstractName) dependency;
                 addDependency(name);
@@ -193,7 +191,7 @@
 
     public void writeExternal(ObjectOutput out) throws IOException {
         // write version index
-        out.writeObject(new Integer(backwardExternalizables.length -1));
+        out.writeObject(backwardExternalizables.length - 1);
 
         // write the gbean info
         out.writeObject(gbeanInfo);
@@ -206,9 +204,8 @@
 
         // write the attributes
         out.writeInt(attributes.size());
-        for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
+        for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+            String name = entry.getKey();
             Object value = entry.getValue();
             try {
                 out.writeObject(name);
@@ -222,10 +219,9 @@
 
         // write the references
         out.writeInt(references.size());
-        for (Iterator iterator = references.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String name = (String) entry.getKey();
-            ReferencePatterns value = (ReferencePatterns) entry.getValue();
+        for (Map.Entry<String, ReferencePatterns> entry : references.entrySet()) {
+            String name = entry.getKey();
+            ReferencePatterns value = entry.getValue();
             try {
                 out.writeObject(name);
                 out.writeObject(value);
@@ -235,8 +231,7 @@
         }
         //write the dependencies
         out.writeInt(dependencies.size());
-        for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
-            ReferencePatterns referencePatterns = (ReferencePatterns) iterator.next();
+        for (ReferencePatterns referencePatterns : dependencies) {
             try {
                 out.writeObject(referencePatterns);
             } catch (IOException e) {
@@ -249,7 +244,7 @@
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         Object opaque = in.readObject();
         if (opaque instanceof Integer) {
-            backwardExternalizables[((Integer) opaque).intValue()].readExternal(in);
+            backwardExternalizables[((Integer) opaque)].readExternal(in);
         } else {
             gbeanInfo = (GBeanInfo) opaque;
             backwardExternalizables[0].readExternal(in);
@@ -260,13 +255,10 @@
      * Note: this comparator
      * imposes orderings that are inconsistent with equals.
      */
-    public static class PriorityComparator implements Comparator {
+    public static class PriorityComparator implements Comparator<GBeanData> {
 
-        public int compare(Object o1, Object o2) {
-            if (o1 instanceof GBeanData && o2 instanceof GBeanData) {
-                return ((GBeanData)o1).priority - ((GBeanData)o2).priority;
-            }
-            return 0;
+        public int compare(GBeanData o1, GBeanData o2) {
+            return o1.priority - o2.priority;
         }
     }
 
@@ -348,7 +340,7 @@
             throw new UnsupportedOperationException();
         }
 
-        protected void readGBeanInfo(ObjectInput in)  throws IOException, ClassNotFoundException
{
+        protected void readGBeanInfo(ObjectInput in) throws IOException, ClassNotFoundException
{
             gbeanInfo = (GBeanInfo) in.readObject();
         }
 

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java?view=diff&rev=556119&r1=556118&r2=556119
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/ReferencePatterns.java
Fri Jul 13 12:34:02 2007
@@ -19,7 +19,6 @@
 
 import java.io.Serializable;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
@@ -29,13 +28,12 @@
 public class ReferencePatterns implements Serializable {
     private static final long serialVersionUID = 1888371271299507818L;
 
-    private final Set patterns;
+    private final Set<AbstractNameQuery> patterns;
     private final AbstractName abstractName;
 
-    public ReferencePatterns(Set patterns) {
-        this.patterns = new LinkedHashSet();
-        for (Iterator iterator = patterns.iterator(); iterator.hasNext();) {
-            Object pattern = iterator.next();
+    public ReferencePatterns(Set<? extends Object> patterns) {
+        this.patterns = new LinkedHashSet<AbstractNameQuery>();
+        for (Object pattern : patterns) {
             if (pattern instanceof AbstractName) {
                 AbstractName name = (AbstractName) pattern;
                 this.patterns.add(new AbstractNameQuery(name));
@@ -62,7 +60,7 @@
         this.patterns = null;
     }
 
-    public Set getPatterns() {
+    public Set<AbstractNameQuery> getPatterns() {
         if (patterns == null) {
             throw new IllegalStateException("This is resolved to: " + abstractName);
         }



Mime
View raw message