geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r922153 [1/2] - in /geronimo/server/trunk/plugins/aries: ./ aries-deployer/ aries-deployer/src/main/history/ aries-deployer/src/main/plan/ geronimo-aries-builder/ geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ geron...
Date Fri, 12 Mar 2010 06:25:47 GMT
Author: gawor
Date: Fri Mar 12 06:25:46 2010
New Revision: 922153

URL: http://svn.apache.org/viewvc?rev=922153&view=rev
Log:
GERONIMO-4971: Much improved Aries application support along with Karaf shell commands for installing/uninstalling/starting/stopping/listing applications

Added:
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java
      - copied, changed from r922109, geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplication.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContextManager.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoLocalPlatform.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/NoOpResolver.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/app-context-management.xml   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/pom.xml   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ApplicationCommandSupport.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/InstallApplication.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ListApplication.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StartApplication.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StopApplication.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/UninstallApplication.java   (with props)
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/resources/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/resources/OSGI-INF/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/resources/OSGI-INF/blueprint/
    geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/resources/OSGI-INF/blueprint/shell-eba.xml   (with props)
Removed:
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java
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/aries-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/pom.xml
    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=922153&r1=922152&r2=922153&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml (original)
+++ geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml Fri Mar 12 06:25:46 2010
@@ -49,26 +49,26 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.aries.application</groupId>
-            <artifactId>org.apache.aries.application.api</artifactId>
-            <version>1.0.0-incubating-SNAPSHOT</version>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-aries-shell</artifactId>
+            <version>${version}</version>
         </dependency>
+
         <dependency>
             <groupId>org.apache.aries.application</groupId>
-            <artifactId>org.apache.aries.application.management</artifactId>
-            <version>1.0.0-incubating-SNAPSHOT</version>
+            <artifactId>org.apache.aries.application.api</artifactId>
         </dependency>
+
         <dependency>
             <groupId>org.apache.aries.application</groupId>
-            <artifactId>org.apache.aries.application.runtime</artifactId>
-            <version>1.0.0-incubating-SNAPSHOT</version>
+            <artifactId>org.apache.aries.application.management</artifactId>
         </dependency>
+<!--
         <dependency>
             <groupId>org.apache.aries.application</groupId>
             <artifactId>org.apache.aries.application.resolver.obr</artifactId>
-            <version>1.0.0-incubating-SNAPSHOT</version>
         </dependency>
-
+-->
     </dependencies>
 
     <build>

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=922153&r1=922152&r2=922153&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 Fri Mar 12 06:25:46 2010
@@ -18,17 +18,22 @@
     </dependency>
     <dependency>
         <groupId>org.apache.aries.application</groupId>
-        <artifactId>org.apache.aries.application.resolver.obr</artifactId>
+        <artifactId>org.apache.aries.application.utils</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>org.apache.aries.application</groupId>
-        <artifactId>org.apache.aries.application.runtime</artifactId>
+        <groupId>org.apache.felix.gogo</groupId>
+        <artifactId>org.apache.felix.gogo.commands</artifactId>
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>org.apache.aries.application</groupId>
-        <artifactId>org.apache.aries.application.utils</artifactId>
+        <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>
@@ -83,6 +88,11 @@
     </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/aries-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/aries-deployer/src/main/plan/plan.xml?rev=922153&r1=922152&r2=922153&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/aries-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/aries/aries-deployer/src/main/plan/plan.xml Fri Mar 12 06:25:46 2010
@@ -18,9 +18,14 @@
 
 <module xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
 
-    <gbean name="AriesAppBuilder" class="org.apache.geronimo.aries.builder.AriesAppConfigBuilder">
-        <reference name="Repository">
-            <name>Repository</name>
+    <gbean name="ApplicationBuilder" class="org.apache.geronimo.aries.builder.ApplicationConfigBuilder">
+        <reference name="Installer">
+            <name>AppInstaller</name>
+        </reference>
+    </gbean>
+
+    <gbean name="AppInstaller" class="org.apache.geronimo.aries.builder.ApplicationInstaller">
+        <reference name="Store">
         </reference>
     </gbean>
 

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/pom.xml?rev=922153&r1=922152&r2=922153&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/pom.xml (original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/pom.xml Fri Mar 12 06:25:46 2010
@@ -42,7 +42,6 @@
         <dependency>
             <groupId>org.apache.aries.application</groupId>
             <artifactId>org.apache.aries.application.utils</artifactId>
-            <version>1.0.0-incubating-SNAPSHOT</version>
         </dependency>
     </dependencies>
 

Copied: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java (from r922109, geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.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?p2=geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java&p1=geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java&r1=922109&r2=922153&rev=922153&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java (original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java Fri Mar 12 06:25:46 2010
@@ -18,24 +18,16 @@ 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.Enumeration;
-import java.util.HashMap;
-import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-import java.util.zip.ZipEntry;
 
-import org.apache.aries.application.ApplicationMetadata;
-import org.apache.aries.application.ApplicationMetadataFactory;
-import org.apache.aries.application.Content;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.utils.filesystem.FileSystem;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ConfigurationBuilder;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
-import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamReference;
@@ -43,21 +35,10 @@ import org.apache.geronimo.gbean.annotat
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.Naming;
-import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
-import org.apache.geronimo.kernel.config.ConfigurationManager;
-import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
-import org.apache.geronimo.kernel.config.ConfigurationUtil;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
-import org.apache.geronimo.kernel.repository.Dependency;
-import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.kernel.repository.ImportType;
-import org.apache.geronimo.kernel.repository.WritableListableRepository;
-import org.apache.geronimo.kernel.util.JarUtils;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -66,23 +47,19 @@ import org.slf4j.LoggerFactory;
  * @version $Rev:385232 $ $Date$
  */
 @GBean(j2eeType = "ConfigBuilder")
-public class AriesAppConfigBuilder implements ConfigurationBuilder, GBeanLifecycle {
+public class ApplicationConfigBuilder implements ConfigurationBuilder, GBeanLifecycle {
     
-    private static final Logger LOG = LoggerFactory.getLogger(AriesAppConfigBuilder.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ApplicationConfigBuilder.class);
     
-    private Kernel kernel;
     private BundleContext bundleContext;
-    private WritableListableRepository repository;
-    private ConfigurationManager configurationManager;
+    private ApplicationInstaller installer;
 
-    public AriesAppConfigBuilder(@ParamReference(name="Repository", namingType = "Repository")WritableListableRepository repository,
+    public ApplicationConfigBuilder(@ParamReference(name="Installer") ApplicationInstaller installer,
                                  @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
                                  @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext) 
         throws GBeanNotFoundException {
-        this.repository = repository;
-        this.kernel = kernel;
+        this.installer = installer;
         this.bundleContext = bundleContext;
-        this.configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
     }
     
     public void doStart() throws Exception {
@@ -94,136 +71,38 @@ public class AriesAppConfigBuilder imple
     public void doFail() {
         doStop();
     }
-
-    private WritableListableRepository getRepository() {
-        return repository;   
-    }
-    
-    private ApplicationMetadataFactory getApplicationMetadataManager() {
+        
+    private AriesApplicationManager getAriesApplicationManager() {
         ServiceReference ref = 
-            bundleContext.getServiceReference(ApplicationMetadataFactory.class.getName());
+            bundleContext.getServiceReference(AriesApplicationManager.class.getName());
         if (ref != null) {
-            return (ApplicationMetadataFactory) bundleContext.getService(ref);
+            return (AriesApplicationManager) bundleContext.getService(ref);
         } else {
             return null;
         }
     }
-    
-    private String getSymbolicName(Manifest mf) {
-        String name = null;
-        if (mf != null) {
-            name = (String) mf.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
-        }
-        return name;
-    }
-    
-    private String getBundleVersion(Manifest mf) {
-        String version = null;
-        if (mf != null) {
-            version = (String) mf.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
-        }
-        return version;
-    }
-    
-    private static class AppEntry {
-        String entryName;
-        Manifest manifest;
-        
-        public AppEntry(String entryName, Manifest manifest) {
-            this.entryName = entryName;
-            this.manifest = manifest;
-        }
-    }
-    
-    public void install(JarFile jarFile, ApplicationMetadata appMetadata, Environment environment) throws DeploymentException {       
-        /*
-         * XXX: This is totally not right but for now allows us to install 
-         * simple Aries applications into Geronimo. 
-         */
-        HashMap<String, AppEntry> mapping = new HashMap<String, AppEntry>();
-        Enumeration<JarEntry> entries = jarFile.entries();
-        while(entries.hasMoreElements()) {
-            JarEntry entry = entries.nextElement();
-            if (entry.getName().endsWith(".jar")) {
-                try {
-                    InputStream in = jarFile.getInputStream(entry);
-                    JarInputStream jarInput = new JarInputStream(in);
-                    String name = getSymbolicName(jarInput.getManifest());
-                    if (name != null) {
-                        mapping.put(name, new AppEntry(entry.getName(), jarInput.getManifest()));
-                    }
-                } catch (IOException e) {
-                    LOG.warn("Error getting jar entry {}", entry.getName(), e);
-                }
-            }
-        }
-
-        try {
-            for (Content content : appMetadata.getApplicationContents()) {
-                AppEntry appEntry = mapping.get(content.getContentName());
-                if (appEntry == null) {
-                    LOG.warn("Unknown bundle name in application context {}", content.getContentName());
-                    continue;
-                }
-                ZipEntry entry = jarFile.getEntry(appEntry.entryName);
-                if (entry == null) {
-                    // this should not happen
-                    throw new DeploymentException("Jar entry not found " + appEntry.entryName);
-                }
-
-                Artifact artifact = new Artifact("aries-app", 
-                                                 content.getContentName(), 
-                                                 getBundleVersion(appEntry.manifest),
-                                                 "jar");
-                InputStream in = jarFile.getInputStream(entry);
-                getRepository().copyToRepository(in, (int) entry.getSize(), artifact, null);
-                
-                environment.addDependency(new Dependency(artifact, ImportType.ALL));
-            }
-            
-        } catch (Exception e) {
-            throw new DeploymentException("Failed to install application", e);
-        }        
-    }
-
-
+           
     public Object getDeploymentPlan(File planFile, 
                                     JarFile jarFile, 
                                     ModuleIDBuilder idBuilder) 
         throws DeploymentException {
-        if (planFile == null && jarFile == null) {
+        if (jarFile == null) {
             return null;
         }
         
-        JarEntry appManifest = jarFile.getJarEntry("META-INF/APPLICATION.MF");
-        
-        if (appManifest == null) {
-            return null;
+        if (jarFile.getName().endsWith(".eba")) {
+            return new Object();
         }
         
-        ApplicationMetadataFactory service = getApplicationMetadataManager();
-        if (service == null) {
-            return null;
-        }
-        
-        ApplicationMetadata appMetadata = null;
-        try {
-            InputStream in = jarFile.getInputStream(appManifest);
-            appMetadata = service.parseApplicationMetadata(in);
-        } catch (IOException e) {
-            throw new DeploymentException("Failed to parse application metadata", e);
-        }
-        
-        return appMetadata;
+        return null;
     }
     
     public Artifact getConfigurationID(Object plan, 
                                        JarFile jarFile, 
                                        ModuleIDBuilder idBuilder)
         throws IOException, DeploymentException {
-        ApplicationMetadata appMetadata = (ApplicationMetadata) plan;
         
-        Artifact name = new Artifact("aries-app", appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), "jar");
+        Artifact name = new Artifact("eba", "application", "0.0.0", "jar");
         
         return name;
     }
@@ -236,47 +115,25 @@ public class AriesAppConfigBuilder imple
                                                 ArtifactResolver artifactResolver, 
                                                 ConfigurationStore targetConfigurationStore) 
         throws IOException, DeploymentException {
-        ApplicationMetadata appMetadata = (ApplicationMetadata) plan;
-        
-        Environment environment = new Environment();
-        environment.setConfigId(configId);
-        
-        install(jarFile, appMetadata, environment);
+                
+        AriesApplicationManager appManager = getAriesApplicationManager();
         
-        File outfile;
+        AriesApplication app = null;
         try {
-            outfile = targetConfigurationStore.createNewConfigurationDir(configId);
-        } catch (ConfigurationAlreadyExistsException e) {
-            throw new DeploymentException(e);
+            app = appManager.createApplication(FileSystem.getFSRoot(new File(jarFile.getName())));
+        } catch (Exception e) {
+            throw new DeploymentException("Error creating Aries Application", e);
         }
         
-        Naming naming = kernel.getNaming();
-        AbstractName moduleName = naming.createRootName(configId, configId.toString(), "AriesApplication");
         try {
-            DeploymentContext context = new DeploymentContext(outfile,                
-                            inPlaceDeployment && null != jarFile ? JarUtils.toFile(jarFile) : null,
-                            environment,
-                            moduleName,
-                            ConfigurationModuleType.SERVICE,
-                            naming,
-                            configurationManager,
-                            null, 
-                            bundleContext);
-            
-            
-            context.flush();
-            context.initializeConfiguration();
-            
-            return context;
-        } catch (DeploymentException e) {
-            e.printStackTrace();
-            throw e;
-        } catch (IOException e) {
-            e.printStackTrace();
-            throw e;
-        } finally {
-            try { jarFile.close(); } catch (IOException ignore) {}
+            app = appManager.resolve(app);
+        } catch (Exception e) {
+            throw new DeploymentException("Error resolving Aries Application", e);
         }
+                
+        DeploymentContext context = installer.startInstall(app, targetConfigurationStore);
+        
+        return context;
     }
-
+    
 }

Added: 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=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,269 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.
+ */
+package org.apache.geronimo.aries.builder;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.aries.application.ApplicationMetadataFactory;
+import org.apache.aries.application.DeploymentContent;
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.DeploymentMetadataFactory;
+import org.apache.aries.application.management.ApplicationContextManager;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationResolver;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.ManagementException;
+import org.apache.aries.application.management.ApplicationContext.ApplicationState;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.kernel.Kernel;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version $Rev:385232 $ $Date$
+ */
+@GBean
+public class ApplicationGBean implements GBeanLifecycle {
+        
+    private static final Logger LOG = LoggerFactory.getLogger(ApplicationGBean.class);
+    
+    private BundleContext bundleContext;
+    private ApplicationInstaller installer;
+    private GeronimoApplication application;
+    private ApplicationState applicationState;
+    private Set<Bundle> applicationBundles;
+    
+    public ApplicationGBean(@ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
+                            @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext,
+                            @ParamReference(name="Installer") ApplicationInstaller installer) 
+        throws Exception {
+        this.bundleContext = bundleContext;
+        this.installer = installer;
+                
+        // XXX: fix me
+        DeploymentMetadataFactory deploymentFactory = getDeploymentMetadataFactory();
+        ApplicationMetadataFactory applicationFactory = getApplicationMetadataFactory();
+        
+        this.application = new GeronimoApplication(bundleContext.getBundle(), applicationFactory, deploymentFactory);
+        
+        install();
+        
+        GeronimoApplicationContextManager applicationManager = 
+            (GeronimoApplicationContextManager) getApplicationContextManager();
+        applicationManager.registerApplicationContext(new GeronimoApplicationContext(this));
+    }
+    
+    protected Bundle getBundle() {
+        return bundleContext.getBundle();
+    }
+    
+    protected AriesApplication getAriesApplication() {
+        return application;
+    }
+    
+    protected Set<Bundle> getApplicationContent() {
+        return new HashSet<Bundle>(applicationBundles);
+    }
+
+    protected ApplicationState getApplicationState() {
+        return applicationState;
+    }
+        
+    private ApplicationContextManager getApplicationContextManager() {
+        ServiceReference ref = 
+            bundleContext.getServiceReference(ApplicationContextManager.class.getName());
+        if (ref != null) {
+            return (ApplicationContextManager) bundleContext.getService(ref);
+        } else {
+            return null;
+        }
+    }
+    
+    private DeploymentMetadataFactory getDeploymentMetadataFactory() {
+        ServiceReference ref = 
+            bundleContext.getServiceReference(DeploymentMetadataFactory.class.getName());
+        if (ref != null) {
+            return (DeploymentMetadataFactory) bundleContext.getService(ref);
+        } else {
+            return null;
+        }
+    }
+    
+    private ApplicationMetadataFactory getApplicationMetadataFactory() {
+        ServiceReference ref = 
+            bundleContext.getServiceReference(ApplicationMetadataFactory.class.getName());
+        if (ref != null) {
+            return (ApplicationMetadataFactory) bundleContext.getService(ref);
+        } else {
+            return null;
+        }
+    }
+    
+    private void install() throws Exception {
+
+        AriesApplicationResolver resolver = null;
+
+        ServiceReference ref = bundleContext.getServiceReference(AriesApplicationResolver.class.getName());
+
+        if (ref != null) {
+            resolver = (AriesApplicationResolver) bundleContext.getService(ref);
+        }
+
+        if (resolver == null) {
+            throw new ManagementException("AriesApplicationResolver service not found");
+        }
+
+        DeploymentMetadata meta = application.getDeploymentMetadata();
+        
+        List<DeploymentContent> bundlesToInstall = new ArrayList<DeploymentContent>();
+        bundlesToInstall.addAll(meta.getApplicationDeploymentContents());
+        bundlesToInstall.addAll(meta.getApplicationProvisionBundles());
+        
+        applicationBundles = new HashSet<Bundle>();
+        try {
+            for (DeploymentContent content : bundlesToInstall) {
+                String bundleSymbolicName = content.getContentName();
+                Version bundleVersion = content.getExactVersion();
+
+                BundleInfo bundleInfo = null;
+
+                for (BundleInfo info : application.getBundleInfo()) {
+                    if (info.getSymbolicName().equals(bundleSymbolicName)
+                        && info.getVersion().equals(bundleVersion)) {
+                        bundleInfo = info;
+                        break;
+                    }
+                }
+
+                if (bundleInfo == null) {
+                    // call out to the bundle repository.
+                    bundleInfo = resolver.getBundleInfo(bundleSymbolicName, bundleVersion);
+                }
+
+                if (bundleInfo == null) {
+                    throw new ManagementException("Cound not find bundles: " + bundleSymbolicName + "_" + bundleVersion);
+                }
+
+                Bundle bundle = bundleContext.installBundle(bundleInfo.getLocation());
+
+                applicationBundles.add(bundle);
+            }
+        } catch (BundleException be) {
+            for (Bundle bundle : applicationBundles) {
+                bundle.uninstall();
+            }
+
+            applicationBundles.clear();
+
+            throw be;
+        } finally {
+            if (resolver != null) {
+                bundleContext.ungetService(ref);
+            }
+        }
+
+        applicationState = ApplicationState.INSTALLED;
+    }
+    
+    public void doStart() throws Exception {
+        LOG.debug("Starting {}", application.getApplicationMetadata().getApplicationScope());
+        
+        applicationState = ApplicationState.STARTING;
+
+        List<Bundle> bundlesWeStarted = new ArrayList<Bundle>();
+        try {
+            for (Bundle b : applicationBundles) {
+                if (b.getState() != Bundle.ACTIVE) {
+                    b.start(Bundle.START_ACTIVATION_POLICY);
+                    bundlesWeStarted.add(b);
+                }
+            }
+        } catch (BundleException be) {
+            for (Bundle b : bundlesWeStarted) {
+                try {
+                    b.stop();
+                } catch (BundleException be2) {
+                    // we are doing tidyup here, so we don't want to replace the
+                    // bundle exception
+                    // that occurred during start with one from stop. We also
+                    // want to try to stop
+                    // all the bundles we started even if some bundles wouldn't
+                    // stop.
+                }
+            }
+
+            applicationState = ApplicationState.INSTALLED;
+            throw be;
+        }
+        applicationState = ApplicationState.ACTIVE;
+    }    
+
+    public void doStop() {
+        LOG.debug("Stopping {}", application.getApplicationMetadata().getApplicationScope());
+        
+        for (Bundle bundle : applicationBundles) {
+            try {
+                bundle.stop();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        applicationState = ApplicationState.RESOLVED;
+    }
+
+    public void doFail() {
+        doStop();
+    }
+   
+    protected void uninstall() {
+        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 {
+            bundleContext.getBundle().uninstall();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }        
+        
+        applicationState = ApplicationState.UNINSTALLED;
+    }
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,209 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.
+ */
+package org.apache.geronimo.aries.builder;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
+import org.apache.geronimo.kernel.config.ConfigurationData;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
+import org.apache.geronimo.kernel.config.ConfigurationUtil;
+import org.apache.geronimo.kernel.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;
+import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version $Rev:385232 $ $Date$
+ */
+@GBean
+public class ApplicationInstaller implements GBeanLifecycle {
+    
+    private static final Logger LOG = LoggerFactory.getLogger(ApplicationInstaller.class);
+    
+    private Kernel kernel;
+    private BundleContext bundleContext;   
+    private AbstractName abstractName;
+    private ServiceRegistration registration;
+    private ConfigurationManager configurationManager;
+    private Collection<ConfigurationStore> configurationStores;
+
+    public ApplicationInstaller(@ParamReference(name="Store", namingType = "ConfigurationStore") Collection<ConfigurationStore> configurationStores,
+                                @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
+                                @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext,
+                                @ParamSpecial(type = SpecialAttributeType.abstractName) AbstractName abstractName)  
+        throws GBeanNotFoundException {
+        this.kernel = kernel;
+        this.bundleContext = bundleContext;
+        this.abstractName = abstractName;
+        this.configurationStores = configurationStores;
+        this.configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+    }
+    
+    public void doStart() throws Exception {
+        registration = bundleContext.registerService(ApplicationInstaller.class.getName(), this, null);
+    }
+
+    public void doStop() {
+        if (registration != null) {
+            registration.unregister();
+        }
+    }
+
+    public void doFail() {
+        doStop();
+    }
+                
+    public DeploymentContext startInstall(AriesApplication app, ConfigurationStore targetConfigurationStore) 
+        throws ConfigurationAlreadyExistsException, DeploymentException {
+                                
+        Artifact configId = getConfigId(app);
+        
+        File configDir = targetConfigurationStore.createNewConfigurationDir(configId);
+        
+        Environment environment = new Environment();
+        environment.setConfigId(configId);
+        
+        Naming naming = kernel.getNaming();
+        AbstractName moduleName = naming.createRootName(configId, configId.toString(), "AriesApplication");
+        try {
+            DeploymentContext context = new DeploymentContext(configDir,                
+                            null,
+                            environment,
+                            moduleName,
+                            ConfigurationModuleType.SERVICE,
+                            naming,
+                            configurationManager,
+                            null, 
+                            bundleContext);
+                                    
+            context.flush();
+            context.initializeConfiguration();
+                        
+            app.store(configDir);
+            
+            AbstractName name = naming.createChildName(moduleName, "AriesApplication", "GBean");
+            GBeanData data = new GBeanData(name, ApplicationGBean.class);
+            data.setReferencePattern("Installer", abstractName);
+            
+            context.addGBean(data);
+            
+            return context;
+        } catch (DeploymentException e) {
+            e.printStackTrace();
+            throw e;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new DeploymentException("", e);
+        }
+    }
+
+    public ConfigurationData finishInstall(DeploymentContext context, ConfigurationStore targetConfigurationStore)  
+        throws ConfigurationAlreadyExistsException, DeploymentException {
+        try {
+            ConfigurationData configurationData = context.getConfigurationData();
+            targetConfigurationStore.install(configurationData);
+            return configurationData;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new DeploymentException("", e);
+        } finally {
+            try { context.close(); } catch (IOException e) {}
+        }
+    }
+    
+    public void install(AriesApplication app) throws ConfigurationAlreadyExistsException, DeploymentException {
+        ConfigurationStore store = configurationStores.iterator().next();
+        if (store == null) {
+            throw new DeploymentException("No ConfigurationStore");
+        }
+        DeploymentContext context = startInstall(app, store);
+        ConfigurationData configurationData = finishInstall(context, store);
+        
+        try {
+            configurationManager.loadConfiguration(configurationData.getId());
+            configurationManager.startConfiguration(configurationData.getId());
+        } catch (Exception e) {
+            e.printStackTrace();
+            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 Artifact getConfigId(AriesApplication app) {
+        Artifact configId = 
+            new Artifact("aries-app", 
+                         app.getApplicationMetadata().getApplicationSymbolicName(), 
+                         getVersion(app.getApplicationMetadata().getApplicationVersion()), 
+                         "jar");
+        return configId;
+    }
+    
+    private String getVersion(Version version) {
+        String str = version.getMajor() + "." + version.getMinor() + "." + version.getMinor();
+        if (version.getQualifier() != null) {
+            str += "-" + version.getQualifier();
+        }
+        return str;
+    }
+    
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplication.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplication.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplication.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplication.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,92 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.
+ */
+package org.apache.geronimo.aries.builder;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.ApplicationMetadataFactory;
+import org.apache.aries.application.DeploymentMetadata;
+import org.apache.aries.application.DeploymentMetadataFactory;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.utils.AppConstants;
+import org.apache.aries.application.utils.management.SimpleBundleInfo;
+import org.apache.aries.application.utils.manifest.BundleManifest;
+import org.osgi.framework.Bundle;
+
+/**
+ * @version $Rev:385232 $ $Date$
+ */
+public class GeronimoApplication implements AriesApplication {
+    
+    private DeploymentMetadata deploymentMetadata;
+    private Set<BundleInfo> bundleInfo;
+    
+    public GeronimoApplication(Bundle bundle, 
+                               ApplicationMetadataFactory applicationFactory, 
+                               DeploymentMetadataFactory deploymentFactory) 
+        throws IOException {
+        URL deploymentMF = bundle.getEntry(AppConstants.DEPLOYMENT_MF);
+        deploymentMetadata = deploymentFactory.createDeploymentMetadata(deploymentMF.openStream());    
+        
+        bundleInfo = new HashSet<BundleInfo>();
+        Enumeration<URL> e = bundle.findEntries("/", "*", true);
+        while (e.hasMoreElements()) {
+            URL url = e.nextElement();
+            if (url.getPath().endsWith("/")) {
+                continue;
+            }
+            BundleManifest bm = BundleManifest.fromBundle(url.openStream());
+            if (bm != null && bm.isValid()) {
+                bundleInfo.add(new SimpleBundleInfo(applicationFactory, bm, url.toExternalForm()));
+            }
+        }
+    }
+
+    public ApplicationMetadata getApplicationMetadata() {
+        return deploymentMetadata.getApplicationMetadata();
+    }
+
+    public Set<BundleInfo> getBundleInfo() {
+        return bundleInfo;
+    }
+
+    public DeploymentMetadata getDeploymentMetadata() {
+        return deploymentMetadata;
+    }
+
+    public boolean isResolved() {
+        return true;
+    }
+
+    public void store(File arg0) throws FileNotFoundException, IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    public void store(OutputStream arg0) throws FileNotFoundException, IOException {
+        throw new UnsupportedOperationException();        
+    }
+   
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplication.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.aries.builder;
+
+import java.util.Set;
+
+import org.apache.aries.application.management.ApplicationContext;
+import org.apache.aries.application.management.AriesApplication;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+public class GeronimoApplicationContext implements ApplicationContext {
+
+    private ApplicationGBean applicationGBean;
+    
+    public GeronimoApplicationContext(ApplicationGBean applicationGBean) {
+        this.applicationGBean = applicationGBean;
+    }
+    
+    public AriesApplication getApplication() {
+        return applicationGBean.getAriesApplication();
+    }
+
+    public Set<Bundle> getApplicationContent() {
+        return applicationGBean.getApplicationContent();
+    }
+
+    public ApplicationState getApplicationState() {
+        return applicationGBean.getApplicationState();
+    }
+
+    public void start() throws BundleException {
+        applicationGBean.getBundle().start();
+    }
+
+    public void stop() throws BundleException {
+        applicationGBean.getBundle().stop();
+    }
+  
+    protected void uninstall() {
+        applicationGBean.uninstall();
+    }
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContextManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContextManager.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContextManager.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContextManager.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.aries.builder;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.management.ApplicationContext;
+import org.apache.aries.application.management.ApplicationContextManager;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.ManagementException;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+
+public class GeronimoApplicationContextManager implements ApplicationContextManager {
+
+    private ConcurrentMap<String, GeronimoApplicationContext> contextMap;
+    private BundleContext bundleContext;
+    private ServiceReference installerReference;
+    private ApplicationInstaller installer;
+
+    public GeronimoApplicationContextManager() {
+        this.contextMap = new ConcurrentHashMap<String, GeronimoApplicationContext>();
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+        
+    protected void registerApplicationContext(GeronimoApplicationContext context) { 
+        contextMap.put(getApplicationKey(context.getApplication()), context);        
+    }
+    
+    private String getApplicationKey(AriesApplication app) {
+        ApplicationMetadata metadata = app.getApplicationMetadata();
+        return metadata.getApplicationScope();
+    }
+
+    public ApplicationContext getApplicationContext(AriesApplication app) throws BundleException, ManagementException {
+        String key = getApplicationKey(app);
+        GeronimoApplicationContext applicationContext = contextMap.get(key);
+        if (applicationContext == null) {
+            try {
+                getApplicationInstaller().install(app);
+            } catch (Exception e) {
+                throw new BundleException("Application installation failed", e);
+            }
+            // if application was successfully installed & started it
+            // should have registered its ApplicationContext by now
+            applicationContext = contextMap.get(key);
+            if (applicationContext == null) {
+                throw new ManagementException("No ApplicationContext");
+            }
+        }
+
+        return applicationContext;
+    }
+
+    public Set<ApplicationContext> getApplicationContexts() {
+        Set<ApplicationContext> result = new HashSet<ApplicationContext>();
+        result.addAll(contextMap.values());
+        return result;
+    }
+
+    public void remove(ApplicationContext app) {     
+        String key = getApplicationKey(app.getApplication());
+        GeronimoApplicationContext applicationContext = contextMap.remove(key);
+        if (applicationContext != null) {
+            applicationContext.uninstall();
+        }
+    }
+
+    private ApplicationInstaller getApplicationInstaller() {
+        if (installer == null) {
+            installerReference = 
+                bundleContext.getServiceReference(ApplicationInstaller.class.getName());
+            installer = (ApplicationInstaller) bundleContext.getService(installerReference);
+        } 
+        return installer;
+    }
+    
+    public void init() {
+    }
+    
+    public void destroy() {
+        if (installerReference != null) {
+            bundleContext.ungetService(installerReference);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContextManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContextManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContextManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoLocalPlatform.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoLocalPlatform.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoLocalPlatform.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoLocalPlatform.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.geronimo.aries.builder;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.aries.application.management.LocalPlatform;
+
+public class GeronimoLocalPlatform implements LocalPlatform {
+
+    public File getTemporaryDirectory() throws IOException {
+        File f = File.createTempFile("ebaTmp", null);
+        f.delete();
+        f.mkdir();
+        return f;
+    }
+
+    public File getTemporaryFile() throws IOException {
+        return File.createTempFile("ebaTmp", null);
+    }
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoLocalPlatform.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoLocalPlatform.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoLocalPlatform.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/NoOpResolver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/NoOpResolver.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/NoOpResolver.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/NoOpResolver.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.geronimo.aries.builder;
+
+import java.util.Set;
+
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationResolver;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.ResolveConstraint;
+import org.osgi.framework.Version;
+
+/**
+ * AriesApplicationManager requires that there be at least one
+ * AriesApplicationResolver service present. This class provides a null
+ * implementation: it simply returns the bundles that it was provided with -
+ * enough to permit the testing of Aries applications that have no external
+ * dependencies.
+ */
+public class NoOpResolver implements AriesApplicationResolver {
+
+    public Set<BundleInfo> resolve(AriesApplication app, ResolveConstraint... constraints) {
+        return app.getBundleInfo();
+    }
+
+    public BundleInfo getBundleInfo(String bundleSymbolicName, Version bundleVersion) {
+        return null;
+    }
+}
\ No newline at end of file

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/NoOpResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/NoOpResolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/NoOpResolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/app-context-management.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/app-context-management.xml?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/app-context-management.xml (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/app-context-management.xml Fri Mar 12 06:25:46 2010
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+  
+  <bean id="app-context-manager" class="org.apache.geronimo.aries.builder.GeronimoApplicationContextManager" scope="singleton" activation="lazy" init-method="init" destroy-method="destroy">
+    <property name="bundleContext" ref="blueprintBundleContext"/>
+  </bean>
+  <service interface="org.apache.aries.application.management.ApplicationContextManager" ref="app-context-manager" />
+  
+  <bean id="default-local-platform" class="org.apache.geronimo.aries.builder.GeronimoLocalPlatform"/>
+  <service interface="org.apache.aries.application.management.LocalPlatform" 
+           ref="default-local-platform" />
+  
+
+  <bean id="no-op-resolver" class="org.apache.geronimo.aries.builder.NoOpResolver"/>
+  <service interface="org.apache.aries.application.management.AriesApplicationResolver" 
+            ref="no-op-resolver"
+            ranking="-1"/>
+
+  
+
+</blueprint>

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/app-context-management.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/app-context-management.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/resources/OSGI-INF/blueprint/app-context-management.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-shell/pom.xml?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-shell/pom.xml (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-shell/pom.xml Fri Mar 12 06:25:46 2010
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.geronimo.plugins</groupId>
+        <artifactId>aries</artifactId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.geronimo.modules</groupId>
+    <artifactId>geronimo-aries-shell</artifactId>
+    <packaging>bundle</packaging>
+    <name>Geronimo Plugins, Aries :: Shell</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix.karaf.shell</groupId>
+            <artifactId>org.apache.felix.karaf.shell.console</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ApplicationCommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ApplicationCommandSupport.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ApplicationCommandSupport.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ApplicationCommandSupport.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.geronimo.aries.shell;
+
+import java.util.Set;
+
+import org.apache.aries.application.management.ApplicationContext;
+import org.apache.aries.application.management.ApplicationContextManager;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.felix.karaf.shell.console.OsgiCommandSupport;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class ApplicationCommandSupport extends OsgiCommandSupport {
+
+    protected ApplicationContextManager getApplicationContextManager() {
+        ServiceReference ref = 
+            bundleContext.getServiceReference(ApplicationContextManager.class.getName());
+        return getService(ApplicationContextManager.class, ref);
+    }
+    
+    protected AriesApplicationManager getAriesApplicationManager() {
+        ServiceReference ref = 
+            bundleContext.getServiceReference(AriesApplicationManager.class.getName());
+        return getService(AriesApplicationManager.class, ref);
+    }
+    
+    protected ApplicationContext findApplicationContext(ApplicationContextManager manager, String appName) {
+        Set<ApplicationContext> contexts = manager.getApplicationContexts();
+        for (ApplicationContext context : contexts) {
+            String name = context.getApplication().getApplicationMetadata().getApplicationScope();
+            if (appName.equals(name)) {
+                return context;
+            }
+        }
+        return null;
+    }
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ApplicationCommandSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ApplicationCommandSupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ApplicationCommandSupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/InstallApplication.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/InstallApplication.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/InstallApplication.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/InstallApplication.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.geronimo.aries.shell;
+
+import java.io.File;
+
+import org.apache.aries.application.management.ApplicationContext;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationManager;
+import org.apache.aries.application.utils.filesystem.FileSystem;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Command(scope = "eba", name = "install", description = "Install Application")
+public class InstallApplication extends ApplicationCommandSupport {
+
+    @Argument(required = true, description = "Application location")
+    String applicationPath;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        AriesApplicationManager manager = getAriesApplicationManager();
+        AriesApplication application = manager.createApplication(FileSystem.getFSRoot(new File(applicationPath)));        
+        ApplicationContext context = manager.install(application);
+        System.out.println("Installed EBA: " + context.getApplication().getApplicationMetadata().getApplicationScope());
+        return null;
+    }
+ 
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/InstallApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/InstallApplication.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/InstallApplication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ListApplication.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ListApplication.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ListApplication.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ListApplication.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.geronimo.aries.shell;
+
+import java.util.Set;
+
+import org.apache.aries.application.management.ApplicationContext;
+import org.apache.aries.application.management.ApplicationContextManager;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Command(scope = "eba", name = "list", description = "List Applications")
+public class ListApplication extends ApplicationCommandSupport {
+
+    @Argument(required = false, description = "Application name")
+    String applicationName;
+    
+    @Override
+    protected Object doExecute() throws Exception {
+        ApplicationContextManager contextManager = getApplicationContextManager();
+        if (applicationName == null) {
+            System.out.println("EBA Applications:");
+            Set<ApplicationContext> contexts = contextManager.getApplicationContexts();
+            for (ApplicationContext context : contexts) {
+                System.out.println(context.getApplication().getApplicationMetadata().getApplicationScope() + "\t" + context.getApplicationState());
+            }
+        } else {
+            ApplicationContext context = findApplicationContext(contextManager, applicationName);
+            if (context == null) {
+                System.out.println("EBA " + applicationName + " not found");
+            } else {
+                System.out.println("EBA: " + applicationName);
+                System.out.println("Bundles : " + context.getApplicationContent());
+                System.out.println("State   : " + context.getApplicationState());
+            }
+        }
+        return null;
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ListApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ListApplication.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/ListApplication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StartApplication.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StartApplication.java?rev=922153&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StartApplication.java (added)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StartApplication.java Fri Mar 12 06:25:46 2010
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.geronimo.aries.shell;
+
+import org.apache.aries.application.management.ApplicationContext;
+import org.apache.aries.application.management.ApplicationContextManager;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Command(scope = "eba", name = "start", description = "Start Application")
+public class StartApplication extends ApplicationCommandSupport {
+
+    @Argument(required = true, description = "Application name")
+    String applicationName;
+    
+    @Override
+    protected Object doExecute() throws Exception {
+        ApplicationContextManager contextManager = getApplicationContextManager();
+        ApplicationContext context = findApplicationContext(contextManager, applicationName);
+        if (context == null) {
+            System.out.println("EBA " + applicationName + " not found");
+        } else {
+            context.start();
+        }
+        return null;
+    }
+
+
+}

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StartApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StartApplication.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-shell/src/main/java/org/apache/geronimo/aries/shell/StartApplication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message