geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r941144 - in /geronimo/server/trunk/plugins/aries: ./ aries-deployer/ aries-deployer/src/main/history/ geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/
Date Wed, 05 May 2010 04:50:17 GMT
Author: gawor
Date: Wed May  5 04:50:17 2010
New Revision: 941144

URL: http://svn.apache.org/viewvc?rev=941144&view=rev
Log:
GERONIMO-5285: Update some of the aries application code so that it works better with the
standard deploy/undeploy/start/stop operations

Modified:
    geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml
    geronimo/server/trunk/plugins/aries/aries-deployer/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
    geronimo/server/trunk/plugins/aries/pom.xml

Modified: geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml?rev=941144&r1=941143&r2=941144&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml (original)
+++ geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml Wed May  5 04:50:17 2010
@@ -48,12 +48,13 @@
             <version>${version}</version>
         </dependency>
 
+<!--
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-aries-shell</artifactId>
             <version>${version}</version>
         </dependency>
-
+-->
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-aries-resolver</artifactId>

Modified: geronimo/server/trunk/plugins/aries/aries-deployer/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/aries-deployer/src/main/history/dependencies.xml?rev=941144&r1=941143&r2=941144&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/aries-deployer/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/aries/aries-deployer/src/main/history/dependencies.xml Wed
May  5 04:50:17 2010
@@ -32,21 +32,6 @@
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>org.apache.felix.gogo</groupId>
-        <artifactId>org.apache.felix.gogo.commands</artifactId>
-        <type>jar</type>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.felix.gogo</groupId>
-        <artifactId>org.apache.felix.gogo.runtime</artifactId>
-        <type>jar</type>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.felix.karaf.shell</groupId>
-        <artifactId>org.apache.felix.karaf.shell.console</artifactId>
-        <type>jar</type>
-    </dependency>
-    <dependency>
         <groupId>org.apache.geronimo.components</groupId>
         <artifactId>geronimo-jaspi</artifactId>
         <type>jar</type>
@@ -103,11 +88,6 @@
     </dependency>
     <dependency>
         <groupId>org.apache.geronimo.modules</groupId>
-        <artifactId>geronimo-aries-shell</artifactId>
-        <type>jar</type>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.geronimo.modules</groupId>
         <artifactId>geronimo-j2ee</artifactId>
         <type>jar</type>
     </dependency>

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java?rev=941144&r1=941143&r2=941144&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java
Wed May  5 04:50:17 2010
@@ -18,12 +18,21 @@ package org.apache.geronimo.aries.builde
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.Collection;
 import java.util.jar.JarFile;
+import java.util.jar.Manifest;
 
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.ApplicationMetadataFactory;
+import org.apache.aries.application.filesystem.IDirectory;
+import org.apache.aries.application.filesystem.IFile;
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.utils.AppConstants;
 import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.aries.application.utils.manifest.ManifestDefaultsInjector;
+import org.apache.aries.application.utils.manifest.ManifestProcessor;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ConfigurationBuilder;
 import org.apache.geronimo.deployment.DeploymentContext;
@@ -55,8 +64,8 @@ public class ApplicationConfigBuilder im
     private ApplicationInstaller installer;
 
     public ApplicationConfigBuilder(@ParamReference(name="Installer") ApplicationInstaller
installer,
-                                 @ParamSpecial(type = SpecialAttributeType.kernel) Kernel
kernel,
-                                 @ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext) 
+                                    @ParamSpecial(type = SpecialAttributeType.kernel) Kernel
kernel,
+                                    @ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext) 
         throws GBeanNotFoundException {
         this.installer = installer;
         this.bundleContext = bundleContext;
@@ -82,6 +91,16 @@ public class ApplicationConfigBuilder im
         }
     }
            
+    private ApplicationMetadataFactory getApplicationMetadataFactory() {
+        ServiceReference ref = 
+            bundleContext.getServiceReference(ApplicationMetadataFactory.class.getName());
+        if (ref != null) {
+            return (ApplicationMetadataFactory) bundleContext.getService(ref);
+        } else {
+            return null;
+        }
+    }
+    
     public Object getDeploymentPlan(File planFile, 
                                     JarFile jarFile, 
                                     ModuleIDBuilder idBuilder) 
@@ -100,11 +119,24 @@ public class ApplicationConfigBuilder im
     public Artifact getConfigurationID(Object plan, 
                                        JarFile jarFile, 
                                        ModuleIDBuilder idBuilder)
-        throws IOException, DeploymentException {
-        
-        Artifact name = new Artifact("eba", "application", "0.0.0", "jar");
-        
-        return name;
+        throws IOException, DeploymentException {        
+        ApplicationMetadataFactory factory = getApplicationMetadataFactory();        
+        IDirectory ebaFile = FileSystem.getFSRoot(new File(jarFile.getName()));        
+        IFile applicationManifestFile = ebaFile.getFile(AppConstants.APPLICATION_MF);
+        Manifest applicationManifest;
+        if (applicationManifestFile != null) {
+            InputStream in = applicationManifestFile.open();
+            try {
+                applicationManifest = ManifestProcessor.parseManifest(in);
+            } finally {
+                try { in.close(); } catch (IOException ignore) {}
+            }
+        } else {
+            applicationManifest = new Manifest();
+        }
+        ManifestDefaultsInjector.updateManifest(applicationManifest, ebaFile.getName(), ebaFile);

+        ApplicationMetadata metadata = factory.createApplicationMetadata(applicationManifest);
+        return ApplicationInstaller.getConfigId(metadata);        
     }
     
     public DeploymentContext buildConfiguration(boolean inPlaceDeployment, 

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java?rev=941144&r1=941143&r2=941144&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
Wed May  5 04:50:17 2010
@@ -238,11 +238,13 @@ public class ApplicationGBean implements
         
         for (Bundle bundle : applicationBundles) {
             try {
-                bundle.stop();
+                bundle.uninstall();
             } catch (Exception e) {
                 e.printStackTrace();
             }
         }
+        applicationBundles.clear();
+
         applicationState = ApplicationState.RESOLVED;
     }
 
@@ -262,7 +264,6 @@ public class ApplicationGBean implements
     protected void applicationStop() throws BundleException {
         try {
             installer.getConfigurationManager().unloadConfiguration(configId);
-            bundle.stop();
         } catch (Exception e) {
             throw new BundleException("Failed to start application", e);            
         }
@@ -270,27 +271,15 @@ public class ApplicationGBean implements
     
     protected void applicationUninstall() {
         LOG.debug("Uninstalling {}", application.getApplicationMetadata().getApplicationScope());
-        
-        // uninstall application bundles
-        for (Bundle bundle : applicationBundles) {
-            try {
-                bundle.uninstall();
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-        applicationBundles.clear();
 
-        // uninstall configuration
-        installer.uninstall(application);
-        
-        // uninstall application bundle         
         try {
-            bundle.uninstall();
+            installer.getConfigurationManager().unloadConfiguration(configId);
+            installer.getConfigurationManager().uninstallConfiguration(configId);
         } catch (Exception e) {
-            e.printStackTrace();
-        }        
-        
+            // ignore
+        }
+                     
         applicationState = ApplicationState.UNINSTALLED;
     }
+
 }

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java?rev=941144&r1=941143&r2=941144&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
Wed May  5 04:50:17 2010
@@ -20,6 +20,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
 
+import org.apache.aries.application.ApplicationMetadata;
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.DeploymentContext;
@@ -41,7 +42,6 @@ import org.apache.geronimo.kernel.config
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.kernel.util.FileUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
@@ -95,19 +95,21 @@ public class ApplicationInstaller implem
     }
     
     public DeploymentContext startInstall(AriesApplication app, ConfigurationStore targetConfigurationStore)

-        throws ConfigurationAlreadyExistsException, DeploymentException {
+        throws ConfigurationAlreadyExistsException, IOException, DeploymentException {
                                 
-        Artifact configId = getConfigId(app);
+        Artifact configId = getConfigId(app.getApplicationMetadata());
         
-        File configDir = targetConfigurationStore.createNewConfigurationDir(configId);
+        targetConfigurationStore.createNewConfigurationDir(configId);
         
         Environment environment = new Environment();
         environment.setConfigId(configId);
         
         Naming naming = kernel.getNaming();
         AbstractName moduleName = naming.createRootName(configId, configId.toString(), "AriesApplication");
+        //Use a temporary folder to hold the extracted files for analysis use
+        File tempDirectory = FileUtils.createTempDir();
         try {
-            DeploymentContext context = new DeploymentContext(configDir,                
+            DeploymentContext context = new DeploymentContext(tempDirectory,            
   
                             null,
                             environment,
                             moduleName,
@@ -120,7 +122,7 @@ public class ApplicationInstaller implem
             context.flush();
             context.initializeConfiguration();
                         
-            app.store(configDir);
+            app.store(tempDirectory);
                         
             AbstractName name = naming.createChildName(moduleName, "AriesApplication", "GBean");
             GBeanData data = new GBeanData(name, ApplicationGBean.class);
@@ -153,7 +155,7 @@ public class ApplicationInstaller implem
         }
     }
     
-    public void install(AriesApplication app) throws ConfigurationAlreadyExistsException,
DeploymentException {
+    public void install(AriesApplication app) throws ConfigurationAlreadyExistsException,
IOException, DeploymentException {
         ConfigurationStore store = configurationStores.iterator().next();
         if (store == null) {
             throw new DeploymentException("No ConfigurationStore");
@@ -169,39 +171,13 @@ public class ApplicationInstaller implem
             throw new DeploymentException("", e);
         }
     }
-    
-    public void uninstall(AriesApplication app) {
-        Artifact configId = getConfigId(app);
-        try {            
-            Repository repository = findRepository(configId);
-            File location = repository.getLocation(configId);
-            
-            configurationManager.unloadConfiguration(configId);
-            configurationManager.uninstallConfiguration(configId);
             
-            FileUtils.recursiveDelete(location.getParentFile());
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-    
-    private Repository findRepository(Artifact configId) {
-        for (Repository repository : configurationManager.getRepositories()) {
-            if (repository.contains(configId)) {
-                return repository;
-            }
-        }
-        return null;
-    }
-    
-    private static Artifact getConfigId(AriesApplication app) {
-        return createArtifact("aries-app", 
-                              app.getApplicationMetadata().getApplicationSymbolicName(),

-                              app.getApplicationMetadata().getApplicationVersion());
+    public static Artifact getConfigId(ApplicationMetadata metadata) {
+        return createArtifact("application", metadata.getApplicationSymbolicName(), metadata.getApplicationVersion());
     }
     
     private static Artifact createArtifact(String group, String symbolicName, Version version)
{
-        return new Artifact(group, symbolicName, getVersion(version), "jar");
+        return new Artifact(group, symbolicName, getVersion(version), "eba");
     }
     
     private static String getVersion(Version version) {

Modified: geronimo/server/trunk/plugins/aries/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/pom.xml?rev=941144&r1=941143&r2=941144&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/pom.xml (original)
+++ geronimo/server/trunk/plugins/aries/pom.xml Wed May  5 04:50:17 2010
@@ -39,7 +39,9 @@
     <modules>
         <module>geronimo-aries-builder</module>
         <module>geronimo-aries-resolver</module>
+<!--
         <module>geronimo-aries-shell</module>
+-->
         <module>aries-deployer</module>
     </modules>
 
@@ -48,17 +50,17 @@
             <dependency>
                 <groupId>org.apache.aries.application</groupId>
                 <artifactId>org.apache.aries.application.utils</artifactId>
-                <version>0.1-incubating</version>
+                <version>0.1-incubating-SNAPSHOT</version>
             </dependency>
             <dependency>
                 <groupId>org.apache.aries.application</groupId>
                 <artifactId>org.apache.aries.application.api</artifactId>
-                <version>0.1-incubating</version>
+                <version>0.1-incubating-SNAPSHOT</version>
             </dependency>
             <dependency>
                 <groupId>org.apache.aries.application</groupId>
                 <artifactId>org.apache.aries.application.management</artifactId>
-                <version>0.1-incubating</version>
+                <version>0.1-incubating-SNAPSHOT</version>
             </dependency>
         </dependencies>
     </dependencyManagement>



Mime
View raw message