geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r887814 - in /geronimo/server/trunk/plugins/aries: aries-deployer/ aries-deployer/src/main/history/ aries-deployer/src/main/plan/ geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/
Date Mon, 07 Dec 2009 01:06:07 GMT
Author: gawor
Date: Mon Dec  7 01:06:06 2009
New Revision: 887814

URL: http://svn.apache.org/viewvc?rev=887814&view=rev
Log:
GERONIMO-4971: install application bundles into the repository

Removed:
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModule.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/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java

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=887814&r1=887813&r2=887814&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml (original)
+++ geronimo/server/trunk/plugins/aries/aries-deployer/pom.xml Mon Dec  7 01:06:06 2009
@@ -36,8 +36,8 @@
     <dependencies>
         <!-- parent -->
         <dependency>
-            <groupId>org.apache.geronimo.configs</groupId>
-            <artifactId>j2ee-deployer</artifactId>
+            <groupId>org.apache.geronimo.framework</groupId>
+            <artifactId>j2ee-system</artifactId>
             <version>${version}</version>
             <type>car</type>
         </dependency>

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=887814&r1=887813&r2=887814&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 Mon
Dec  7 01:06:06 2009
@@ -12,8 +12,38 @@
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>j2ee-deployer</artifactId>
+        <groupId>org.apache.geronimo.components</groupId>
+        <artifactId>geronimo-jaspi</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.framework</groupId>
+        <artifactId>geronimo-deploy-config</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.framework</groupId>
+        <artifactId>geronimo-deployment</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.framework</groupId>
+        <artifactId>geronimo-management</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.framework</groupId>
+        <artifactId>geronimo-security</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.framework</groupId>
+        <artifactId>geronimo-service-builder</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.framework</groupId>
+        <artifactId>j2ee-system</artifactId>
         <type>car</type>
     </dependency>
     <dependency>
@@ -21,4 +51,109 @@
         <artifactId>geronimo-aries-builder</artifactId>
         <type>jar</type>
     </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.modules</groupId>
+        <artifactId>geronimo-j2ee</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.modules</groupId>
+        <artifactId>geronimo-j2ee-builder</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.modules</groupId>
+        <artifactId>geronimo-j2ee-schema</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.modules</groupId>
+        <artifactId>geronimo-security-builder</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.schema</groupId>
+        <artifactId>geronimo-schema-j2ee_1.4</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.schema</groupId>
+        <artifactId>geronimo-schema-jee_5</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-activation_1.1_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-annotation_1.0_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-ejb_3.1_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-jacc_1.1_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-jaspic_1.0_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-javaee-deployment_1.1MR3_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-jaxws_2.1_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-jpa_2.0_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-jta_1.1_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.geronimo.specs</groupId>
+        <artifactId>geronimo-servlet_3.0_spec</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.xmlbeans</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.bundles</groupId>
+        <artifactId>org.apache.servicemix.bundles.xmlresolver</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.servicemix.specs</groupId>
+        <artifactId>org.apache.servicemix.specs.saaj-api-1.3</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
+        <groupId>org.apache.xbean</groupId>
+        <artifactId>xbean-finder</artifactId>
+        <type>jar</type>
+    </dependency>
 </plugin-artifact>

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=887814&r1=887813&r2=887814&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 Mon Dec  7 01:06:06
2009
@@ -19,6 +19,9 @@
 <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>
+        </reference>
     </gbean>
 
 </module>

Modified: 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/AriesAppConfigBuilder.java?rev=887814&r1=887813&r2=887814&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/AriesAppConfigBuilder.java
Mon Dec  7 01:06:06 2009
@@ -19,11 +19,9 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.JarInputStream;
@@ -52,12 +50,12 @@
 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.osgi.BundleUtils;
 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.Repository;
-import org.osgi.framework.Bundle;
+import org.apache.geronimo.kernel.repository.ImportType;
+import org.apache.geronimo.kernel.repository.WritableListableRepository;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -74,14 +72,14 @@
     
     private Kernel kernel;
     private BundleContext bundleContext;
-    private Collection<Repository> repositories;
+    private WritableListableRepository repository;
     private ConfigurationManager configurationManager;
 
-    public AriesAppConfigBuilder(@ParamReference(name="Repository", namingType = "Repository")Collection<Repository>
repositories,
+    public AriesAppConfigBuilder(@ParamReference(name="Repository", namingType = "Repository")WritableListableRepository
repository,
                                  @ParamSpecial(type = SpecialAttributeType.kernel) Kernel
kernel,
                                  @ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext) 
         throws GBeanNotFoundException {
-        this.repositories = repositories;
+        this.repository = repository;
         this.kernel = kernel;
         this.bundleContext = bundleContext;
         this.configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
@@ -96,22 +94,11 @@
     public void doFail() {
         doStop();
     }
-   
-   
-
-        /*
-        LOG.debug("Found Aries Application: {}", appMetadata.getApplicationName());
-        
-        Environment env = new Environment();
-        env.setConfigId(new Artifact("aries", appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(),
"jar"));
-                
-        AbstractName moduleName = naming.createRootName(env.getConfigId(), NameFactory.NULL,
NameFactory.J2EE_APPLICATION);
-        
-        AriesAppModule module = new AriesAppModule(moduleName, env, moduleFile, targetPath,
appMetadata);
-          */
-        
-       
 
+    private WritableListableRepository getRepository() {
+        return repository;   
+    }
+    
     private ApplicationMetadataManager getApplicationMetadataManager() {
         ServiceReference ref = 
             bundleContext.getServiceReference(ApplicationMetadataManager.class.getName());
@@ -130,12 +117,30 @@
         return name;
     }
     
-    public void installModule(JarFile jarFile, ApplicationMetadata appMetadata) throws DeploymentException
{
+    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, String> mapping = new HashMap<String, String>();
+        HashMap<String, AppEntry> mapping = new HashMap<String, AppEntry>();
         Enumeration<JarEntry> entries = jarFile.entries();
         while(entries.hasMoreElements()) {
             JarEntry entry = entries.nextElement();
@@ -145,7 +150,7 @@
                     JarInputStream jarInput = new JarInputStream(in);
                     String name = getSymbolicName(jarInput.getManifest());
                     if (name != null) {
-                        mapping.put(name, entry.getName());
+                        mapping.put(name, new AppEntry(entry.getName(), jarInput.getManifest()));
                     }
                 } catch (IOException e) {
                     LOG.warn("Error getting jar entry {}", entry.getName(), e);
@@ -153,30 +158,29 @@
             }
         }
 
-        List<Bundle> installedBundles = new ArrayList<Bundle>();        
         try {
             for (Content content : appMetadata.getApplicationContents()) {
-                String entryName = mapping.get(content.getContentName());
-                if (entryName == null) {
+                AppEntry appEntry = mapping.get(content.getContentName());
+                if (appEntry == null) {
                     LOG.warn("Unknown bundle name in application context {}", content.getContentName());
                     continue;
                 }
-                ZipEntry entry = jarFile.getEntry(entryName);
+                ZipEntry entry = jarFile.getEntry(appEntry.entryName);
                 if (entry == null) {
                     // this should not happen
-                    throw new DeploymentException("Jar entry not found " + entryName);
+                    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);
-                Bundle appBundle = bundleContext.installBundle(content.getContentName(),
in);
-                installedBundles.add(appBundle);
+                getRepository().copyToRepository(in, (int) entry.getSize(), artifact, null);
+                
+                environment.addDependency(new Dependency(artifact, ImportType.ALL));
             }
             
-            for (Bundle installedBundle : installedBundles) {
-                if (BundleUtils.canStart(installedBundle)) {
-                    installedBundle.start();
-                }
-            }
         } catch (Exception e) {
             throw new DeploymentException("Failed to install application", e);
         }        
@@ -219,7 +223,7 @@
         throws IOException, DeploymentException {
         ApplicationMetadata appMetadata = (ApplicationMetadata) plan;
         
-        Artifact name = new Artifact("aries", appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(),
"eba");
+        Artifact name = new Artifact("aries-app", appMetadata.getApplicationSymbolicName(),
appMetadata.getApplicationVersion().toString(), "eba");
         
         return name;
     }
@@ -233,7 +237,11 @@
                                                 ConfigurationStore targetConfigurationStore)

         throws IOException, DeploymentException {
         ApplicationMetadata appMetadata = (ApplicationMetadata) plan;
-        installModule(jarFile, appMetadata);
+        
+        Environment environment = new Environment();
+        environment.setConfigId(configId);
+        
+        install(jarFile, appMetadata, environment);
         
         File outfile;
         try {
@@ -242,9 +250,6 @@
             throw new DeploymentException(e);
         }
         
-        Environment environment = new Environment();
-        environment.setConfigId(configId);
-        
         Naming naming = kernel.getNaming();
         AbstractName moduleName = naming.createRootName(configId, configId.toString(), "AriesApplication");
         try {
@@ -255,7 +260,7 @@
                             ConfigurationModuleType.SERVICE,
                             naming,
                             configurationManager,
-                            repositories, 
+                            null, 
                             bundleContext);
             
             
@@ -269,6 +274,8 @@
         } catch (IOException e) {
             e.printStackTrace();
             throw e;
+        } finally {
+            try { jarFile.close(); } catch (IOException ignore) {}
         }
     }
 



Mime
View raw message