geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r393687 - in /geronimo/branches/1.1: applications/console-core/src/java/org/apache/geronimo/console/util/ modules/deployment/src/java/org/apache/geronimo/deployment/ modules/kernel/src/java/org/apache/geronimo/kernel/config/ modules/system/...
Date Thu, 13 Apr 2006 02:41:21 GMT
Author: dain
Date: Wed Apr 12 19:41:19 2006
New Revision: 393687

URL: http://svn.apache.org/viewcvs?rev=393687&view=rev
Log:
Added created timestamp to configuration which should help with hot deploy.
Added concept of owned configurations.  An owned configuration is cascade-uninstalled when
the owner is uninstalled.
Added config.info file to cars which contains an easy to parse data needed for efficient management
such as time stamp, module type and owned configurations.

Modified:
    geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java

Modified: geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
(original)
+++ geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/util/KernelManagementHelper.java
Wed Apr 12 19:41:19 2006
@@ -830,7 +830,7 @@
                                     // and defined by the store, then it is stopped.
                                     state = State.STOPPED;
                                 }
-                                results.add(new ConfigurationInfo(info.getStoreName(), Artifact.create(temp.getKeyProperty(NameFactory.J2EE_NAME)),
state, type, info.getConfigID()));
+                                results.add(new ConfigurationInfo(info.getStoreName(), Artifact.create(temp.getKeyProperty(NameFactory.J2EE_NAME)),
type, info.getCreated(), info.getOwnedConfigurations(), state, info.getConfigID()));
                             }
                         }
                     }

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
(original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
Wed Apr 12 19:41:19 2006
@@ -477,6 +477,12 @@
                 baseDir,
                 inPlaceConfigurationDir,
                 naming);
+
+        for (Iterator iterator = additionalDeployment.iterator(); iterator.hasNext();) {
+            ConfigurationData ownedConfiguration = (ConfigurationData) iterator.next();
+            configurationData.addOwnedConfigurations(ownedConfiguration.getId());
+        }
+        
         return configurationData;
     }
 

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
Wed Apr 12 19:41:19 2006
@@ -448,6 +448,14 @@
     }
 
     /**
+     * Gets the time at which this configuration was created (or deployed).
+     * @return the time at which this configuration was created (or deployed)
+     */
+    public long getCreated() {
+        return configurationData.getCreated();
+    }
+
+    /**
      * Gets the class loader for this configuration.
      * @return the class loader for this configuration
      */
@@ -461,6 +469,14 @@
      */
     public List getChildren() {
         return Collections.unmodifiableList(children);
+    }
+
+    /**
+     * Gets the configurations owned by this configuration.  This is only used for cascade-uninstall.
+     * @return the configurations owned by this configuration
+     */
+    public Set getOwnedConfigurations() {
+        return configurationData.getOwnedConfigurations();
     }
 
     /**

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
Wed Apr 12 19:41:19 2006
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.LinkedHashMap;
+import java.util.Set;
 
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -39,6 +40,11 @@
     private static final long serialVersionUID = 4324193220056650732L;
 
     /**
+     * The time at which this configuration was created.
+     */
+    private final long created = System.currentTimeMillis();
+
+    /**
      * Identifies the type of configuration (WAR, RAR et cetera)
      */
     private final ConfigurationModuleType moduleType;
@@ -64,6 +70,11 @@
     private final Map childConfigurations = new LinkedHashMap();
 
     /**
+     * Configurations owned by this configuration.  This is only used for cascade-uninstall.
+     */
+    private final Set ownedConfigurations = new LinkedHashSet();
+
+    /**
      * The base file of the configuation
      */
     private transient File configurationDir;
@@ -134,6 +145,14 @@
         return environment.getConfigId();
     }
 
+    /**
+     * Gets the time at which this configuration was created (or deployed).
+     * @return the time at which this configuration was created (or deployed)
+     */
+    public long getCreated() {
+        return created;
+    }
+
     public ConfigurationModuleType getModuleType() {
         return moduleType;
     }
@@ -143,14 +162,18 @@
     }
 
     public List getGBeans(ClassLoader classLoader) throws InvalidConfigException {
+        if (classLoader == null) throw new NullPointerException("classLoader is null");
         return gbeanState.getGBeans(classLoader);
     }
 
     public void addGBean(GBeanData gbeanData) {
+        if (gbeanData == null) throw new NullPointerException("gbeanData is null");
         gbeanState.addGBean(gbeanData);
     }
 
     public GBeanData addGBean(String name, GBeanInfo gbeanInfo) {
+        if (name == null) throw new NullPointerException("name is null");
+        if (gbeanInfo == null) throw new NullPointerException("gbeanInfo is null");
         return gbeanState.addGBean(name, gbeanInfo, naming, environment);
     }
 
@@ -163,9 +186,24 @@
     }
 
     public void addChildConfiguration(ConfigurationData configurationData) {
+        if (configurationData == null) throw new NullPointerException("configurationData
is null");
         childConfigurations.put(configurationData.getId(), configurationData);
     }
 
+    /**
+     * Gets the configurations owned by this configuration.  This is only used for cascade-uninstall.
+     * @return the configurations owned by this configuration
+     */
+    public Set getOwnedConfigurations() {
+        return Collections.unmodifiableSet(ownedConfigurations);
+    }
+
+    public void addOwnedConfigurations(Artifact id) {
+        if (id == null) throw new NullPointerException("id is null");
+        if (!id.isResolved()) throw new IllegalArgumentException("id is not resolved: " +
id);
+        ownedConfigurations.add(id);
+    }
+
     public Environment getEnvironment() {
         return environment;
     }
@@ -179,6 +217,7 @@
     }
 
     public void setConfigurationDir(File configurationDir) {
+        if (configurationDir == null) throw new NullPointerException("configurationDir is
null");
         this.configurationDir = configurationDir;
     }
 
@@ -195,6 +234,7 @@
     }
 
     public void setConfigurationStore(ConfigurationStore configurationStore) {
+        if (configurationStore == null) throw new NullPointerException("configurationStore
is null");
         this.configurationStore = configurationStore;
     }
 }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationInfo.java
Wed Apr 12 19:41:19 2006
@@ -17,10 +17,12 @@
 package org.apache.geronimo.kernel.config;
 
 import java.io.Serializable;
+import java.util.LinkedHashSet;
+import java.util.Set;
 
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.gbean.AbstractName;
 
 /**
  * 
@@ -28,51 +30,73 @@
  * @version $Rev$ $Date$
  */
 public class ConfigurationInfo implements Serializable {
-    private static final long serialVersionUID = 576134736036202445L;
+    private static final long serialVersionUID = -16555213664245560L;
+    private final AbstractName storeName;
     private final Artifact configID;
     private final ConfigurationModuleType type;
-    private final AbstractName storeName;
-    private final Artifact parentID;
+    private final long created;
+    private final Set ownedConfigurations = new LinkedHashSet();
     private final State state;
+    private final Artifact parentID;
 
-    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType
type) {
+    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType
type, long created, Set ownedConfigurations) {
+        this.storeName = storeName;
         this.configID = configID;
         this.type = type;
+        this.created = created;
+        if (ownedConfigurations != null) {
+            this.ownedConfigurations.addAll(ownedConfigurations);
+        }
         state = null;
-        this.storeName = storeName;
-        this.parentID = null;
+        parentID = null;
     }
 
-    public ConfigurationInfo(AbstractName storeName, Artifact configID, State state, ConfigurationModuleType
type) {
+    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType
type, long created, Set ownedConfigurations, State state) {
+        this.storeName = storeName;
         this.configID = configID;
-        this.state = state;
         this.type = type;
-        this.storeName = storeName;
-        this.parentID = null;
+        this.created = created;
+        if (ownedConfigurations != null) {
+            this.ownedConfigurations.addAll(ownedConfigurations);
+        }
+        this.state = state;
+        parentID = null;
     }
 
-    public ConfigurationInfo(AbstractName storeName, Artifact configID, State state, ConfigurationModuleType
type, Artifact parentID) {
+    public ConfigurationInfo(AbstractName storeName, Artifact configID, ConfigurationModuleType
type, long created, Set ownedConfigurations, State state, Artifact parentID) {
+        this.storeName = storeName;
         this.configID = configID;
-        this.state = state;
         this.type = type;
-        this.storeName = storeName;
+        this.created = created;
+        if (ownedConfigurations != null) {
+            this.ownedConfigurations.addAll(ownedConfigurations);
+        }
+        this.state = state;
         this.parentID = parentID;
     }
 
-    public Artifact getConfigID() {
-        return configID;
+    public AbstractName getStoreName() {
+        return storeName;
     }
 
-    public State getState() {
-        return state;
+    public Artifact getConfigID() {
+        return configID;
     }
 
     public ConfigurationModuleType getType() {
         return type;
     }
 
-    public AbstractName getStoreName() {
-        return storeName;
+    public long getCreated() {
+        return created;
+    }
+
+    public Set getOwnedConfigurations() {
+        return ownedConfigurations;
+    }
+
+    public State getState() {
+        return state;
     }
 
     public Artifact getParentID() {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
Wed Apr 12 19:41:19 2006
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.PrintWriter;
 import java.net.URI;
 import java.net.URL;
 import java.util.Collection;
@@ -28,6 +29,9 @@
 import java.util.List;
 import java.util.Collections;
 import java.util.ArrayList;
+import java.util.Properties;
+import java.util.Map;
+import java.util.LinkedHashSet;
 
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
@@ -161,6 +165,52 @@
 
     public static ConfigurationData readConfigurationData(InputStream in) throws IOException,
ClassNotFoundException {
         return configurationMarshaler.readConfigurationData(in);
+    }
+
+    public static void writeConfigInfo(PrintWriter writer, ConfigurationData configurationData)
{
+        writer.println("id=" + configurationData.getId());
+        writer.println("type=" + configurationData.getModuleType());
+        writer.println("created=" + configurationData.getCreated());
+        Set ownedConfigurations = configurationData.getOwnedConfigurations();
+        int i = 0;
+        for (Iterator iterator = ownedConfigurations.iterator(); iterator.hasNext();) {
+            Artifact ownedConfiguration = (Artifact) iterator.next();
+            writer.println("owned.configuration." + i++ + "=" + ownedConfiguration);
+        }
+    }
+
+    public static ConfigurationInfo readConfigurationInfo(InputStream in, AbstractName storeName)
throws IOException {
+        Properties properties = new Properties();
+        properties.load(in);
+
+        String id = properties.getProperty("id");
+        Artifact configId = Artifact.create(id);
+
+        String type = properties.getProperty("type");
+        ConfigurationModuleType moduleType = ConfigurationModuleType.getByName(type);
+        if (moduleType == null) {
+            throw new IllegalArgumentException("Unknown module type: " + type);
+        }
+
+        String created = properties.getProperty("created");
+        long time;
+        try {
+            time = Long.parseLong(created);
+        } catch (NumberFormatException e) {
+            throw new IllegalArgumentException("Invalid created time: " + created);
+        }
+
+        LinkedHashSet ownedConfigurations = new LinkedHashSet();
+        for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext();) {
+            Map.Entry entry = (Map.Entry) iterator.next();
+            String name = (String) entry.getKey();
+            if (name.startsWith("owned.configuration.")) {
+                String value = (String) entry.getValue();
+                Artifact ownedConfiguration = Artifact.create(value);
+                ownedConfigurations.add(ownedConfiguration);
+            }
+        }
+        return new ConfigurationInfo(storeName, configId, moduleType, time, ownedConfigurations);
     }
 
     /**

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
Wed Apr 12 19:41:19 2006
@@ -106,9 +106,18 @@
         for (ListIterator iterator = list.listIterator(); iterator.hasNext();) {
             ConfigurationInfo configurationInfo = (ConfigurationInfo) iterator.next();
             if (isRunning(configurationInfo.getConfigID())) {
-                configurationInfo = new ConfigurationInfo(store.getAbstractName(), configurationInfo.getConfigID(),
State.RUNNING, configurationInfo.getType());
+                configurationInfo = new ConfigurationInfo(store.getAbstractName(),
+                        configurationInfo.getConfigID(),
+                        configurationInfo.getType(),
+                        configurationInfo.getCreated(),
+                        configurationInfo.getOwnedConfigurations(),
+                        State.RUNNING);
             } else {
-                configurationInfo = new ConfigurationInfo(store.getAbstractName(), configurationInfo.getConfigID(),
State.STOPPED, configurationInfo.getType());
+                configurationInfo = new ConfigurationInfo(store.getAbstractName(),
+                        configurationInfo.getConfigID(),
+                        configurationInfo.getType(),
+                        configurationInfo.getCreated(),
+                        configurationInfo.getOwnedConfigurations(), State.STOPPED);
             }
             iterator.set(configurationInfo);
         }

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
Wed Apr 12 19:41:19 2006
@@ -23,6 +23,9 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.FileWriter;
+import java.io.Writer;
 import java.net.URI;
 import java.util.Collection;
 import java.util.Collections;
@@ -39,7 +42,7 @@
  * @version $Rev$ $Date$
  */
 public final class ExecutableConfigurationUtil {
-	
+
     private ExecutableConfigurationUtil() {
     }
 
@@ -106,6 +109,16 @@
         } finally {
             out.closeEntry();
         }
+
+        // write the info file
+        out.putNextEntry(new ZipEntry("META-INF/config.info"));
+        try {
+            PrintWriter writer = new PrintWriter(new OutputStreamWriter(out));
+            ConfigurationUtil.writeConfigInfo(writer, configurationData);
+            writer.flush();
+        } finally {
+            out.closeEntry();
+        }
     }
 
     public static void writeConfiguration(ConfigurationData configurationData, File source)
throws IOException {
@@ -118,19 +131,24 @@
         try {
             ConfigurationUtil.writeConfigurationData(configurationData, out);
         } finally {
-            if (out != null) {
-                try {
-                    out.flush();
-                } catch (Exception ignored) {
-                }
-                try {
-                    out.close();
-                } catch (Exception ignored) {
-                }
-            }
+            flush(out);
+            close(out);
         }
+
+        // write the check sum file
         ConfigurationStoreUtil.writeChecksumFor(configSer);
-        
+
+        // write the info file
+        PrintWriter writer = null;
+        try {
+            writer = new PrintWriter(new FileWriter(new File(metaInf, "config.info")));
+            ConfigurationUtil.writeConfigInfo(writer, configurationData);
+        } finally {
+            flush(writer);
+            close(writer);
+        }
+
+        // write the in place location
         InPlaceConfigurationUtil.writeInPlaceLocation(configurationData, source);
     }
 
@@ -154,6 +172,24 @@
         }
     }
 
+    private static void flush(OutputStream thing) {
+        if (thing != null) {
+            try {
+                thing.flush();
+            } catch (Exception ignored) {
+            }
+        }
+    }
+
+    private static void flush(Writer thing) {
+        if (thing != null) {
+            try {
+                thing.flush();
+            } catch (Exception ignored) {
+            }
+        }
+    }
+
     private static void close(InputStream thing) {
         if (thing != null) {
             try {
@@ -164,6 +200,15 @@
     }
 
     private static void close(OutputStream thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch (Exception ignored) {
+            }
+        }
+    }
+
+    private static void close(Writer thing) {
         if (thing != null) {
             try {
                 thing.close();

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java?rev=393687&r1=393686&r2=393687&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/RepositoryConfigurationStore.java
Wed Apr 12 19:41:19 2006
@@ -31,14 +31,13 @@
 import java.util.zip.ZipEntry;
 import javax.management.ObjectName;
 
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
 import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.config.ConfigurationInfo;
-import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
@@ -240,8 +239,33 @@
     }
 
     public void uninstall(Artifact configId) throws NoSuchConfigException, IOException {
+        ConfigurationInfo configurationInfo = null;
+        try {
+            configurationInfo = loadConfigurationInfo(configId);
+        } catch (IOException e) {
+            // don't really care
+        }
         File location = repository.getLocation(configId);
         IOUtil.recursiveDelete(location);
+
+        if (configurationInfo != null) {
+            IOException ioException = null;
+            for (Iterator iterator = configurationInfo.getOwnedConfigurations().iterator();
iterator.hasNext();) {
+                Artifact ownedConfiguration = (Artifact) iterator.next();
+                try {
+                    uninstall(ownedConfiguration);
+                } catch (NoSuchConfigException e) {
+                    // ignored - already deleted or never installed
+                } catch (IOException e) {
+                    if (ioException != null) {
+                        ioException = e;
+                    }
+                }
+                if (ioException != null) {
+                    throw ioException;
+                }
+            }
+        }
     }
 
     public List listConfigurations() {
@@ -254,18 +278,48 @@
                 Artifact configId = (Artifact) i.next();
                 if (configId.getType().equals("car")) {
                     try {
-                        // this is super expensive just to get one small piece of info
-                        // todo consider making module type the same as artifact type
-                        ConfigurationData configurationData = loadConfiguration(configId);
-                        ConfigurationModuleType type = configurationData.getModuleType();
-
-                        configs.add(new ConfigurationInfo(kernel.getAbstractNameFor(this),
configId, type));
+                        ConfigurationInfo configurationInfo = loadConfigurationInfo(configId);
+                        configs.add(configurationInfo);
                     } catch (Exception e) {
                     }
                 }
             }
         }
         return configs;
+    }
+
+    private ConfigurationInfo loadConfigurationInfo(Artifact configId) throws NoSuchConfigException,
IOException {
+        File location = repository.getLocation(configId);
+
+        if (!location.exists() && !location.canRead()) {
+            throw new NoSuchConfigException(configId);
+        }
+
+        ConfigurationInfo configurationInfo;
+        if (location.isDirectory()) {
+            File infoFile = new File(location, "META-INF");
+            infoFile = new File(infoFile, "config.info");
+
+            InputStream in = new FileInputStream(infoFile);
+            try {
+                configurationInfo = ConfigurationUtil.readConfigurationInfo(in, getAbstractName());
+            } finally {
+                IOUtil.close(in);
+            }
+        } else {
+            JarFile jarFile = new JarFile(location);
+            InputStream in = null;
+            try {
+                ZipEntry entry = jarFile.getEntry("META-INF/config.info");
+                in = jarFile.getInputStream(entry);
+                configurationInfo = ConfigurationUtil.readConfigurationInfo(in, getAbstractName());
+            } finally {
+                IOUtil.close(in);
+                IOUtil.close(jarFile);
+            }
+        }
+
+        return configurationInfo;
     }
 
 //    /**



Mime
View raw message