You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2009/10/05 20:54:56 UTC

svn commit: r821961 [4/30] - in /geronimo/sandbox/djencks/osgi/framework: ./ buildsupport/ buildsupport/car-maven-plugin/ buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/ buildsupport/geronimo-maven-plugin/src/main/java...

Modified: geronimo/sandbox/djencks/osgi/framework/configs/shutdown/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/configs/shutdown/src/main/history/dependencies.xml?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/configs/shutdown/src/main/history/dependencies.xml (original)
+++ geronimo/sandbox/djencks/osgi/framework/configs/shutdown/src/main/history/dependencies.xml Mon Oct  5 18:54:50 2009
@@ -7,43 +7,48 @@
         <type>car</type>
     </module-id>
     <dependency>
-        <groupId>asm</groupId>
-        <artifactId>asm</artifactId>
+        <groupId>javax.activation</groupId>
+        <artifactId>activation</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>asm</groupId>
-        <artifactId>asm-commons</artifactId>
+        <groupId>javax.xml.bind</groupId>
+        <artifactId>jaxb-api</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>cglib</groupId>
-        <artifactId>cglib-nodep</artifactId>
+        <groupId>javax.xml.bind</groupId>
+        <artifactId>jsr173_api</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>com.thoughtworks.xstream</groupId>
-        <artifactId>xstream</artifactId>
+        <groupId>javax.xml.stream</groupId>
+        <artifactId>stax-api</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>commons-cli</groupId>
-        <artifactId>commons-cli</artifactId>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>commons-jexl</groupId>
-        <artifactId>commons-jexl</artifactId>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.osgi.core</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>log4j</groupId>
-        <artifactId>log4j</artifactId>
+        <groupId>org.apache.geronimo.bundles</groupId>
+        <artifactId>asm</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>org.osgi.core</artifactId>
+        <groupId>org.apache.geronimo.bundles</groupId>
+        <artifactId>asm-commons</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.bundles</groupId>
+        <artifactId>commons-cli</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
@@ -113,17 +118,32 @@
     </dependency>
     <dependency>
         <groupId>org.apache.geronimo.specs</groupId>
-        <artifactId>geronimo-javaee-deployment_1.1MR3_spec</artifactId>
+        <artifactId>geronimo-activation_1.1_spec</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
         <groupId>org.apache.geronimo.specs</groupId>
-        <artifactId>geronimo-jaxb_2.1_spec</artifactId>
+        <artifactId>geronimo-javaee-deployment_1.1MR3_spec</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>org.apache.geronimo.specs</groupId>
-        <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.commons-jexl</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.commons-lang</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.jaxb-impl</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
@@ -133,6 +153,11 @@
     </dependency>
     <dependency>
         <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.woodstox</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
         <artifactId>org.apache.servicemix.bundles.xmlbeans</artifactId>
         <type>jar</type>
     </dependency>
@@ -142,6 +167,31 @@
         <type>jar</type>
     </dependency>
     <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.xpp3</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.xstream</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.specs</groupId>
+        <artifactId>org.apache.servicemix.specs.activation-api-1.1</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.specs</groupId>
+        <artifactId>org.apache.servicemix.specs.jaxb-api-2.1</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.specs</groupId>
+        <artifactId>org.apache.servicemix.specs.stax-api-1.0</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
         <groupId>org.apache.xbean</groupId>
         <artifactId>xbean-reflect</artifactId>
         <type>jar</type>

Modified: geronimo/sandbox/djencks/osgi/framework/configs/upgrade-cli/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/configs/upgrade-cli/src/main/history/dependencies.xml?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/configs/upgrade-cli/src/main/history/dependencies.xml (original)
+++ geronimo/sandbox/djencks/osgi/framework/configs/upgrade-cli/src/main/history/dependencies.xml Mon Oct  5 18:54:50 2009
@@ -7,6 +7,21 @@
         <type>car</type>
     </module-id>
     <dependency>
+        <groupId>cglib</groupId>
+        <artifactId>cglib-nodep</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>com.thoughtworks.xstream</groupId>
+        <artifactId>xstream</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
         <groupId>org.apache.geronimo.bundles</groupId>
         <artifactId>slf4j</artifactId>
         <type>jar</type>
@@ -26,4 +41,9 @@
         <artifactId>geronimo-upgrade</artifactId>
         <type>jar</type>
     </dependency>
+    <dependency>
+        <groupId>xpp3</groupId>
+        <artifactId>xpp3_min</artifactId>
+        <type>jar</type>
+    </dependency>
 </plugin-artifact>

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-cli/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-cli/pom.xml?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-cli/pom.xml (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-cli/pom.xml Mon Oct  5 18:54:50 2009
@@ -40,7 +40,7 @@
         </dependency>
 
         <dependency>
-            <groupId>commons-cli</groupId>
+            <groupId>org.apache.geronimo.bundles</groupId>
             <artifactId>commons-cli</artifactId>
         </dependency>
         <dependency>

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-commands/src/main/groovy/org/apache/geronimo/commands/GeronimoBranding.java Mon Oct  5 18:54:50 2009
@@ -35,7 +35,7 @@
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.IOUtil;
+import org.apache.geronimo.system.plugin.plexus.util.IOUtil;
 
 import jline.Terminal;
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/jmx/RemoteDeploymentManager.java Mon Oct  5 18:54:50 2009
@@ -63,10 +63,10 @@
 import org.apache.geronimo.system.plugin.PluginInstaller;
 import org.apache.geronimo.system.plugin.PluginRepositoryList;
 import org.apache.geronimo.system.plugin.ServerArchiver;
+import org.apache.geronimo.system.plugin.plexus.archiver.ArchiverException;
 import org.apache.geronimo.system.plugin.model.PluginListType;
 import org.apache.geronimo.system.plugin.model.PluginType;
 import org.apache.geronimo.system.plugin.model.AttributesType;
-import org.codehaus.plexus.archiver.ArchiverException;
 
 /**
  * Connects to a Kernel in a remote VM (may or many not be on the same machine).

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deployment/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deployment/pom.xml?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deployment/pom.xml (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deployment/pom.xml Mon Oct  5 18:54:50 2009
@@ -48,11 +48,10 @@
             <!--<artifactId>plexus-archiver</artifactId>-->
         <!--</dependency>-->
 
-        <!--<dependency>-->
-            <!--<groupId>org.apache.geronimo.specs</groupId>-->
-            <!--<artifactId>geronimo-stax-api_1.0_spec</artifactId>-->
-            <!--<scope>test</scope>-->
-        <!--</dependency>-->
+        <dependency>
+            <groupId>org.apache.servicemix.specs</groupId>
+            <artifactId>org.apache.servicemix.specs.stax-api-1.0</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.servicemix.bundles</groupId>

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentConfigurationManager.java Mon Oct  5 18:54:50 2009
@@ -37,6 +37,8 @@
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.config.NoSuchStoreException;
 import org.apache.geronimo.kernel.config.SimpleConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModel;
+import org.apache.geronimo.kernel.config.DeploymentWatcher;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.Repository;
@@ -51,10 +53,17 @@
     private final ConfigurationManager configurationManager;
 
     public DeploymentConfigurationManager(ConfigurationManager configurationManager, Collection<? extends Repository> repositories, BundleContext bundleContext) {
-        super(Arrays.asList(configurationManager.getStores()), configurationManager.getArtifactResolver(), repositories, bundleContext);
+        super(Arrays.asList(configurationManager.getStores()), configurationManager.getArtifactResolver(), repositories, Collections.<DeploymentWatcher>emptySet(), bundleContext, getConfigurationModel(configurationManager));
         this.configurationManager = configurationManager;
     }
 
+    private static ConfigurationModel getConfigurationModel(ConfigurationManager configurationManager) {
+        if (configurationManager instanceof SimpleConfigurationManager) {
+            return ((SimpleConfigurationManager)configurationManager).getConfigurationModel();
+        }
+        return new ConfigurationModel();
+    }
+
     //
     // GENERAL DATA
     //

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/pom.xml?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/pom.xml (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/pom.xml Mon Oct  5 18:54:50 2009
@@ -50,19 +50,23 @@
             <artifactId>geronimo-logging</artifactId>
             <version>${version}</version>
         </dependency>
+        <!--<dependency>-->
+            <!--<groupId>asm</groupId>-->
+            <!--<artifactId>asm</artifactId>-->
+        <!--</dependency>-->
+
         <dependency>
-            <groupId>asm</groupId>
+            <groupId>org.apache.geronimo.bundles</groupId>
             <artifactId>asm</artifactId>
         </dependency>
-
         <dependency>
-            <groupId>asm</groupId>
+            <groupId>org.apache.geronimo.bundles</groupId>
             <artifactId>asm-commons</artifactId>
         </dependency>
 
         <dependency>
-            <groupId>cglib</groupId>
-            <artifactId>cglib-nodep</artifactId>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
         </dependency>
 
         <dependency>
@@ -71,14 +75,14 @@
         </dependency>
 
         <dependency>
-            <groupId>com.thoughtworks.xstream</groupId>
-            <artifactId>xstream</artifactId>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.xstream</artifactId>
         </dependency>
 
-        <!--<dependency>-->
-            <!--<groupId>xpp3</groupId>-->
-            <!--<artifactId>xpp3_min</artifactId>-->
-        <!--</dependency>-->
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.xpp3</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.geronimo.testsupport</groupId>
             <artifactId>testsupport-common</artifactId>

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ConfigurationModel.java Mon Oct  5 18:54:50 2009
@@ -123,7 +123,7 @@
         return results.toArray(new Artifact[results.size()]);
     }
 
-    public LinkedHashSet load(Artifact configurationId) throws NoSuchConfigException {
+    public LinkedHashSet<Artifact> load(Artifact configurationId) throws NoSuchConfigException {
         ConfigurationStatus configurationStatus = configurations.get(configurationId);
         if (configurationStatus == null) {
             throw new NoSuchConfigException(configurationId);

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/KernelConfigurationManager.java Mon Oct  5 18:54:50 2009
@@ -72,12 +72,12 @@
     private boolean online = true;
 
     public KernelConfigurationManager(@ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
-                                      @ParamReference(name = "Stores") Collection<ConfigurationStore> stores,
+                                      @ParamReference(name = "Stores", namingType = "ConfigurationStore") Collection<ConfigurationStore> stores,
                                       @ParamReference(name = "AttributeStore", namingType = "AttributeStore") ManageableAttributeStore attributeStore,
                                       @ParamReference(name = "PersistentConfigurationList") PersistentConfigurationList configurationList,
                                       @ParamReference(name = "ArtifactManager", namingType = "ArtifactManager") ArtifactManager artifactManager,
                                       @ParamReference(name = "ArtifactResolver", namingType = "ArtifactResolver") ArtifactResolver artifactResolver,
-                                      @ParamReference(name = "Repositories") Collection<ListableRepository> repositories,
+                                      @ParamReference(name = "Repositories", namingType = "Repository") Collection<ListableRepository> repositories,
                                       @ParamReference(name = "Watchers") Collection<DeploymentWatcher> watchers,
                                       @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext) {
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Mon Oct  5 18:54:50 2009
@@ -57,7 +57,7 @@
     private final ArtifactResolver artifactResolver;
     protected final Map<Artifact, Configuration> configurations = new LinkedHashMap<Artifact, Configuration>();
     protected final Map<Artifact, Bundle> bundles = new LinkedHashMap<Artifact, Bundle>();
-    protected final ConfigurationModel configurationModel = new ConfigurationModel();
+    protected final ConfigurationModel configurationModel;
     protected final Collection<? extends Repository> repositories;
     protected final Collection<DeploymentWatcher> watchers;
     protected final BundleContext bundleContext;
@@ -79,11 +79,15 @@
         this(stores, artifactResolver, repositories, Collections.<DeploymentWatcher>emptySet(), bundleContext);
     }
 
-    public SimpleConfigurationManager(@ParamReference(name = "Stores") Collection<ConfigurationStore> stores,
+    public SimpleConfigurationManager(@ParamReference(name = "Stores", namingType = "ConfigurationStore") Collection<ConfigurationStore> stores,
                                       @ParamReference(name = "ArtifactResolver", namingType = "ArtifactResolver") ArtifactResolver artifactResolver,
-                                      @ParamReference(name = "Repositories") Collection<? extends Repository> repositories,
+                                      @ParamReference(name = "Repositories", namingType = "Repository") Collection<? extends Repository> repositories,
                                       @ParamReference(name = "Watchers") Collection<DeploymentWatcher> watchers,
                                       @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext) {
+        this(stores, artifactResolver, repositories, watchers, bundleContext, new ConfigurationModel());
+    }
+
+    public SimpleConfigurationManager(Collection<ConfigurationStore> stores, ArtifactResolver artifactResolver, Collection<? extends Repository> repositories, Collection<DeploymentWatcher> watchers, BundleContext bundleContext, ConfigurationModel configurationModel) {
         if (stores == null) stores = Collections.emptySet();
         if (repositories == null) repositories = Collections.emptySet();
         for (Repository repo : repositories) {
@@ -93,7 +97,7 @@
         for (DeploymentWatcher watcher : watchers) {
             if (watcher == null) throw new NullPointerException("null DeploymentWatcher");
         }
-
+        this.configurationModel = configurationModel;
         this.stores = stores;
         this.artifactResolver = artifactResolver;
         this.repositories = repositories;
@@ -101,6 +105,10 @@
         this.bundleContext = bundleContext;
     }
 
+    public ConfigurationModel getConfigurationModel() {
+        return configurationModel;
+    }
+
     public synchronized boolean isInstalled(Artifact configId) {
         if (!configId.isResolved()) {
             throw new IllegalArgumentException("Artifact " + configId + " is not fully resolved");

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/KernelActivator.java Mon Oct  5 18:54:50 2009
@@ -21,12 +21,28 @@
 package org.apache.geronimo.kernel.osgi;
 
 import java.util.Dictionary;
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.net.URL;
+import java.io.InputStream;
+import java.io.IOException;
 
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelFactory;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.config.PersistentConfigurationList;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.InvalidConfigException;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
@@ -40,9 +56,27 @@
         kernel.boot();
         Dictionary dictionary = null;//new Hashtable();
         kernelRegistration = bundleContext.registerService(Kernel.class.getName(), kernel, dictionary);
+        //boot the root configuration
+        Bundle bundle = bundleContext.getBundle();
+        URL plan = bundle.getEntry("META-INF/config.ser");
+        InputStream in = plan.openStream();
+        try {
+            //TODO there are additional consistency checks in RepositoryConfigurationStore that we should use.
+            ConfigurationData data = ConfigurationUtil.readConfigurationData(in);
+            data.setBundleContext(bundleContext);
+            AbstractName name = ConfigurationUtil.loadBootstrapConfiguration(kernel, data, bundleContext, false);
+//            Artifact id = data.getId();
+//            manager.startConfiguration(id);
+        } finally {
+            in.close();
+        }
+
     }
 
     public void stop(BundleContext bundleContext) throws Exception {
+        Kernel kernel = (Kernel) bundleContext.getService(kernelRegistration.getReference());
+        kernel.shutdown();
         kernelRegistration.unregister();
+        kernelRegistration = null;
     }
 }

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/repository/AbstractRepository.java Mon Oct  5 18:54:50 2009
@@ -55,7 +55,7 @@
         this.rootFile = rootFile;
         log.debug("Repository root is {}", rootFile.getAbsolutePath());
 
-        typeHandlers.put("car", new UnpackArtifactTypeHandler());
+//        typeHandlers.put("car", new UnpackArtifactTypeHandler());
     }
 
     public boolean contains(Artifact artifact) {

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/pom.xml?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/pom.xml (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/pom.xml Mon Oct  5 18:54:50 2009
@@ -49,36 +49,21 @@
         </dependency>
 
         <dependency>
-            <groupId>com.sun.xml.bind</groupId>
-            <artifactId>jaxb-impl</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-activation_1.1_spec</artifactId>
-            <scope>test</scope>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.jaxb-impl</artifactId>
         </dependency>
 
         <dependency>
-            <groupId>org.codehaus.woodstox</groupId>
-            <artifactId>wstx-asl</artifactId>
-            <scope>test</scope>
+            <groupId>org.apache.servicemix.specs</groupId>
+            <artifactId>org.apache.servicemix.specs.activation-api-1.1</artifactId>
         </dependency>
 
-        <!-- archiver seems to need to be same version as maven uses ??? -->
         <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>plexus-archiver</artifactId>
-            <scope>provided</scope>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.woodstox</artifactId>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.geronimo.bundles</groupId>
-            <artifactId>plexus-utils</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.geronimo.testsupport</groupId>
             <artifactId>testsupport-common</artifactId>
             <version>${version}</version>

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ArchiverGBean.java Mon Oct  5 18:54:50 2009
@@ -32,12 +32,12 @@
 import org.apache.geronimo.kernel.config.IOUtil;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.codehaus.plexus.archiver.Archiver;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.UnixStat;
-import org.codehaus.plexus.archiver.tar.TarArchiver;
-import org.codehaus.plexus.archiver.tar.TarLongFileMode;
-import org.codehaus.plexus.archiver.zip.ZipArchiver;
+import org.apache.geronimo.system.plugin.plexus.archiver.Archiver;
+import org.apache.geronimo.system.plugin.plexus.archiver.ArchiverException;
+import org.apache.geronimo.system.plugin.plexus.archiver.UnixStat;
+import org.apache.geronimo.system.plugin.plexus.archiver.tar.TarArchiver;
+import org.apache.geronimo.system.plugin.plexus.archiver.tar.TarLongFileMode;
+import org.apache.geronimo.system.plugin.plexus.archiver.zip.ZipArchiver;
 //maven inconsistency -- if we can use 1.0-alpha-9 uncomment
 //import org.codehaus.plexus.archiver.util.DefaultFileSet;
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/PluginInstallerGBean.java Mon Oct  5 18:54:50 2009
@@ -96,14 +96,14 @@
 import org.apache.geronimo.system.plugin.model.PluginArtifactType;
 import org.apache.geronimo.system.plugin.model.PluginListType;
 import org.apache.geronimo.system.plugin.model.PluginType;
+import org.apache.geronimo.system.plugin.model.PluginXmlUtil;
 import org.apache.geronimo.system.plugin.model.PrerequisiteType;
 import org.apache.geronimo.system.plugin.model.PropertyType;
-import org.apache.geronimo.system.plugin.model.PluginXmlUtil;
+import org.apache.geronimo.system.plugin.plexus.util.FileUtils;
 import org.apache.geronimo.system.repository.Maven2Repository;
 import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.system.threads.ThreadPool;
-import org.codehaus.plexus.util.FileUtils;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -151,19 +151,19 @@
      * @param threadPool                   thread pool for async operations
      * @param artifactManager              artifact manager to resolve existing artifacts
      * @param persistentConfigurationLists used to start new plugins in a running server
-     * @param bundleContext                  classLoader @throws IOException exception if server instance cannot be loaded
+     * @param bundleContext                classLoader @throws IOException exception if server instance cannot be loaded
      * @throws java.io.IOException from bad ServerInstance
      */
-    public PluginInstallerGBean(@ParamAttribute(name = "installedPluginsList")String installedPluginsList,
-                                @ParamReference(name = "ConfigManager", namingType = "ConfigurationManager")ConfigurationManager configManager,
-                                @ParamReference(name = "Repository", namingType = "Repository")WritableListableRepository repository,
-                                @ParamReference(name = "ConfigStore", namingType = "ConfigurationStore")ConfigurationStore configStore,
-                                @ParamReference(name = "ServerInstances", namingType = "ServerInstanceData")Collection<ServerInstanceData> serverInstanceDatas,
+    public PluginInstallerGBean(@ParamAttribute(name = "installedPluginsList") String installedPluginsList,
+                                @ParamReference(name = "ConfigManager", namingType = "ConfigurationManager") ConfigurationManager configManager,
+                                @ParamReference(name = "Repository", namingType = "Repository") WritableListableRepository repository,
+                                @ParamReference(name = "ConfigStore", namingType = "ConfigurationStore") ConfigurationStore configStore,
+                                @ParamReference(name = "ServerInstances", namingType = "ServerInstanceData") Collection<ServerInstanceData> serverInstanceDatas,
                                 @ParamReference(name = "ServerInfo") final ServerInfo serverInfo,
-                                @ParamReference(name = "ThreadPool")ThreadPool threadPool,
+                                @ParamReference(name = "ThreadPool") ThreadPool threadPool,
                                 @ParamReference(name = "ArtifactManager") final ArtifactManager artifactManager,
-                                @ParamReference(name = "PersistentConfigurationLists", namingType = "AttributeStore")Collection<PersistentConfigurationList> persistentConfigurationLists,
-                                @ParamReference(name = "PluginRepositoryList")PluginRepositoryList pluginRepositoryList,
+                                @ParamReference(name = "PersistentConfigurationLists", namingType = "AttributeStore") Collection<PersistentConfigurationList> persistentConfigurationLists,
+                                @ParamReference(name = "PluginRepositoryList") PluginRepositoryList pluginRepositoryList,
                                 @ParamSpecial(type = SpecialAttributeType.bundleContext) final BundleContext bundleContext) throws IOException {
         this(installedPluginsList, configManager, repository, configStore, serverInstanceDatas, serverInfo, threadPool, artifactManager, persistentConfigurationLists, pluginRepositoryList, bundleContext, true);
     }
@@ -209,7 +209,7 @@
      * @param serverInstanceDatas  set of server layouts
      * @param pluginRepositoryList
      * @param kernel               kernel for current server
-     * @param bundleContext          classLoader
+     * @param bundleContext        classLoader
      * @throws IOException if layouts can't be loaded
      */
     public PluginInstallerGBean(String targetRepositoryPath,
@@ -222,7 +222,7 @@
         final ArtifactManager artifactManager = new DefaultArtifactManager();
 
         FileUtils.forceMkdir(new File(targetServerPath));
-        serverInfo = new BasicServerInfo(targetServerPath, false);
+        serverInfo = new BasicServerInfo(targetServerPath, false, null);
         File targetRepositoryFile = serverInfo.resolve(targetRepositoryPath);
         FileUtils.forceMkdir(targetRepositoryFile);
         writeableRepo = new Maven2Repository(targetRepositoryFile);
@@ -452,7 +452,7 @@
                     targetServerPathName,
                     installedPluginsList,
                     serverInstanceDatas,
-                    pluginRepositoryList, 
+                    pluginRepositoryList,
                     kernel,
                     bundleContext);
 
@@ -729,7 +729,7 @@
                 try {
                     if (validatePlugins) {
                         if (!validatePlugin(metadata)) {
-                            throw new MissingDependencyException("Already installed", toArtifact(metadata.getPluginArtifact().get(0).getModuleId()), (Stack<Artifact>)null);
+                            throw new MissingDependencyException("Already installed", toArtifact(metadata.getPluginArtifact().get(0).getModuleId()), (Stack<Artifact>) null);
                         }
                         verifyPrerequisites(metadata);
                     }
@@ -806,8 +806,8 @@
                                     log.error("Unable to load configuration. ", e);
                                     configManager.uninstallConfiguration(artifact);
                                 }
-                            } 
-                            
+                            }
+
                             if (configManager.isLoaded(artifact)) {
                                 configManager.startConfiguration(artifact);
                             }
@@ -844,8 +844,8 @@
         if (!restrictToDefaultRepository) {
             if (!instance.getSourceRepository().isEmpty()) {
                 addRepos(repos, instance.getSourceRepository());
-            } 
-            
+            }
+
             //always add the default repository location no matter if the plugin instance contains source-repository.
             addRepos(repos, pluginsToInstall.getDefaultRepository());
         }
@@ -858,7 +858,7 @@
                 SourceRepository repo = pluginRepositoryList.getSourceRepository(repoLocation);
                 repos.add(repo);
             } catch (IllegalStateException e) {
-                log.warn("Invalid repository: "  + repoLocation, e);
+                log.warn("Invalid repository: " + repoLocation, e);
             }
         }
     }
@@ -1039,7 +1039,7 @@
         // 1. Check that it's not already installed
         if (metadata.getModuleId() != null) { // that is, it's a real configuration not a plugin list
             Artifact artifact = toArtifact(metadata.getModuleId());
-            
+
             //plugin groups don't get registered with configManager
             if (plugin.isPluginGroup() != null && plugin.isPluginGroup()) {
                 if (installedArtifacts.contains(artifact)) {
@@ -1229,7 +1229,7 @@
                 }
                 if (pluginData != null) { // it's a plugin, not a plain JAR
                     if (!validatePlugin(pluginData)) {
-                        monitor.getResults().addSkippedConfigID(new MissingDependencyException("already installed", configID, (Stack<Artifact>)null));
+                        monitor.getResults().addSkippedConfigID(new MissingDependencyException("already installed", configID, (Stack<Artifact>) null));
                         return;
                     }
                     instance = pluginData.getPluginArtifact().get(0);
@@ -1436,7 +1436,11 @@
                 log.error("Plugin install cannot write to file {}", target.getAbsolutePath());
                 continue;
             }
-            copyFile(url.openStream(), new FileOutputStream(target));
+            try {
+                copyFile(url.openStream(), new FileOutputStream(target));
+            } catch (NullPointerException e) {
+                throw (NullPointerException) new NullPointerException("problem copying path: " + path + " for artifact " + configID).initCause(e);
+            }
         }
     }
 
@@ -1727,7 +1731,8 @@
                 for (LicenseType licenseType : license) {
                     LicenseType otherLicense = that.license.get(i++);
                     if (licenseType.isOsiApproved() != otherLicense.isOsiApproved()) return false;
-                    if (licenseType.getValue() != null ? !licenseType.getValue().equals(otherLicense.getValue()) : otherLicense.getValue() != null) return false;
+                    if (licenseType.getValue() != null ? !licenseType.getValue().equals(otherLicense.getValue()) : otherLicense.getValue() != null)
+                        return false;
                 }
             }
 

Modified: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java?rev=821961&r1=821960&r2=821961&view=diff
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java (original)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/ServerArchiver.java Mon Oct  5 18:54:50 2009
@@ -24,7 +24,7 @@
 import java.io.IOException;
 
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.codehaus.plexus.archiver.ArchiverException;
+import org.apache.geronimo.system.plugin.plexus.archiver.ArchiverException;
 
 /**
  * @version $Rev$ $Date$

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiveFinalizer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiveFinalizer.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiveFinalizer.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiveFinalizer.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,21 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+public abstract class AbstractArchiveFinalizer
+    implements ArchiveFinalizer
+{
+    
+    protected AbstractArchiveFinalizer()
+    {
+    }
+
+    public void finalizeArchiveCreation( Archiver archiver )
+        throws ArchiverException
+    {
+    }
+
+    public void finalizeArchiveExtraction( UnArchiver unarchiver )
+        throws ArchiverException
+    {
+    }
+
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiveFinalizer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiver.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiver.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiver.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiver.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,899 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.apache.geronimo.system.plugin.plexus.archiver.manager.ArchiverManager;
+import org.apache.geronimo.system.plugin.plexus.archiver.manager.NoSuchArchiverException;
+import org.apache.geronimo.system.plugin.plexus.archiver.util.DefaultArchivedFileSet;
+import org.apache.geronimo.system.plugin.plexus.archiver.util.DefaultFileSet;
+import org.apache.geronimo.system.plugin.plexus.archiver.util.FilterSupport;
+import org.apache.geronimo.system.plugin.plexus.util.IOUtil;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoFileResourceCollection;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoResource;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoResourceCollection;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoResourceWithAttributes;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoArchivedResourceCollection;
+import org.apache.geronimo.system.plugin.plexus.io.resources.proxy.PlexusIoProxyResourceCollection;
+import org.apache.geronimo.system.plugin.plexus.io.attributes.PlexusIoResourceAttributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @version $Id: AbstractArchiver.java 8217 2009-05-27 00:56:55Z jdcasey $
+ */
+public abstract class AbstractArchiver
+    implements Archiver, FilterEnabled, FinalizerEnabled
+{
+
+    private static final Logger logger = LoggerFactory.getLogger(AbstractArchiver.class);
+
+    private File destFile;
+
+    /**
+     * A list of the following objects:
+     * <ul>
+     *   <li>Instances of {@link ArchiveEntry}, which are passed back by
+     *     {@link #getResources()} without modifications.</li>
+     *   <li>Instances of PlexusIoResourceCollection, which
+     *     are converted into an {@link Iterator} over instances of
+     *     {@link ArchiveEntry} by {@link #getResources()}.
+     * </ul>
+     */
+    private List resources = new ArrayList();
+
+    private boolean includeEmptyDirs = true;
+
+    private int fileMode = -1;
+
+    private int directoryMode = -1;
+
+    private int defaultFileMode = -1;
+
+    private int defaultDirectoryMode = -1;
+
+    private boolean forced = true;
+
+    private FilterSupport filterSupport;
+
+    private List finalizers;
+
+    private File dotFileDirectory;
+
+    private String duplicateBehavior = Archiver.DUPLICATES_SKIP;
+
+    // contextualized.
+    private ArchiverManager archiverManager;
+
+    public String getDuplicateBehavior()
+    {
+        return duplicateBehavior;
+    }
+
+    public void setDuplicateBehavior( String duplicate )
+    {
+        if ( !Archiver.DUPLICATES_VALID_BEHAVIORS.contains( duplicate ) )
+        {
+            throw new IllegalArgumentException( "Invalid duplicate-file behavior: \'" + duplicate
+                + "\'. Please specify one of: " + Archiver.DUPLICATES_VALID_BEHAVIORS );
+        }
+        
+        this.duplicateBehavior = duplicate;
+    }
+
+    public final void setFileMode( int mode )
+    {
+        fileMode = ( mode & UnixStat.PERM_MASK ) | UnixStat.FILE_FLAG;
+    }
+    
+    public final void setDefaultFileMode( int mode )
+    {
+        defaultFileMode = ( mode & UnixStat.PERM_MASK ) | UnixStat.FILE_FLAG;
+    }
+    
+    public final int getOverrideFileMode()
+    {
+        return fileMode;
+    }
+    
+    public final int getFileMode()
+    {
+        if ( fileMode < 0 )
+        {
+            if ( defaultFileMode < 0 )
+            {
+                return DEFAULT_FILE_MODE;
+            }
+            
+            return defaultFileMode;
+        }
+        
+        return fileMode;
+    }
+
+    public final int getDefaultFileMode()
+    {
+        return defaultFileMode;
+    }
+    
+    /**
+     * @deprecated Use {@link Archiver#getDefaultFileMode()}.
+     */
+    public final int getRawDefaultFileMode()
+    {
+        return getDefaultFileMode();
+    }
+    
+    public final void setDirectoryMode( int mode )
+    {
+        directoryMode = ( mode & UnixStat.PERM_MASK ) | UnixStat.DIR_FLAG;
+    }
+    
+    public final void setDefaultDirectoryMode( int mode )
+    {
+        defaultDirectoryMode = ( mode & UnixStat.PERM_MASK ) | UnixStat.DIR_FLAG;
+    }
+    
+    public final int getOverrideDirectoryMode()
+    {
+        return directoryMode;
+    }
+    
+    public final int getDirectoryMode()
+    {
+        if ( directoryMode < 0 )
+        {
+            if ( defaultDirectoryMode < 0 )
+            {
+                return DEFAULT_DIR_MODE;
+            }
+            
+            return defaultDirectoryMode;
+        }
+        
+        return directoryMode;
+    }
+
+    public final int getDefaultDirectoryMode()
+    {
+        return defaultDirectoryMode;
+    }
+    
+    /**
+     * @deprecated Use {@link Archiver#getDefaultDirectoryMode()}.
+     */
+    public final int getRawDefaultDirectoryMode()
+    {
+        return getDefaultDirectoryMode();
+    }
+
+    public boolean getIncludeEmptyDirs()
+    {
+        return includeEmptyDirs;
+    }
+
+    public void setIncludeEmptyDirs( boolean includeEmptyDirs )
+    {
+        this.includeEmptyDirs = includeEmptyDirs;
+    }
+
+    public void addDirectory( File directory )
+        throws ArchiverException
+    {
+        addDirectory( directory, "" );
+    }
+
+    public void addDirectory( File directory, String prefix )
+        throws ArchiverException
+    {
+        addDirectory( directory, prefix, null, null );
+    }
+
+    public void addDirectory( File directory, String[] includes, String[] excludes )
+        throws ArchiverException
+    {
+        addDirectory( directory, "", includes, excludes );
+    }
+
+    public void addDirectory( File directory, String prefix, String[] includes, String[] excludes )
+        throws ArchiverException
+    {
+        DefaultFileSet fileSet = new DefaultFileSet();
+        fileSet.setDirectory( directory );
+        fileSet.setPrefix( prefix );
+        fileSet.setIncludes( includes );
+        fileSet.setExcludes( excludes );
+        fileSet.setIncludingEmptyDirectories( includeEmptyDirs );
+        addFileSet( fileSet );
+    }
+
+    public void addFileSet( FileSet fileSet )
+        throws ArchiverException
+    {
+        File directory = fileSet.getDirectory();
+        if ( directory == null )
+        {
+            throw new ArchiverException( "The file sets base directory is null." );
+        }
+        
+        if ( !directory.isDirectory() )
+        {
+            throw new ArchiverException( directory.getAbsolutePath() + " isn't a directory." );
+        }
+        
+        PlexusIoFileResourceCollection collection = new PlexusIoFileResourceCollection( logger );
+        
+        collection.setIncludes( fileSet.getIncludes() );
+        collection.setExcludes( fileSet.getExcludes() );
+        collection.setBaseDir( directory );
+        collection.setFileSelectors( fileSet.getFileSelectors() );
+        collection.setIncludingEmptyDirectories( fileSet.isIncludingEmptyDirectories() );
+        collection.setPrefix( fileSet.getPrefix() );
+        collection.setCaseSensitive( fileSet.isCaseSensitive() );
+        collection.setUsingDefaultExcludes( fileSet.isUsingDefaultExcludes() );
+        
+        if ( getOverrideDirectoryMode() > -1 || getOverrideFileMode() > -1 )
+        {
+            collection.setOverrideAttributes( -1, null, -1, null, getOverrideFileMode(), getOverrideDirectoryMode() );
+        }
+        
+        if ( getDefaultDirectoryMode() > -1 || getDefaultFileMode() > -1 )
+        {
+            collection.setDefaultAttributes( -1, null, -1, null, getDefaultFileMode(), getDefaultDirectoryMode() );
+        }
+        
+        addResources( collection );
+    }
+
+    public void addFile( File inputFile, String destFileName )
+        throws ArchiverException
+    {
+        int fileMode = getOverrideFileMode();
+        
+        addFile( inputFile, destFileName, fileMode );
+    }
+
+    protected ArchiveEntry asArchiveEntry( PlexusIoResource resource, String destFileName, int permissions )
+        throws ArchiverException
+    {
+        if ( !resource.isExisting() )
+        {
+            throw new ArchiverException( resource.getName() + " not found." );
+        }
+        
+        if ( resource.isFile() )
+        {
+            return ArchiveEntry.createFileEntry( destFileName, resource, permissions );
+        }
+        else
+        {
+            return ArchiveEntry.createDirectoryEntry( destFileName, resource, permissions );
+        }
+    }
+
+    protected ArchiveEntry asArchiveEntry( PlexusIoResourceCollection collection, PlexusIoResource resource )
+        throws ArchiverException
+    {
+        try
+        {
+            final String destFileName = collection.getName( resource );
+            
+            int permissions = -1;
+            if ( resource instanceof PlexusIoResourceWithAttributes)
+            {
+                PlexusIoResourceAttributes attrs = ((PlexusIoResourceWithAttributes) resource ).getAttributes();
+                
+                if ( attrs != null )
+                {
+                    permissions = attrs.getOctalMode();
+                }
+            }
+            
+            return asArchiveEntry( resource, destFileName, permissions );
+        }
+        catch ( IOException e )
+        {
+            throw new ArchiverException( e.getMessage(), e );
+        }
+    }
+    
+    public void addResource( PlexusIoResource resource, String destFileName, int permissions )
+        throws ArchiverException
+    {
+        resources.add( asArchiveEntry( resource, destFileName, permissions ) );
+    }
+    
+    public void addFile( File inputFile, String destFileName, int permissions )
+        throws ArchiverException
+    {
+        if ( !inputFile.isFile() || !inputFile.exists() )
+        {
+            throw new ArchiverException( inputFile.getAbsolutePath() + " isn't a file." );
+        }
+
+        FileInputStream fileStream = null;
+
+        destFileName = destFileName.replace( '\\', '/' );
+
+        if ( permissions < 0 )
+        {
+            permissions = getOverrideFileMode();
+        }
+        
+        try
+        {
+            // do a null check here, to avoid creating a file stream if there are no filters...
+            if ( filterSupport != null )
+            {
+                fileStream = new FileInputStream( inputFile );
+
+                if ( include( fileStream, destFileName ) )
+                {
+                    resources.add( ArchiveEntry.createFileEntry( destFileName, inputFile, permissions ) );
+                }
+            }
+            else
+            {
+                resources.add( ArchiveEntry.createFileEntry( destFileName, inputFile, permissions ) );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new ArchiverException( "Failed to determine inclusion status for: " + inputFile, e );
+        }
+        catch ( ArchiveFilterException e )
+        {
+            throw new ArchiverException( "Failed to determine inclusion status for: " + inputFile, e );
+        }
+        finally
+        {
+            IOUtil.close( fileStream );
+        }
+    }
+
+    public ResourceIterator getResources()
+        throws ArchiverException
+    {
+        return new ResourceIterator()
+        {
+            private final Iterator addedResourceIter = resources.iterator();
+            private PlexusIoResourceCollection currentResourceCollection;
+            private Iterator ioResourceIter;
+            private ArchiveEntry nextEntry;
+            
+            private Set seenEntries = new HashSet();
+
+            public boolean hasNext()
+                throws ArchiverException
+            {
+                if ( nextEntry == null )
+                {
+                    if ( ioResourceIter == null )
+                    {
+                        if ( addedResourceIter.hasNext() )
+                        {
+                            Object o = addedResourceIter.next();
+                            if ( o instanceof ArchiveEntry )
+                            {
+                                nextEntry = (ArchiveEntry) o;
+                            }
+                            else if ( o instanceof PlexusIoResourceCollection )
+                            {
+                                currentResourceCollection = (PlexusIoResourceCollection) o;
+                                
+                                try
+                                {
+                                    ioResourceIter = currentResourceCollection.getResources();
+                                }
+                                catch ( IOException e )
+                                {
+                                    throw new ArchiverException( e.getMessage(), e );
+                                }
+                                
+                                return hasNext();
+                            }
+                            else
+                            {
+                                throw new IllegalStateException( "An invalid resource of type: "
+                                    + o.getClass().getName() + " was added to archiver: " + this.getClass().getName() );
+                            }
+                        }
+                        else
+                        {
+                            nextEntry = null;
+                        }
+                    }
+                    else
+                    {
+                        if ( ioResourceIter.hasNext() )
+                        {
+                            PlexusIoResource resource = (PlexusIoResource) ioResourceIter.next();
+                            nextEntry = asArchiveEntry( currentResourceCollection, resource );
+                        }
+                        else
+                        {
+                            ioResourceIter = null;
+                            return hasNext();
+                        }
+                    }
+                }
+                
+                if ( nextEntry != null && seenEntries.contains( nextEntry.getName() ) )
+                {
+                    String path = nextEntry.getName();
+                    
+                    if ( Archiver.DUPLICATES_PRESERVE.equals( duplicateBehavior ) || Archiver.DUPLICATES_SKIP.equals( duplicateBehavior ) )
+                    {
+                        getLogger().info( path + " already added, skipping" );
+                        
+                        nextEntry = null;
+                        return hasNext();
+                    }
+                    else if ( Archiver.DUPLICATES_FAIL.equals( duplicateBehavior ) )
+                    {
+                        throw new ArchiverException( "Duplicate file " + path + " was found and the duplicate "
+                            + "attribute is 'fail'." );
+                    }
+                    else
+                    {
+                        // duplicate equal to add, so we continue
+                        getLogger().debug( "duplicate file " + path + " found, adding." );
+                    }
+                }
+                
+                return nextEntry != null;
+            }
+
+            public ArchiveEntry next()
+                throws ArchiverException
+            {
+                if ( !hasNext() )
+                {
+                    throw new NoSuchElementException();
+                }
+                
+                ArchiveEntry next = nextEntry;
+                nextEntry = null;
+                
+                seenEntries.add( next.getName() );
+                
+                return next;
+            }
+        };
+    }
+
+    public Map getFiles()
+    {
+        try
+        {
+            final Map map = new HashMap();
+            for ( ResourceIterator iter = getResources();  iter.hasNext();  )
+            {
+                ArchiveEntry entry = (ArchiveEntry) iter.next();
+                if ( includeEmptyDirs  ||  entry.getType() == ArchiveEntry.FILE )
+                {
+                    map.put( entry.getName(), entry );
+                }
+            }
+            return map;
+        }
+        catch ( ArchiverException e )
+        {
+            throw new UndeclaredThrowableException( e );
+        }
+    }
+
+    public File getDestFile()
+    {
+        return destFile;
+    }
+
+    public void setDestFile( File destFile )
+    {
+        this.destFile = destFile;
+
+        if ( destFile != null )
+        {
+            destFile.getParentFile().mkdirs();
+        }
+    }
+
+    protected Logger getLogger()
+    {
+        return logger;
+    }
+
+    public Map getDirs()
+    {
+        try
+        {
+            final Map map = new HashMap();
+            for ( ResourceIterator iter = getResources();  iter.hasNext();  )
+            {
+                ArchiveEntry entry = (ArchiveEntry) iter.next();
+                if ( entry.getType() == ArchiveEntry.DIRECTORY )
+                {
+                    map.put( entry.getName(), entry );
+                }
+            }
+            return map;
+        }
+        catch ( ArchiverException e )
+        {
+            throw new UndeclaredThrowableException( e );
+        }
+    }
+
+    protected PlexusIoResourceCollection asResourceCollection( ArchivedFileSet fileSet )
+        throws ArchiverException
+    {
+        File archiveFile = fileSet.getArchive();
+
+        final PlexusIoResourceCollection resources;
+        try
+        {
+            resources = archiverManager.getResourceCollection( archiveFile );
+        }
+        catch ( NoSuchArchiverException e )
+        {
+            throw new ArchiverException( "Error adding archived file-set. PlexusIoResourceCollection not found for: " + archiveFile, e );
+        }
+
+        if ( resources instanceof PlexusIoArchivedResourceCollection )
+        {
+            ( (PlexusIoArchivedResourceCollection) resources ).setFile( fileSet.getArchive() );
+        }
+        else
+        {
+            throw new ArchiverException( "Expected "
+                                         + PlexusIoArchivedResourceCollection.class.getName()
+                                         + ", got " + resources.getClass().getName() );
+        }
+
+        final PlexusIoProxyResourceCollection proxy = new PlexusIoProxyResourceCollection();
+        
+        proxy.setSrc( resources );
+        proxy.setExcludes( fileSet.getExcludes() );
+        proxy.setIncludes( fileSet.getIncludes() );
+        proxy.setIncludingEmptyDirectories( fileSet.isIncludingEmptyDirectories() );
+        proxy.setCaseSensitive( fileSet.isCaseSensitive() );
+        proxy.setPrefix( fileSet.getPrefix() );
+        proxy.setUsingDefaultExcludes( fileSet.isUsingDefaultExcludes() );
+        proxy.setFileSelectors( fileSet.getFileSelectors() );
+        
+        if ( getOverrideDirectoryMode() > -1 || getOverrideFileMode() > -1 )
+        {
+            proxy.setOverrideAttributes( -1, null, -1, null, getOverrideFileMode(), getOverrideDirectoryMode() );
+        }
+        
+        if ( getDefaultDirectoryMode() > -1 || getDefaultFileMode() > -1 )
+        {
+            proxy.setDefaultAttributes( -1, null, -1, null, getDefaultFileMode(), getDefaultDirectoryMode() );
+        }
+        
+        return proxy;
+    }
+
+    /**
+     * Adds a resource collection to the archive.
+     */
+    public void addResources( PlexusIoResourceCollection collection )
+        throws ArchiverException
+    {
+        resources.add( collection );
+    }
+    
+    public void addArchivedFileSet( final ArchivedFileSet fileSet )
+        throws ArchiverException
+    {
+        final PlexusIoResourceCollection resourceCollection = asResourceCollection( fileSet );
+        addResources( resourceCollection );
+    }
+
+    /**
+     * @since 1.0-alpha-7
+     */
+    public void addArchivedFileSet( File archiveFile, String prefix, String[] includes, String[] excludes )
+        throws ArchiverException
+    {
+        DefaultArchivedFileSet fileSet = new DefaultArchivedFileSet();
+        fileSet.setArchive( archiveFile );
+        fileSet.setPrefix( prefix );
+        fileSet.setIncludes( includes );
+        fileSet.setExcludes( excludes );
+        fileSet.setIncludingEmptyDirectories( includeEmptyDirs );
+        addArchivedFileSet( fileSet );
+    }
+
+    /**
+     * @since 1.0-alpha-7
+     */
+    public void addArchivedFileSet( File archiveFile, String prefix )
+        throws ArchiverException
+    {
+        addArchivedFileSet( archiveFile, prefix, null, null );
+    }
+
+    /**
+     * @since 1.0-alpha-7
+     */
+    public void addArchivedFileSet( File archiveFile, String[] includes, String[] excludes )
+        throws ArchiverException
+    {
+        addArchivedFileSet( archiveFile, null, includes, excludes );
+    }
+
+    /**
+     * @since 1.0-alpha-7
+     */
+    public void addArchivedFileSet( File archiveFile )
+        throws ArchiverException
+    {
+        addArchivedFileSet( archiveFile, null, null, null );
+    }
+
+//    /**
+//     * Allows us to pull the ArchiverManager instance out of the container without
+//     * causing a chicken-and-egg instantiation/composition problem.
+//     */
+//    public void contextualize( Context context )
+//        throws ContextException
+//    {
+//        PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+//
+//        try
+//        {
+//            archiverManager = (ArchiverManager) container.lookup( ArchiverManager.ROLE );
+//        }
+//        catch ( ComponentLookupException e )
+//        {
+//            throw new ContextException( "Error retrieving ArchiverManager instance: " + e.getMessage(), e );
+//        }
+//    }
+
+    public boolean isForced()
+    {
+        return forced;
+    }
+
+    public void setForced( boolean forced )
+    {
+        this.forced = forced;
+    }
+
+    public void setArchiveFilters( List filters )
+    {
+        filterSupport = new FilterSupport( filters, getLogger() );
+    }
+
+    public void addArchiveFinalizer( ArchiveFinalizer finalizer )
+    {
+        if ( finalizers == null )
+        {
+            finalizers = new ArrayList();
+        }
+
+        finalizers.add( finalizer );
+    }
+
+    public void setArchiveFinalizers( List archiveFinalizers )
+    {
+        finalizers = archiveFinalizers;
+    }
+
+    public void setDotFileDirectory( File dotFileDirectory )
+    {
+        this.dotFileDirectory = dotFileDirectory;
+    }
+
+    protected boolean isUptodate()
+        throws ArchiverException
+    {
+        File zipFile = getDestFile();
+        long destTimestamp = zipFile.lastModified();
+        if ( destTimestamp == 0 )
+        {
+            getLogger().debug( "isUp2date: false (Destination " + zipFile.getPath() + " not found.)" );
+            return false; // File doesn't yet exist
+        }
+
+        Iterator it = resources.iterator();
+        if ( !it.hasNext() )
+        {
+            getLogger().debug( "isUp2date: false (No input files.)" );
+            return false; // No timestamp to compare
+        }
+
+        while ( it.hasNext() )
+        {
+            Object o = it.next();
+            final long l;
+            if ( o instanceof ArchiveEntry )
+            {
+                l = ( (ArchiveEntry) o ).getResource().getLastModified();
+            }
+            else if ( o instanceof PlexusIoResourceCollection )
+            {
+                try
+                {
+                    l = ( (PlexusIoResourceCollection) o ).getLastModified();
+                }
+                catch ( IOException e )
+                {
+                    throw new ArchiverException( e.getMessage(), e );
+                }
+            }
+            else
+            {
+                throw new IllegalStateException( "Invalid object type: " + o.getClass().getName() );
+            }
+            if ( l == PlexusIoResource.UNKNOWN_MODIFICATION_DATE )
+            {
+                // Don't know what to do. Safe thing is to assume not up2date.
+                getLogger().debug( "isUp2date: false (Resource with unknown modification date found.)" );
+                return false;
+            }
+            if ( l > destTimestamp )
+            {
+                getLogger().debug( "isUp2date: false (Resource with newer modification date found.)" );
+                return false;
+            }
+        }
+
+        getLogger().debug( "isUp2date: true" );
+        return true;
+    }
+
+    protected boolean checkForced()
+        throws ArchiverException
+    {
+        if ( !isForced() && isSupportingForced() && isUptodate() )
+        {
+            getLogger().debug( "Archive " + getDestFile() + " is uptodate." );
+            return false;
+        }
+        return true;
+    }
+
+    public boolean isSupportingForced()
+    {
+        return false;
+    }
+
+    protected List getArchiveFinalizers()
+    {
+        return finalizers;
+    }
+
+    protected void runArchiveFinalizers()
+        throws ArchiverException
+    {
+        if ( finalizers != null )
+        {
+            for ( Iterator it = finalizers.iterator(); it.hasNext(); )
+            {
+                ArchiveFinalizer finalizer = (ArchiveFinalizer) it.next();
+
+                finalizer.finalizeArchiveCreation( this );
+            }
+        }
+    }
+
+    private boolean include( InputStream in, String path )
+        throws ArchiveFilterException
+    {
+        return ( filterSupport == null ) || filterSupport.include( in, path );
+    }
+
+    public final void createArchive()
+        throws ArchiverException, IOException
+    {
+        validate();
+        try
+        {
+            try
+            {
+                if ( dotFileDirectory != null )
+                {
+                    addArchiveFinalizer( new DotDirectiveArchiveFinalizer( dotFileDirectory ) );
+                }
+
+                runArchiveFinalizers();
+
+                execute();
+            }
+            finally
+            {
+                close();
+            }
+        }
+        catch ( IOException e )
+        {
+            String msg = "Problem creating " + getArchiveType() + ": " + e.getMessage();
+
+            StringBuffer revertBuffer = new StringBuffer();
+            if ( !revert( revertBuffer ) )
+            {
+                msg += revertBuffer.toString();
+            }
+
+            throw new ArchiverException( msg, e );
+        }
+        finally
+        {
+            cleanUp();
+        }
+    }
+
+    protected boolean hasVirtualFiles()
+    {
+        if ( finalizers != null )
+        {
+            for ( Iterator it = finalizers.iterator(); it.hasNext(); )
+            {
+                ArchiveFinalizer finalizer = (ArchiveFinalizer) it.next();
+
+                List virtualFiles = finalizer.getVirtualFiles();
+
+                if ( ( virtualFiles != null ) && !virtualFiles.isEmpty() )
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    protected boolean revert( StringBuffer messageBuffer )
+    {
+        return true;
+    }
+
+    protected void validate()
+        throws ArchiverException, IOException
+    {
+    }
+
+    protected abstract String getArchiveType();
+
+    protected abstract void close()
+        throws IOException;
+
+    protected void cleanUp()
+    {
+        resources.clear();
+    }
+
+    protected abstract void execute()
+        throws ArchiverException, IOException;
+
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractArchiver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractUnArchiver.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractUnArchiver.java?rev=821961&view=auto
==============================================================================
--- geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractUnArchiver.java (added)
+++ geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractUnArchiver.java Mon Oct  5 18:54:50 2009
@@ -0,0 +1,251 @@
+package org.apache.geronimo.system.plugin.plexus.archiver;
+
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.geronimo.system.plugin.plexus.archiver.util.FilterSupport;
+import org.apache.geronimo.system.plugin.plexus.io.fileselectors.FileSelector;
+import org.apache.geronimo.system.plugin.plexus.io.resources.PlexusIoResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
+ * @version $Revision$ $Date$
+ * @todo there should really be constructors which take the source file.
+ */
+public abstract class AbstractUnArchiver
+    implements UnArchiver, FinalizerEnabled, FilterEnabled
+{
+    private static final Logger logger = LoggerFactory.getLogger(AbstractUnArchiver.class);
+    private File destDirectory;
+
+    private File destFile;
+
+    private File sourceFile;
+
+    private boolean overwrite = true;
+
+    private FilterSupport filterSupport;
+
+    private List finalizers;
+
+    private FileSelector[] fileSelectors;
+
+    public AbstractUnArchiver()
+    {
+    }
+
+    public AbstractUnArchiver( File sourceFile )
+    {
+        this.sourceFile = sourceFile;
+    }
+
+    public static Logger getLogger() {
+        return logger;
+    }
+
+    public File getDestDirectory()
+    {
+        return destDirectory;
+    }
+
+    public void setDestDirectory( File destDirectory )
+    {
+        this.destDirectory = destDirectory;
+    }
+
+    public File getDestFile()
+    {
+        return destFile;
+    }
+
+    public void setDestFile( File destFile )
+    {
+        this.destFile = destFile;
+    }
+
+    public File getSourceFile()
+    {
+        return sourceFile;
+    }
+
+    public void setSourceFile( File sourceFile )
+    {
+        this.sourceFile = sourceFile;
+    }
+
+    public boolean isOverwrite()
+    {
+        return overwrite;
+    }
+
+    public void setOverwrite( boolean b )
+    {
+        overwrite = b;
+    }
+
+    public final void extract()
+        throws ArchiverException
+    {
+        validate();
+        execute();
+        runArchiveFinalizers();
+    }
+
+    public final void extract( String path, File outputDirectory )
+        throws ArchiverException
+    {
+        validate( path, outputDirectory );
+        execute( path, outputDirectory );
+        runArchiveFinalizers();
+    }
+
+    public void setArchiveFilters( List filters )
+    {
+        filterSupport = new FilterSupport( filters, logger);
+    }
+
+    public void addArchiveFinalizer( ArchiveFinalizer finalizer )
+    {
+        if ( finalizers == null )
+        {
+            finalizers = new ArrayList();
+        }
+
+        finalizers.add( finalizer );
+    }    
+
+    public void setArchiveFinalizers( List archiveFinalizers )
+    {
+        this.finalizers = archiveFinalizers;
+    }
+
+    private final void runArchiveFinalizers()
+        throws ArchiverException
+    {
+        if ( finalizers != null )
+        {
+            for ( Iterator it = finalizers.iterator(); it.hasNext(); )
+            {
+                ArchiveFinalizer finalizer = (ArchiveFinalizer) it.next();
+
+                finalizer.finalizeArchiveExtraction( this );
+            }
+        }
+    }
+
+    protected boolean include( InputStream inputStream, String name )
+        throws ArchiveFilterException
+    {
+        return filterSupport == null || filterSupport.include( inputStream, name );
+    }
+
+    protected void validate( String path, File outputDirectory )
+    {
+    }
+
+    protected void validate()
+        throws ArchiverException
+    {
+        if ( sourceFile == null )
+        {
+            throw new ArchiverException( "The source file isn't defined." );
+        }
+
+        if ( sourceFile.isDirectory() )
+        {
+            throw new ArchiverException( "The source must not be a directory." );
+        }
+
+        if ( !sourceFile.exists() )
+        {
+            throw new ArchiverException( "The source file " + sourceFile + " doesn't exist." );
+        }
+
+        if ( destDirectory == null && destFile == null )
+        {
+            throw new ArchiverException( "The destination isn't defined." );
+        }
+
+        if ( destDirectory != null && destFile != null )
+        {
+            throw new ArchiverException( "You must choose between a destination directory and a destination file." );
+        }
+
+        if ( destDirectory != null && !destDirectory.isDirectory() )
+        {
+            destFile = destDirectory;
+            destDirectory = null;
+        }
+
+        if ( destFile != null && destFile.isDirectory() )
+        {
+            destDirectory = destFile;
+            destFile = null;
+        }
+    }
+
+    public void setFileSelectors( FileSelector[] fileSelectors )
+    {
+        this.fileSelectors = fileSelectors;
+    }
+
+    public FileSelector[] getFileSelectors( )
+    {
+        return fileSelectors;
+    }
+
+    protected boolean isSelected( String fileName, PlexusIoResource fileInfo )
+            throws ArchiverException
+    {
+        if ( fileSelectors != null )
+        {
+            for ( int i = 0;  i < fileSelectors.length;  i++ )
+            {
+                try {
+                    if ( !fileSelectors[i].isSelected( fileInfo ) )
+                    {
+                        return false;
+                    }
+                }
+                catch ( IOException e )
+                {
+                    throw new ArchiverException( "Failed to check, whether "
+                                                 + fileInfo.getName()
+                                                 + " is selected: "
+                                                 + e.getMessage(), e );
+                }
+            }
+        }
+        return true;
+    }
+
+    protected abstract void execute()
+        throws ArchiverException;
+
+    protected abstract void execute( String path, File outputDirectory )
+        throws ArchiverException;
+
+}

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractUnArchiver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractUnArchiver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/osgi/framework/modules/geronimo-plugin/src/main/java/org/apache/geronimo/system/plugin/plexus/archiver/AbstractUnArchiver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain