geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1308424 - in /geronimo/server/trunk/framework/modules: geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ geronimo-kernel/src/main/java/org/apache/geronimo/kernel/ geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/
Date Mon, 02 Apr 2012 16:32:50 GMT
Author: xuhaihong
Date: Mon Apr  2 16:32:49 2012
New Revision: 1308424

URL: http://svn.apache.org/viewvc?rev=1308424&view=rev
Log:
GERONIMO-6112 Move the validation codes earlier, and avoid some unneeded process

Modified:
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeployerImpl.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeployerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeployerImpl.java?rev=1308424&r1=1308423&r2=1308424&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeployerImpl.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeployerImpl.java
Mon Apr  2 16:32:49 2012
@@ -77,7 +77,7 @@ public class DeployerImpl implements Dep
     private static final String REMOTE_DEPLOY_ADDRESS = "remoteDeployAddress";
 
     private String remoteDeployAddress;
-    
+
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, referenceInterface =
ConfigurationBuilder.class, policy = ReferencePolicy.DYNAMIC)
     private final Collection<ConfigurationBuilder> configurationBuilders = new ArrayList<ConfigurationBuilder>();
 
@@ -133,27 +133,27 @@ public class DeployerImpl implements Dep
     public void bindConfigurationStore(ConfigurationStore store) {
         configurationStores.add(store);
     }
-    
+
     public void unbindConfigurationStore(ConfigurationStore store) {
         configurationStores.remove(store);
     }
-    
+
     public void bindConfigurationBuilder(ConfigurationBuilder builder) {
         configurationBuilders.add(builder);
     }
-    
+
     public void unbindConfigurationBuilder(ConfigurationBuilder builder) {
         configurationBuilders.remove(builder);
     }
-    
+
     public void bindDeploymentWatcher(DeploymentWatcher watcher) {
         deploymentWatchers.add(watcher);
     }
-    
+
     public void unbindDeploymentWatcher(DeploymentWatcher watcher) {
         deploymentWatchers.remove(watcher);
     }
-    
+
     public void setArtifactResolver(ArtifactResolver artifactResolver) {
         this.artifactResolver = artifactResolver;
     }
@@ -290,16 +290,18 @@ public class DeployerImpl implements Dep
         }
         validatePlanFile(planFile);
 
-        JarFile module = getModule(inPlace, moduleFile);
-
         ModuleIDBuilder idBuilder = new ModuleIDBuilder();
 
         DeploymentContext context = null;
+        JarFile module = null;
         try {
+            module = getModule(inPlace, moduleFile);
+            validateModuleFile(module);
+
             Object plan = null;
             ConfigurationBuilder builder = null;
-            for (Iterator i = configurationBuilders.iterator(); i.hasNext();) {
-                ConfigurationBuilder candidate = (ConfigurationBuilder) i.next();
+            for (Iterator<ConfigurationBuilder> i = configurationBuilders.iterator();
i.hasNext();) {
+                ConfigurationBuilder candidate = i.next();
                 plan = candidate.getDeploymentPlan(planFile, module, idBuilder);
                 if (plan != null) {
                     builder = candidate;
@@ -369,6 +371,12 @@ public class DeployerImpl implements Dep
         }
     }
 
+    private void validateModuleFile(JarFile module) throws DeploymentException {
+        if (module != null && module.getEntry("META-INF/config.ser") != null) {
+            throw new DeploymentException("The target applicaiton is an Geronimo plugin as
config.ser was found in the META-INF directory, please use the install-plugin command.");
+        }
+    }
+
     private ConfigurationStore getConfigurationStore(String targetConfigurationStore)
             throws URISyntaxException, GBeanNotFoundException {
 //        if (targetConfigurationStore != null) {
@@ -559,14 +567,14 @@ public class DeployerImpl implements Dep
         }
     }
 
-    private void notifyWatchers(List list) {
+    private void notifyWatchers(List<String> list) {
         Artifact[] arts = new Artifact[list.size()];
         for (int i = 0; i < list.size(); i++) {
-            String s = (String) list.get(i);
+            String s = list.get(i);
             arts[i] = Artifact.create(s);
         }
-        for (Iterator it = deploymentWatchers.iterator(); it.hasNext();) {
-            DeploymentWatcher watcher = (DeploymentWatcher) it.next();
+        for (Iterator<DeploymentWatcher> it = deploymentWatchers.iterator(); it.hasNext();)
{
+            DeploymentWatcher watcher = it.next();
             for (int i = 0; i < arts.length; i++) {
                 Artifact art = arts[i];
                 watcher.deployed(art);
@@ -574,9 +582,9 @@ public class DeployerImpl implements Dep
         }
     }
 
-    private void cleanupConfigurations(List configurations) {
-        for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
-            ConfigurationData configurationData = (ConfigurationData) iterator.next();
+    private void cleanupConfigurations(List<ConfigurationData> configurations) {
+        for (Iterator<ConfigurationData> iterator = configurations.iterator(); iterator.hasNext();)
{
+            ConfigurationData configurationData = iterator.next();
             File configurationDir = configurationData.getConfigurationDir();
             if (!FileUtils.recursiveDelete(configurationDir)) {
                 reaper.delete(configurationDir.getAbsolutePath(), "delete");
@@ -664,7 +672,7 @@ public class DeployerImpl implements Dep
             if (pendingDeletionIndex.size() == 0)
                 return;
             // Otherwise, attempt to delete all of the directories
-            Enumeration list = pendingDeletionIndex.propertyNames();
+            Enumeration<?> list = pendingDeletionIndex.propertyNames();
             while (list.hasMoreElements()) {
                 String dirName = (String) list.nextElement();
                 File deleteDir = new File(dirName);

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java?rev=1308424&r1=1308423&r2=1308424&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/DependencyManager.java
Mon Apr  2 16:32:49 2012
@@ -66,7 +66,7 @@ public interface DependencyManager {
      * @param child the dependent component
      * @param parents the set of components the child is depending on
      */
-    public void addDependencies(AbstractName child, Set parents);
+    public void addDependencies(AbstractName child, Set<AbstractName> parents);
 
     /**
      * Gets the set of parents that the child is depending on
@@ -74,7 +74,7 @@ public interface DependencyManager {
      * @param child the dependent component
      * @return a collection containing all of the components the child depends on; will never
be null
      */
-    public Set getParents(AbstractName child);
+    public Set<AbstractName> getParents(AbstractName child);
 
     /**
      * Gets all of the MBeans that have a dependency on the specified startParent.
@@ -82,6 +82,6 @@ public interface DependencyManager {
      * @param parent the component the returned childen set depend on
      * @return a collection containing all of the components that depend on the parent; will
never be null
      */
-    public Set getChildren(AbstractName parent);
+    public Set<AbstractName> getChildren(AbstractName parent);
 
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java?rev=1308424&r1=1308423&r2=1308424&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java
Mon Apr  2 16:32:49 2012
@@ -24,7 +24,6 @@ import org.apache.geronimo.kernel.lifecy
 import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
 
-import javax.management.ObjectName;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -59,12 +58,12 @@ public class BasicDependencyManager impl
     /**
      * A map from child names to a list of parents.
      */
-    private final Map childToParentMap = new HashMap();
+    private final Map<AbstractName, Set<AbstractName>> childToParentMap = new
HashMap<AbstractName, Set<AbstractName>>();
 
     /**
      * A map from parent back to a list of its children.
      */
-    private final Map parentToChildMap = new HashMap();
+    private final Map<AbstractName, Set<AbstractName>> parentToChildMap = new
HashMap<AbstractName, Set<AbstractName>>();
 
     public BasicDependencyManager(LifecycleMonitor lifecycleMonitor) {
         assert lifecycleMonitor != null;
@@ -85,16 +84,16 @@ public class BasicDependencyManager impl
      * @param parent the component the child is depending on
      */
     public synchronized void addDependency(AbstractName child, AbstractName parent) {
-        Set parents = (Set) childToParentMap.get(child);
+        Set<AbstractName> parents = childToParentMap.get(child);
         if (parents == null) {
-            parents = new HashSet();
+            parents = new HashSet<AbstractName>();
             childToParentMap.put(child, parents);
         }
         parents.add(parent);
 
-        Set children = (Set) parentToChildMap.get(parent);
+        Set<AbstractName> children = parentToChildMap.get(parent);
         if (children == null) {
-            children = new HashSet();
+            children = new HashSet<AbstractName>();
             parentToChildMap.put(parent, children);
         }
         children.add(child);
@@ -107,12 +106,12 @@ public class BasicDependencyManager impl
      * @param parent the component that the child wil no longer depend on
      */
     public synchronized void removeDependency(AbstractName child, AbstractName parent) {
-        Set parents = (Set) childToParentMap.get(child);
+        Set<AbstractName> parents = childToParentMap.get(child);
         if (parents != null) {
             parents.remove(parent);
         }
 
-        Set children = (Set) parentToChildMap.get(parent);
+        Set<AbstractName> children = parentToChildMap.get(parent);
         if (children != null) {
             children.remove(child);
         }
@@ -124,13 +123,13 @@ public class BasicDependencyManager impl
      * @param child the component that will no longer depend on anything
      */
     public synchronized void removeAllDependencies(AbstractName child) {
-        Set parents = (Set) childToParentMap.remove(child);
+        Set<AbstractName> parents = childToParentMap.remove(child);
         if (parents == null) {
             return;
         }
-        for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
-            ObjectName parent = (ObjectName) iterator.next();
-            Set children = (Set) parentToChildMap.get(parent);
+        for (Iterator<AbstractName> iterator = parents.iterator(); iterator.hasNext();)
{
+            AbstractName parent = iterator.next();
+            Set<AbstractName> children = parentToChildMap.get(parent);
             if (children != null) {
                 children.remove(child);
             }
@@ -144,20 +143,20 @@ public class BasicDependencyManager impl
      * @param child the dependent component
      * @param parents the set of components the child is depending on
      */
-    public synchronized void addDependencies(AbstractName child, Set parents) {
-        Set existingParents = (Set) childToParentMap.get(child);
+    public synchronized void addDependencies(AbstractName child, Set<AbstractName>
parents) {
+        Set<AbstractName> existingParents = childToParentMap.get(child);
         if (existingParents == null) {
-            existingParents = new HashSet(parents);
+            existingParents = new HashSet<AbstractName>(parents);
             childToParentMap.put(child, existingParents);
         } else {
             existingParents.addAll(parents);
         }
 
-        for (Iterator i = parents.iterator(); i.hasNext();) {
-            Object startParent = i.next();
-            Set children = (Set) parentToChildMap.get(startParent);
+        for (Iterator<AbstractName> i = parents.iterator(); i.hasNext();) {
+            AbstractName startParent = i.next();
+            Set<AbstractName> children = parentToChildMap.get(startParent);
             if (children == null) {
-                children = new HashSet();
+                children = new HashSet<AbstractName>();
                 parentToChildMap.put(startParent, children);
             }
             children.add(child);
@@ -170,12 +169,12 @@ public class BasicDependencyManager impl
      * @param child the dependent component
      * @return a collection containing all of the components the child depends on; will never
be null
      */
-    public synchronized Set getParents(AbstractName child) {
-        Set parents = (Set) childToParentMap.get(child);
+    public synchronized Set<AbstractName> getParents(AbstractName child) {
+        Set<AbstractName> parents = childToParentMap.get(child);
         if (parents == null) {
-            return Collections.EMPTY_SET;
+            return Collections.<AbstractName>emptySet();
         }
-        return new HashSet(parents);
+        return new HashSet<AbstractName>(parents);
     }
 
     /**
@@ -184,12 +183,12 @@ public class BasicDependencyManager impl
      * @param parent the component the returned childen set depend on
      * @return a collection containing all of the components that depend on the parent; will
never be null
      */
-    public synchronized Set getChildren(AbstractName parent) {
-        Set children = (Set) parentToChildMap.get(parent);
+    public synchronized Set<AbstractName> getChildren(AbstractName parent) {
+        Set<AbstractName> children = parentToChildMap.get(parent);
         if (children == null) {
-            return Collections.EMPTY_SET;
+            return Collections.<AbstractName>emptySet();
         }
-        return new HashSet(children);
+        return new HashSet<AbstractName>(children);
     }
 
 



Mime
View raw message