geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r747165 [2/2] - in /geronimo/server/trunk: framework/modules/geronimo-deployment/src/test/java/org/apache/geronimo/deployment/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ framework/modules/geronimo-ker...
Date Mon, 23 Feb 2009 22:27:40 GMT
Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=747165&r1=747164&r2=747165&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Mon Feb 23 22:27:34 2009
@@ -21,7 +21,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;
@@ -29,8 +28,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -44,18 +41,20 @@
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.repository.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @version $Rev$ $Date$
  */
 public class SimpleConfigurationManager implements ConfigurationManager {
     protected final Logger log = LoggerFactory.getLogger(getClass());
-    protected final Collection stores;
+    protected final Collection<ConfigurationStore> stores;
     private final ArtifactResolver artifactResolver;
-    protected final Map configurations = new LinkedHashMap();
+    protected final Map<Artifact, Configuration> configurations = new LinkedHashMap<Artifact, Configuration>();
     protected final ConfigurationModel configurationModel = new ConfigurationModel();
     protected final Collection<? extends Repository> repositories;
-    protected final Collection watchers;
+    protected final Collection<DeploymentWatcher> watchers;
 
     /**
      * When this is not null, it points to the "new" configuration that is
@@ -66,17 +65,17 @@
     private Configuration reloadingConfiguration;
 
 
-    public SimpleConfigurationManager(Collection stores, ArtifactResolver artifactResolver, Collection<? extends Repository> repositories) {
-        this(stores, artifactResolver, repositories, Collections.EMPTY_SET);
+    public SimpleConfigurationManager(Collection<ConfigurationStore> stores, ArtifactResolver artifactResolver, Collection<? extends Repository> repositories) {
+        this(stores, artifactResolver, repositories, Collections.<DeploymentWatcher>emptySet());
     }
 
-    public SimpleConfigurationManager(Collection stores,
+    public SimpleConfigurationManager(Collection<ConfigurationStore> stores,
                                       ArtifactResolver artifactResolver,
                                       Collection<? extends Repository> repositories,
-                                      Collection watchers) {
-        if (stores == null) stores = Collections.EMPTY_SET;
+                                      Collection<DeploymentWatcher> watchers) {
+        if (stores == null) stores = Collections.emptySet();
         if (repositories == null) repositories = Collections.emptySet();
-        if (watchers == null) watchers = Collections.EMPTY_SET;
+        if (watchers == null) watchers = Collections.emptySet();
 
         this.stores = stores;
         this.artifactResolver = artifactResolver;
@@ -88,9 +87,7 @@
         if (!configId.isResolved()) {
             throw new IllegalArgumentException("Artifact " + configId + " is not fully resolved");
         }
-        List storeSnapshot = getStoreList();
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+        for (ConfigurationStore store : getStoreList()) {
             if (store.containsConfiguration(configId)) {
                 return true;
             }
@@ -117,9 +114,8 @@
 
     public Artifact[] getInstalled(Artifact query) {
         Artifact[] all = artifactResolver.queryArtifacts(query);
-        List configs = new ArrayList();
-        for (int i = 0; i < all.length; i++) {
-            Artifact artifact = all[i];
+        List<Artifact> configs = new ArrayList<Artifact>();
+        for (Artifact artifact : all) {
             if (isConfiguration(artifact)) {
                 configs.add(artifact);
             }
@@ -127,7 +123,7 @@
         if (configs.size() == all.length) {
             return all;
         }
-        return (Artifact[]) configs.toArray(new Artifact[configs.size()]);
+        return configs.toArray(new Artifact[configs.size()]);
     }
 
     public Artifact[] getLoaded(Artifact query) {
@@ -140,18 +136,17 @@
 
 
     public List listStores() {
-        List storeSnapshot = getStoreList();
-        List result = new ArrayList(storeSnapshot.size());
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+        List<ConfigurationStore> storeSnapshot = getStoreList();
+        List<AbstractName> result = new ArrayList<AbstractName>(storeSnapshot.size());
+        for (ConfigurationStore store : storeSnapshot) {
             result.add(store.getAbstractName());
         }
         return result;
     }
 
     public ConfigurationStore[] getStores() {
-        List storeSnapshot = getStoreList();
-        return (ConfigurationStore[]) storeSnapshot.toArray(new ConfigurationStore[storeSnapshot.size()]);
+        List<ConfigurationStore> storeSnapshot = getStoreList();
+        return storeSnapshot.toArray(new ConfigurationStore[storeSnapshot.size()]);
     }
 
     public Collection<? extends Repository> getRepositories() {
@@ -159,10 +154,9 @@
     }
 
     public List listConfigurations() {
-        List storeSnapshot = getStoreList();
-        List list = new ArrayList();
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+        List<ConfigurationStore> storeSnapshot = getStoreList();
+        List<ConfigurationInfo> list = new ArrayList<ConfigurationInfo>();
+        for (ConfigurationStore store : storeSnapshot) {
             list.addAll(listConfigurations(store));
         }
         return list;
@@ -172,9 +166,8 @@
         if (!configId.isResolved()) {
             throw new IllegalArgumentException("Artifact " + configId + " is not fully resolved");
         }
-        List storeSnapshot = getStoreList();
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+        List<ConfigurationStore> storeSnapshot = getStoreList();
+        for (ConfigurationStore store : storeSnapshot) {
             if (store.containsConfiguration(configId)) {
                 return store;
             }
@@ -183,8 +176,7 @@
     }
 
     public List<ConfigurationInfo> listConfigurations(AbstractName storeName) throws NoSuchStoreException {
-        List<ConfigurationStore> storeSnapshot = getStoreList();
-        for (ConfigurationStore store : storeSnapshot) {
+        for (ConfigurationStore store : getStoreList()) {
             if (storeName.equals(store.getAbstractName())) {
                 return listConfigurations(store);
             }
@@ -195,7 +187,7 @@
     private List<ConfigurationInfo> listConfigurations(ConfigurationStore store) {
         List<ConfigurationInfo> list = store.listConfigurations();
         for (ListIterator<ConfigurationInfo> iterator = list.listIterator(); iterator.hasNext();) {
-            ConfigurationInfo configurationInfo = (ConfigurationInfo) iterator.next();
+            ConfigurationInfo configurationInfo = iterator.next();
             if (isRunning(configurationInfo.getConfigID())) {
                 configurationInfo = new ConfigurationInfo(store.getAbstractName(),
                         configurationInfo.getConfigID(),
@@ -232,9 +224,7 @@
         }
 
         // see if any stores think it is a configuration
-        List storeSnapshot = getStoreList();
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+        for (ConfigurationStore store : getStoreList()) {
             if (store.containsConfiguration(artifact)) {
                 return true;
             }
@@ -249,7 +239,7 @@
         if (reloadingConfiguration != null && reloadingConfiguration.getId().equals(configurationId)) {
             return reloadingConfiguration;
         }
-        return (Configuration) configurations.get(configurationId);
+        return configurations.get(configurationId);
     }
 
     public synchronized LifecycleResults loadConfiguration(Artifact configurationId) throws NoSuchConfigException, LifecycleException {
@@ -269,7 +259,7 @@
         }
 
         // load the ConfigurationData for the new configuration
-        ConfigurationData configurationData = null;
+        ConfigurationData configurationData;
         try {
             configurationData = loadConfigurationData(configurationId, monitor);
         } catch (Exception e) {
@@ -292,7 +282,7 @@
         LifecycleResults results = new LifecycleResults();
         if (!isLoaded(id)) {
             // recursively load configurations from the new child to the parents
-            LinkedHashMap configurationsToLoad = new LinkedHashMap();
+            LinkedHashMap<Artifact, UnloadedConfiguration> configurationsToLoad = new LinkedHashMap<Artifact, UnloadedConfiguration>();
             try {
                 loadDepthFirst(configurationData, configurationsToLoad, monitor);
             } catch (Exception e) {
@@ -301,13 +291,12 @@
             }
 
             // load and start the unloaded the gbean for each configuration (depth first)
-            Map actuallyLoaded = new LinkedHashMap(configurationsToLoad.size());
+            Map<Artifact, Configuration> actuallyLoaded = new LinkedHashMap<Artifact, Configuration>(configurationsToLoad.size());
             Artifact configurationId = null;
             try {
-                for (Iterator iterator = configurationsToLoad.entrySet().iterator(); iterator.hasNext();) {
-                    Map.Entry entry = (Map.Entry) iterator.next();
-                    configurationId = (Artifact) entry.getKey();
-                    UnloadedConfiguration unloadedConfiguration = (UnloadedConfiguration) entry.getValue();
+                for (Map.Entry<Artifact, UnloadedConfiguration> entry : configurationsToLoad.entrySet()) {
+                    configurationId = entry.getKey();
+                    UnloadedConfiguration unloadedConfiguration = entry.getValue();
 
                     monitor.loading(configurationId);
                     Configuration configuration = load(unloadedConfiguration.getConfigurationData(), unloadedConfiguration.getResolvedParentIds(), actuallyLoaded);
@@ -319,8 +308,7 @@
                 monitor.failed(configurationId, e);
 
                 // there was a problem, so we need to unload all configurations that were actually loaded
-                for (Iterator iterator = actuallyLoaded.values().iterator(); iterator.hasNext();) {
-                    Configuration configuration = (Configuration) iterator.next();
+                for (Configuration configuration : actuallyLoaded.values()) {
                     unload(configuration);
                 }
 
@@ -341,10 +329,10 @@
         configurationModel.load(configurationId);
     }
 
-    protected Configuration load(ConfigurationData configurationData, LinkedHashSet resolvedParentIds, Map loadedConfigurations) throws InvalidConfigException {
+    protected Configuration load(ConfigurationData configurationData, LinkedHashSet<Artifact> resolvedParentIds, Map<Artifact, Configuration> loadedConfigurations) throws InvalidConfigException {
         Artifact configurationId = configurationData.getId();
         try {
-            Collection parents = findParentConfigurations(resolvedParentIds, loadedConfigurations);
+            Collection<Configuration> parents = findParentConfigurations(resolvedParentIds, loadedConfigurations);
 
             Configuration configuration = new Configuration(parents, configurationData, new ConfigurationResolver(configurationData, repositories, artifactResolver), null);
             configuration.doStart();
@@ -354,14 +342,13 @@
         }
     }
 
-    private Collection findParentConfigurations(LinkedHashSet resolvedParentIds, Map loadedConfigurations) throws InvalidConfigException {
-        LinkedHashMap parents = new LinkedHashMap();
-        for (Iterator iterator = resolvedParentIds.iterator(); iterator.hasNext();) {
-            Artifact resolvedArtifact = (Artifact) iterator.next();
+    private Collection<Configuration> findParentConfigurations(LinkedHashSet<Artifact> resolvedParentIds, Map<Artifact, Configuration> loadedConfigurations) throws InvalidConfigException {
+        LinkedHashMap<Artifact, Configuration> parents = new LinkedHashMap<Artifact, Configuration>();
+        for (Artifact resolvedArtifact : resolvedParentIds) {
 
-            Configuration parent = null;
+            Configuration parent;
             if (loadedConfigurations.containsKey(resolvedArtifact)) {
-                parent = (Configuration) loadedConfigurations.get(resolvedArtifact);
+                parent = loadedConfigurations.get(resolvedArtifact);
             } else if (isLoaded(resolvedArtifact)) {
                 parent = getConfiguration(resolvedArtifact);
             } else {
@@ -373,9 +360,8 @@
         return parents.values();
     }
 
-    private void addNewConfigurationsToModel(Map loadedConfigurations) throws NoSuchConfigException {
-        for (Iterator iterator = loadedConfigurations.values().iterator(); iterator.hasNext();) {
-            Configuration configuration = (Configuration) iterator.next();
+    private void addNewConfigurationsToModel(Map<Artifact, Configuration> loadedConfigurations) throws NoSuchConfigException {
+        for (Configuration configuration : loadedConfigurations.values()) {
             addNewConfigurationToModel(configuration);
         }
     }
@@ -387,11 +373,10 @@
         configurations.put(configuration.getId(), configuration);
     }
 
-    protected LinkedHashSet getLoadParents(Configuration configuration) {
-        LinkedHashSet loadParent = new LinkedHashSet(configuration.getClassParents());
-        for (Iterator iterator = configuration.getChildren().iterator(); iterator.hasNext();) {
-            Configuration childConfiguration = (Configuration) iterator.next();
-            LinkedHashSet childLoadParent = getLoadParents(childConfiguration);
+    protected LinkedHashSet<Configuration> getLoadParents(Configuration configuration) {
+        LinkedHashSet<Configuration> loadParent = new LinkedHashSet<Configuration>(configuration.getClassParents());
+        for (Configuration childConfiguration : configuration.getChildren()) {
+            LinkedHashSet<Configuration> childLoadParent = getLoadParents(childConfiguration);
 
             // remove this configuration from the parent Ids since it will cause an infinite loop
             childLoadParent.remove(configuration);
@@ -401,11 +386,10 @@
         return loadParent;
     }
 
-    protected LinkedHashSet getStartParents(Configuration configuration) {
-        LinkedHashSet startParent = new LinkedHashSet(configuration.getServiceParents());
-        for (Iterator iterator = configuration.getChildren().iterator(); iterator.hasNext();) {
-            Configuration childConfiguration = (Configuration) iterator.next();
-            LinkedHashSet childStartParent = getStartParents(childConfiguration);
+    protected LinkedHashSet<Configuration> getStartParents(Configuration configuration) {
+        LinkedHashSet<Configuration> startParent = new LinkedHashSet<Configuration>(configuration.getServiceParents());
+        for (Configuration childConfiguration : configuration.getChildren()) {
+            LinkedHashSet<Configuration> childStartParent = getStartParents(childConfiguration);
 
             // remove this configuration from the parent Ids since it will cause an infinite loop
             childStartParent.remove(configuration);
@@ -512,8 +496,7 @@
             }
         }
 
-        for (Iterator iterator = configurationData.getChildConfigurations().values().iterator(); iterator.hasNext();) {
-            ConfigurationData childConfigurationData = (ConfigurationData) iterator.next();
+        for (ConfigurationData childConfigurationData : configurationData.getChildConfigurations().values()) {
             LinkedHashSet<Artifact> childParentIds = resolveParentIds(childConfigurationData);
             // remove this configuration's id from the parent Ids since it will cause an infinite loop
             childParentIds.remove(configurationData.getId());
@@ -524,9 +507,9 @@
 
     private static class UnloadedConfiguration {
         private final ConfigurationData configurationData;
-        private final LinkedHashSet resolvedParentIds;
+        private final LinkedHashSet<Artifact> resolvedParentIds;
 
-        public UnloadedConfiguration(ConfigurationData configurationData, LinkedHashSet resolvedParentIds) {
+        public UnloadedConfiguration(ConfigurationData configurationData, LinkedHashSet<Artifact> resolvedParentIds) {
             this.configurationData = configurationData;
             this.resolvedParentIds = resolvedParentIds;
         }
@@ -535,7 +518,7 @@
             return configurationData;
         }
 
-        public LinkedHashSet getResolvedParentIds() {
+        public LinkedHashSet<Artifact> getResolvedParentIds() {
             return resolvedParentIds;
         }
     }
@@ -548,15 +531,15 @@
         if (!id.isResolved()) {
             throw new IllegalArgumentException("Artifact " + id + " is not fully resolved");
         }
-        LinkedHashSet unstartedConfigurations = configurationModel.start(id);
+        LinkedHashSet<Artifact> unstartedConfigurations = configurationModel.start(id);
 
         addConfigurationsToMonitor(monitor, unstartedConfigurations);
 
         LifecycleResults results = new LifecycleResults();
         Artifact configurationId = null;
         try {
-            for (Iterator iterator = unstartedConfigurations.iterator(); iterator.hasNext();) {
-                configurationId = (Artifact) iterator.next();
+            for (Artifact unstartedConfiguration : unstartedConfigurations) {
+                configurationId = unstartedConfiguration;
                 Configuration configuration = getConfiguration(configurationId);
 
                 monitor.starting(configurationId);
@@ -569,12 +552,11 @@
             monitor.failed(configurationId, e);
             configurationModel.stop(id);
 
-            for (Iterator iterator = results.getStarted().iterator(); iterator.hasNext();) {
-                configurationId = (Artifact) iterator.next();
-                Configuration configuration = getConfiguration(configurationId);
-                monitor.stopping(configurationId);
+            for (Artifact started : results.getStarted()) {
+                Configuration configuration = getConfiguration(started);
+                monitor.stopping(started);
                 stop(configuration);
-                monitor.succeeded(configurationId);
+                monitor.succeeded(started);
             }
             monitor.finished();
             throw new LifecycleException("start", id, e);
@@ -595,13 +577,12 @@
         if (!id.isResolved()) {
             throw new IllegalArgumentException("Artifact " + id + " is not fully resolved");
         }
-        LinkedHashSet stopList = configurationModel.stop(id);
+        LinkedHashSet<Artifact> stopList = configurationModel.stop(id);
 
         addConfigurationsToMonitor(monitor, stopList);
 
         LifecycleResults results = new LifecycleResults();
-        for (Iterator iterator = stopList.iterator(); iterator.hasNext();) {
-            Artifact configurationId = (Artifact) iterator.next();
+        for (Artifact configurationId : stopList) {
             Configuration configuration = getConfiguration(configurationId);
 
             monitor.stopping(configurationId);
@@ -629,14 +610,13 @@
             throw new IllegalArgumentException("Artifact " + id + " is not fully resolved");
         }
         // get a sorted list of configurations to restart
-        LinkedHashSet restartList = configurationModel.restart(id);
+        LinkedHashSet<Artifact> restartList = configurationModel.restart(id);
 
         addConfigurationsToMonitor(monitor, restartList);
 
         // stop the configuations
         LifecycleResults results = new LifecycleResults();
-        for (Iterator iterator = restartList.iterator(); iterator.hasNext();) {
-            Artifact configurationId = (Artifact) iterator.next();
+        for (Artifact configurationId : restartList) {
             Configuration configuration = getConfiguration(configurationId);
             monitor.stopping(configurationId);
             stop(configuration);
@@ -648,9 +628,8 @@
         restartList = reverse(restartList);
 
         // restart the configurations
-        Set skip = new HashSet();
-        for (Iterator iterator = restartList.iterator(); iterator.hasNext();) {
-            Artifact configurationId = (Artifact) iterator.next();
+        Set<Artifact> skip = new HashSet<Artifact>();
+        for (Artifact configurationId : restartList) {
 
             // skip the configurations that have alredy failed or are children of failed configurations
             if (skip.contains(configurationId)) {
@@ -672,7 +651,7 @@
                 skip.add(configurationId);
 
                 // officially stop the configuration in the model (without gc)
-                LinkedHashSet stopList = configurationModel.stop(configurationId, false);
+                LinkedHashSet<Artifact> stopList = configurationModel.stop(configurationId, false);
 
                 // all of the configurations to be stopped must be in our restart list, or the model is corrupt
                 if (!restartList.containsAll(stopList)) {
@@ -680,8 +659,7 @@
                 }
 
                 // add the children of the failed configuration to the results as stopped
-                for (Iterator iterator1 = stopList.iterator(); iterator1.hasNext();) {
-                    Artifact failedId = (Artifact) iterator1.next();
+                for (Artifact failedId : stopList) {
 
                     // if any of the failed configuration is in the restarted set, the model is
                     // corrupt because we started a child before a parent
@@ -710,13 +688,12 @@
             throw new IllegalArgumentException("Artifact " + id + " is not fully resolved");
         }
         Set started = configurationModel.getStarted();
-        LinkedHashSet unloadList = configurationModel.unload(id);
+        LinkedHashSet<Artifact> unloadList = configurationModel.unload(id);
 
         addConfigurationsToMonitor(monitor, unloadList);
 
         LifecycleResults results = new LifecycleResults();
-        for (Iterator iterator = unloadList.iterator(); iterator.hasNext();) {
-            Artifact configurationId = (Artifact) iterator.next();
+        for (Artifact configurationId : unloadList) {
             Configuration configuration = getConfiguration(configurationId);
 
             // first make sure it is stopped
@@ -777,9 +754,8 @@
         Configuration configuration = getConfiguration(id);
         if (configuration == null) { // The configuration to reload is not currently loaded
             ConfigurationData data = null;
-            List storeSnapshot = getStoreList();
-            for (int i = 0; i < storeSnapshot.size(); i++) {
-                ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+            List<ConfigurationStore> storeSnapshot = getStoreList();
+            for (ConfigurationStore store : storeSnapshot) {
                 if (store.containsConfiguration(id)) {
                     try {
                         data = store.loadConfiguration(id);
@@ -791,9 +767,9 @@
             if (data == null) {
                 throw new NoSuchConfigException(id);
             }
-            UnloadedConfiguration existingUnloadedConfiguration = new UnloadedConfiguration(data, new LinkedHashSet());
+            UnloadedConfiguration existingUnloadedConfiguration = new UnloadedConfiguration(data, new LinkedHashSet<Artifact>());
             Artifact newId = new Artifact(id.getGroupId(), id.getArtifactId(), version, id.getType());
-            ConfigurationData newData = null;
+            ConfigurationData newData;
             try {
                 newData = loadConfigurationData(newId, monitor);
             } catch (Exception e) {
@@ -809,7 +785,7 @@
             Artifact newId = new Artifact(id.getGroupId(), id.getArtifactId(), version, id.getType());
 
             // reload the ConfigurationData from a store
-            ConfigurationData configurationData = null;
+            ConfigurationData configurationData;
             try {
                 configurationData = loadConfigurationData(newId, monitor);
             } catch (Exception e) {
@@ -836,16 +812,14 @@
     }
 
     private boolean hasHardDependency(Artifact configurationId, ConfigurationData configurationData) {
-        for (Iterator iterator = configurationData.getEnvironment().getDependencies().iterator(); iterator.hasNext();) {
-            Dependency dependency = (Dependency) iterator.next();
+        for (Dependency dependency : configurationData.getEnvironment().getDependencies()) {
             Artifact artifact = dependency.getArtifact();
             if (artifact.getVersion() != null && artifact.matches(configurationId)) {
                 return true;
             }
         }
 
-        for (Iterator iterator = configurationData.getChildConfigurations().values().iterator(); iterator.hasNext();) {
-            ConfigurationData childConfigurationData = (ConfigurationData) iterator.next();
+        for (ConfigurationData childConfigurationData : configurationData.getChildConfigurations().values()) {
             if (hasHardDependency(configurationId, childConfigurationData)) {
                 return true;
             }
@@ -863,7 +837,7 @@
         //
         // recursively load the new configuration; this will catch any new parents
         //
-        LinkedHashMap newConfigurations = new LinkedHashMap();
+        LinkedHashMap<Artifact, UnloadedConfiguration> newConfigurations = new LinkedHashMap<Artifact, UnloadedConfiguration>();
         try {
             loadDepthFirst(newConfigurationData, newConfigurations, monitor);
         } catch (Exception e) {
@@ -874,16 +848,15 @@
         //
         // get a list of the started configuration, so we can restart them later
         //
-        Set started = configurationModel.getStarted();
+        Set<Artifact> started = configurationModel.getStarted();
 
         //
         // get a list of the child configurations that will need to reload
         //
         //   note: we are iterating in reverse order
-        LinkedHashMap existingParents = new LinkedHashMap();
-        LinkedHashMap reloadChildren = new LinkedHashMap();
-        for (Iterator iterator = reverse(configurationModel.reload(existingConfigurationId)).iterator(); iterator.hasNext();) {
-            Artifact configurationId = (Artifact) iterator.next();
+        LinkedHashMap<Artifact, LinkedHashSet<Artifact>> existingParents = new LinkedHashMap<Artifact, LinkedHashSet<Artifact>>();
+        LinkedHashMap<Artifact, UnloadedConfiguration> reloadChildren = new LinkedHashMap<Artifact, UnloadedConfiguration>();
+        for (Artifact configurationId : reverse(configurationModel.reload(existingConfigurationId))) {
 
             if (configurationId.equals(existingConfigurationId)) {
                 continue;
@@ -899,11 +872,11 @@
             ConfigurationData configurationData = configuration.getConfigurationData();
 
             // save off the exising resolved parent ids in case we need to restore this configuration
-            LinkedHashSet existingParentIds = getResolvedParentIds(configuration);
+            LinkedHashSet<Artifact> existingParentIds = getResolvedParentIds(configuration);
             existingParents.put(configurationId, existingParentIds);
 
             // check that the child doen't have a hard dependency on the old configuration
-            LinkedHashSet resolvedParentIds = null;
+            LinkedHashSet<Artifact> resolvedParentIds;
             if (hasHardDependency(existingConfigurationId, configurationData)) {
                 if (force) {
                     throw new LifecycleException("reload", newConfigurationId,
@@ -913,7 +886,7 @@
                 // we leave the resolved parent ids null to signal that we should not reload the configuration
                 resolvedParentIds = null;
             } else {
-                resolvedParentIds = new LinkedHashSet(existingParentIds);
+                resolvedParentIds = new LinkedHashSet<Artifact>(existingParentIds);
                 resolvedParentIds.remove(existingConfigurationId);
                 resolvedParentIds.add(newConfigurationId);
             }
@@ -928,8 +901,7 @@
 
         // note: we are iterating in reverse order
         LifecycleResults results = new LifecycleResults();
-        for (Iterator iterator = reverse(reloadChildren).keySet().iterator(); iterator.hasNext();) {
-            Artifact configurationId = (Artifact) iterator.next();
+        for (Artifact configurationId: reverse(reloadChildren).keySet()) {
             Configuration configuration = getConfiguration(configurationId);
 
             // first make sure it is stopped
@@ -976,18 +948,17 @@
         boolean reinstatedExisting = false;
         /* reduce variable scope */
         {
-            Map loadedParents = new LinkedHashMap();
-            Map startedParents = new LinkedHashMap();
+            Map<Artifact,  Configuration> loadedParents = new LinkedHashMap<Artifact,  Configuration>();
+            Map<Artifact,  Configuration> startedParents = new LinkedHashMap<Artifact,  Configuration>();
             Configuration newConfiguration = null;
             Artifact configurationId = null;
             try {
                 //
                 // load all of the new configurations
                 //
-                for (Iterator iterator = newConfigurations.entrySet().iterator(); iterator.hasNext();) {
-                    Map.Entry entry = (Map.Entry) iterator.next();
-                    configurationId = (Artifact) entry.getKey();
-                    UnloadedConfiguration unloadedConfiguration = (UnloadedConfiguration) entry.getValue();
+                for (Map.Entry<Artifact,  UnloadedConfiguration> entry : newConfigurations.entrySet()) {
+                    configurationId = entry.getKey();
+                    UnloadedConfiguration unloadedConfiguration = entry.getValue();
 
                     monitor.loading(configurationId);
                     Configuration configuration = load(unloadedConfiguration.getConfigurationData(), unloadedConfiguration.getResolvedParentIds(), loadedParents);
@@ -1013,17 +984,15 @@
                 if (started.contains(existingConfigurationId)) {
 
                     // determine which of the parents we need to start
-                    LinkedHashSet startList = new LinkedHashSet();
-                    for (Iterator iterator = getStartParents(newConfiguration).iterator(); iterator.hasNext();) {
-                        Configuration serviceParent = (Configuration) iterator.next();
+                    LinkedHashSet<Configuration> startList = new LinkedHashSet<Configuration>();
+                    for (Configuration serviceParent : getStartParents(newConfiguration)) {
                         if (loadedParents.containsKey(serviceParent.getId())) {
                             startList.add(serviceParent);
                         }
                     }
 
                     // start the new parents
-                    for (Iterator iterator = startList.iterator(); iterator.hasNext();) {
-                        Configuration startParent = (Configuration) iterator.next();
+                    for (Configuration startParent : startList) {
                         monitor.starting(configurationId);
                         start(startParent);
                         monitor.succeeded(configurationId);
@@ -1068,7 +1037,7 @@
                 }
 
                 // replace the configuraiton in he configurations map
-                configurations.remove(existingConfiguration);
+                configurations.remove(existingConfiguration.getId());
                 configurations.put(newConfigurationId, newConfiguration);
 
                 // migrate the configuration settings
@@ -1080,12 +1049,10 @@
                 //
                 // stop and unload all configurations that were actually loaded
                 //
-                for (Iterator iterator = startedParents.values().iterator(); iterator.hasNext();) {
-                    Configuration configuration = (Configuration) iterator.next();
+                for (Configuration configuration : startedParents.values()) {
                     stop(configuration);
                 }
-                for (Iterator iterator = loadedParents.values().iterator(); iterator.hasNext();) {
-                    Configuration configuration = (Configuration) iterator.next();
+                for (Configuration configuration : loadedParents.values()) {
                     unload(configuration);
                 }
 
@@ -1102,7 +1069,7 @@
                 try {
                     configuration = load(existingUnloadedConfiguration.getConfigurationData(),
                             existingUnloadedConfiguration.getResolvedParentIds(),
-                            Collections.EMPTY_MAP);
+                            Collections.<Artifact, Configuration>emptyMap());
                     reloadingConfiguration = configuration;
                     // if the configuration was started before restart it
                     if (started.contains(existingConfigurationId)) {
@@ -1127,8 +1094,7 @@
                     //
                     // cleanup the model
                     //
-                    for (Iterator iterator = results.getUnloaded().iterator(); iterator.hasNext();) {
-                        Artifact childId = (Artifact) iterator.next();
+                    for (Artifact childId : results.getUnloaded()) {
                         configurationModel.unload(childId);
                         removeConfigurationFromModel(childId);
                     }
@@ -1143,11 +1109,10 @@
         //
         // reload as many child configurations as possible
         //
-        Set skip = new HashSet();
-        for (Iterator iterator = reloadChildren.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            Artifact configurationId = (Artifact) entry.getKey();
-            UnloadedConfiguration unloadedConfiguration = (UnloadedConfiguration) entry.getValue();
+        Set<Artifact> skip = new HashSet<Artifact>();
+        for (Map.Entry<Artifact, UnloadedConfiguration> entry : reloadChildren.entrySet()) {
+            Artifact configurationId = entry.getKey();
+            UnloadedConfiguration unloadedConfiguration = entry.getValue();
 
             // skip the configurations that have alredy failed or are children of failed configurations
             if (skip.contains(configurationId)) {
@@ -1158,17 +1123,17 @@
             Configuration configuration = null;
             try {
                 // get the correct resolved parent ids based on if we are loading with the new config id or the existing one
-                LinkedHashSet resolvedParentIds;
+                LinkedHashSet<Artifact> resolvedParentIds;
                 if (!reinstatedExisting) {
                     resolvedParentIds = unloadedConfiguration.getResolvedParentIds();
                 } else {
-                    resolvedParentIds = (LinkedHashSet) existingParents.get(configurationId);
+                    resolvedParentIds = existingParents.get(configurationId);
                 }
 
                 // if the resolved parent ids is null, then we are not supposed to reload this configuration
                 if (resolvedParentIds != null) {
                     monitor.loading(configurationId);
-                    configuration = load(unloadedConfiguration.getConfigurationData(), resolvedParentIds, Collections.EMPTY_MAP);
+                    configuration = load(unloadedConfiguration.getConfigurationData(), resolvedParentIds, Collections.<Artifact, Configuration>emptyMap());
                     reloadingConfiguration = configuration;
                     monitor.succeeded(configurationId);
 
@@ -1199,7 +1164,7 @@
                 }
 
                 // officially unload the configuration in the model (without gc)
-                LinkedHashSet unloadList = configurationModel.unload(configurationId, false);
+                LinkedHashSet<Artifact> unloadList = configurationModel.unload(configurationId, false);
                 configurationModel.removeConfiguration(configurationId);
 
                 // all of the configurations to be unloaded must be in our unloaded list, or the model is corrupt
@@ -1208,8 +1173,7 @@
                 }
 
                 // add the children of the failed configuration to the results as unloaded
-                for (Iterator iterator1 = unloadList.iterator(); iterator1.hasNext();) {
-                    Artifact failedId = (Artifact) iterator1.next();
+                for (Artifact failedId : unloadList) {
 
                     // if any of the failed configuration are in the reloaded set, the model is
                     // corrupt because we loaded a child before a parent
@@ -1245,18 +1209,15 @@
     protected void migrateConfiguration(Artifact oldName, Artifact newName, Configuration configuration, boolean running) throws NoSuchConfigException {
     }
 
-    private static LinkedHashSet getResolvedParentIds(Configuration configuration) {
-        LinkedHashSet resolvedParentIds = new LinkedHashSet();
-        for (Iterator iterator = configuration.getClassParents().iterator(); iterator.hasNext();) {
-            Configuration classParent = (Configuration) iterator.next();
+    private static LinkedHashSet<Artifact> getResolvedParentIds(Configuration configuration) {
+        LinkedHashSet<Artifact> resolvedParentIds = new LinkedHashSet<Artifact>();
+        for (Configuration classParent : configuration.getClassParents()) {
             resolvedParentIds.add(classParent.getId());
         }
-        for (Iterator iterator = configuration.getServiceParents().iterator(); iterator.hasNext();) {
-            Configuration serviceParent = (Configuration) iterator.next();
+        for (Configuration serviceParent : configuration.getServiceParents()) {
             resolvedParentIds.add(serviceParent.getId());
         }
-        for (Iterator iterator = configuration.getChildren().iterator(); iterator.hasNext();) {
-            Configuration child = (Configuration) iterator.next();
+        for (Configuration child : configuration.getChildren()) {
             resolvedParentIds.addAll(getResolvedParentIds(child));
         }
 
@@ -1277,9 +1238,7 @@
         }
 
         uninstall(configurationId);
-        List storeSnapshot = getStoreList();
-        for (int i = 0; i < storeSnapshot.size(); i++) {
-            ConfigurationStore store = (ConfigurationStore) storeSnapshot.get(i);
+        for (ConfigurationStore store: getStoreList()) {
             if (store.containsConfiguration(configurationId)) {
                 store.uninstall(configurationId);
             }
@@ -1294,8 +1253,7 @@
     }
 
     private void notifyWatchers(Artifact id) {
-        for (Iterator it = watchers.iterator(); it.hasNext();) {
-            DeploymentWatcher watcher = (DeploymentWatcher) it.next();
+        for (DeploymentWatcher watcher : watchers) {
             watcher.undeployed(id);
         }
     }
@@ -1316,33 +1274,31 @@
     public void setOnline(boolean online) {
     }
 
-    protected List getStoreList() {
-        return new ArrayList(stores);
+    protected List<ConfigurationStore> getStoreList() {
+        return new ArrayList<ConfigurationStore>(stores);
     }
 
-    private static void addConfigurationsToMonitor(LifecycleMonitor monitor, LinkedHashSet configurations) {
-        for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
-            Artifact configurationId = (Artifact) iterator.next();
+    private static void addConfigurationsToMonitor(LifecycleMonitor monitor, LinkedHashSet<Artifact> configurations) {
+        for (Artifact configurationId : configurations) {
             monitor.addConfiguration(configurationId);
         }
     }
 
-    private static LinkedHashSet reverse(LinkedHashSet set) {
-        ArrayList reverseList = new ArrayList(set);
+    private static LinkedHashSet<Artifact> reverse(LinkedHashSet<Artifact> set) {
+        ArrayList<Artifact> reverseList = new ArrayList<Artifact>(set);
         Collections.reverse(reverseList);
-        set = new LinkedHashSet(reverseList);
+        set = new LinkedHashSet<Artifact>(reverseList);
         return set;
     }
 
-    private static LinkedHashMap reverse(LinkedHashMap map) {
-        ArrayList reverseEntrySet = new ArrayList(map.entrySet());
+    private static LinkedHashMap<Artifact, UnloadedConfiguration> reverse(LinkedHashMap<Artifact, UnloadedConfiguration> map) {
+        ArrayList<Map.Entry<Artifact, UnloadedConfiguration>> reverseEntrySet = new ArrayList<Map.Entry<Artifact, UnloadedConfiguration>>(map.entrySet());
         Collections.reverse(reverseEntrySet);
 
-        map = new LinkedHashMap(reverseEntrySet.size());
-        for (Iterator iterator = reverseEntrySet.iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            Object key = entry.getKey();
-            Object value = entry.getValue();
+        map = new LinkedHashMap<Artifact, UnloadedConfiguration>(reverseEntrySet.size());
+        for (Map.Entry<Artifact, UnloadedConfiguration> entry : reverseEntrySet) {
+            Artifact key = entry.getKey();
+            UnloadedConfiguration value = entry.getValue();
             map.put(key, value);
         }
         return map;
@@ -1351,7 +1307,8 @@
     /**
      * Used to apply overrides to a configuration's gbeans. 
      * The overrides are applied before configuration restart.
-     * @throws InvalidConfigException
+     * @param configuration configuration to customize
+     * @throws InvalidConfigException on error
      */
     private void applyOverrides(Configuration configuration) throws InvalidConfigException{
     	ClassLoader configurationClassLoader = configuration.getConfigurationClassLoader();

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java?rev=747165&r1=747164&r2=747165&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/xstream/XStreamGBeanState.java Mon Feb 23 22:27:34 2009
@@ -47,7 +47,7 @@
     /**
      * GBeans contained in this configuration.
      */
-    private final List gbeans = new ArrayList();
+    private final List<GBeanData> gbeans = new ArrayList<GBeanData>();
 
     /**
      * The serialized form of the gbeans.  Once this is set on more gbeans can be added.
@@ -58,7 +58,7 @@
         this.gbeanState = gbeanState;
     }
 
-    public XStreamGBeanState(Collection gbeans) {
+    public XStreamGBeanState(Collection<GBeanData> gbeans) {
         if (gbeans != null){
             this.gbeans.addAll(gbeans);
         }
@@ -72,7 +72,7 @@
         return gbeanState;
     }
 
-    public List getGBeans(ClassLoader classLoader) throws InvalidConfigException {
+    public List<GBeanData> getGBeans(ClassLoader classLoader) throws InvalidConfigException {
         if (gbeanState == null) {
             return Collections.unmodifiableList(gbeans);
         }
@@ -101,7 +101,7 @@
         return gBeanData;
     }
 
-    private static List loadGBeans(Element element, ClassLoader classLoader) throws InvalidConfigException {
+    private static List<GBeanData> loadGBeans(Element element, ClassLoader classLoader) throws InvalidConfigException {
         if (element != null) {
             // Set the thread context classloader so deserializing classes can grab the cl from the thread
             ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
@@ -120,14 +120,14 @@
                 Thread.currentThread().setContextClassLoader(oldCl);
             }
         }
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
-    private static Element storeGBeans(List gbeans) throws IOException {
-        GBeanData[] gbeanDatas = (GBeanData[]) gbeans.toArray(new GBeanData[gbeans.size()]);
+    private static Element storeGBeans(List<GBeanData> gbeans) throws IOException {
+        GBeanData[] gbeanDatas = gbeans.toArray(new GBeanData[gbeans.size()]);
 
         DocumentBuilderFactory documentBuilderFactory = XmlUtil.newDocumentBuilderFactory();
-        DocumentBuilder documentBuilder = null;
+        DocumentBuilder documentBuilder;
         try {
             documentBuilder = documentBuilderFactory.newDocumentBuilder();
         } catch (ParserConfigurationException e) {

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java?rev=747165&r1=747164&r2=747165&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java (original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java Mon Feb 23 22:27:34 2009
@@ -32,18 +32,20 @@
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.MultiParentClassLoader;
 import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
 import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
 import org.apache.geronimo.kernel.repository.Maven2Repository;
+import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
 
 public class JAXWSToolsCLI {
                
     private static final String CONFIG_ID = "org.apache.geronimo.configs/cxf-tools//car";
     
-    enum Command { JAVA2WS, WSDL2JAVA };
+    enum Command { JAVA2WS, WSDL2JAVA }
     
     private static final String USAGE_MSG =
         "Usage: jaxws-tools <toolName> <tool options>\n\n" +
@@ -84,10 +86,10 @@
 
         String repository = System.getProperty("Xorg.apache.geronimo.repository.boot.path", "repository");
         Maven2Repository bootRepository = new Maven2Repository(new File(geronimoHome, repository));
-        Collection<Maven2Repository> repositories = Collections.singleton(bootRepository);
+        Collection<Repository> repositories = Collections.<Repository>singleton(bootRepository);
         ArtifactResolver artifactResolver = new DefaultArtifactResolver(new DefaultArtifactManager(), bootRepository);
         RepositoryConfigurationStore repositoryStore = new RepositoryConfigurationStore(bootRepository);
-        Collection<RepositoryConfigurationStore> repositoryStores = Collections.singleton(repositoryStore);
+        Collection<ConfigurationStore> repositoryStores = Collections.<ConfigurationStore>singleton(repositoryStore);
         SimpleConfigurationManager manager = new SimpleConfigurationManager(repositoryStores, artifactResolver, repositories);
         
         Artifact id = Artifact.create(CONFIG_ID);



Mime
View raw message