geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1065200 - in /geronimo/server/trunk/plugins/aries: aries-deployer/src/main/plan/ geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/
Date Sun, 30 Jan 2011 06:54:07 GMT
Author: xuhaihong
Date: Sun Jan 30 06:54:07 2011
New Revision: 1065200

URL: http://svn.apache.org/viewvc?rev=1065200&view=rev
Log:
GERONIMO-5797 Add defaultEnvironment support for eba config builder

Modified:
    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/ApplicationConfigBuilder.java
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java

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=1065200&r1=1065199&r2=1065200&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 Sun Jan 30 06:54:07
2011
@@ -27,6 +27,18 @@
     <gbean name="AppInstaller" class="org.apache.geronimo.aries.builder.ApplicationInstaller">
         <reference name="Store">
         </reference>
+        <xml-attribute name="defaultEnvironment">
+            <environment xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.geronimo.modules</groupId>
+                        <artifactId>geronimo-aries-builder</artifactId>
+                        <version>${version}</version>
+                        <type>jar</type>
+                    </dependency>
+                </dependencies>
+            </environment>
+        </xml-attribute>
     </gbean>
 
 </module>

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java?rev=1065200&r1=1065199&r2=1065200&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationConfigBuilder.java
Sun Jan 30 06:54:07 2011
@@ -57,20 +57,20 @@ import org.slf4j.LoggerFactory;
  */
 @GBean(j2eeType = "ConfigBuilder")
 public class ApplicationConfigBuilder implements ConfigurationBuilder, GBeanLifecycle {
-    
+
     private static final Logger LOG = LoggerFactory.getLogger(ApplicationConfigBuilder.class);
-    
+
     private BundleContext bundleContext;
     private ApplicationInstaller installer;
 
     public ApplicationConfigBuilder(@ParamReference(name="Installer") ApplicationInstaller
installer,
                                     @ParamSpecial(type = SpecialAttributeType.kernel) Kernel
kernel,
-                                    @ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext) 
+                                    @ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext)
         throws GBeanNotFoundException {
         this.installer = installer;
         this.bundleContext = bundleContext;
     }
-    
+
     public void doStart() throws Exception {
     }
 
@@ -80,9 +80,9 @@ public class ApplicationConfigBuilder im
     public void doFail() {
         doStop();
     }
-        
+
     private AriesApplicationManager getAriesApplicationManager() {
-        ServiceReference ref = 
+        ServiceReference ref =
             bundleContext.getServiceReference(AriesApplicationManager.class.getName());
         if (ref != null) {
             return (AriesApplicationManager) bundleContext.getService(ref);
@@ -90,9 +90,9 @@ public class ApplicationConfigBuilder im
             return null;
         }
     }
-           
+
     private ApplicationMetadataFactory getApplicationMetadataFactory() {
-        ServiceReference ref = 
+        ServiceReference ref =
             bundleContext.getServiceReference(ApplicationMetadataFactory.class.getName());
         if (ref != null) {
             return (ApplicationMetadataFactory) bundleContext.getService(ref);
@@ -100,28 +100,28 @@ public class ApplicationConfigBuilder im
             return null;
         }
     }
-    
-    public Object getDeploymentPlan(File planFile, 
-                                    JarFile jarFile, 
-                                    ModuleIDBuilder idBuilder) 
+
+    public Object getDeploymentPlan(File planFile,
+                                    JarFile jarFile,
+                                    ModuleIDBuilder idBuilder)
         throws DeploymentException {
         if (jarFile == null) {
             return null;
         }
-        
+
         if (jarFile.getName().endsWith(".eba")) {
             return new Object();
         }
-        
+
         return null;
     }
-    
-    public Artifact getConfigurationID(Object plan, 
-                                       JarFile jarFile, 
+
+    public Artifact getConfigurationID(Object plan,
+                                       JarFile jarFile,
                                        ModuleIDBuilder idBuilder)
-        throws IOException, DeploymentException {        
-        ApplicationMetadataFactory factory = getApplicationMetadataFactory();        
-        IDirectory ebaFile = FileSystem.getFSRoot(new File(jarFile.getName()));        
+        throws IOException, DeploymentException {
+        ApplicationMetadataFactory factory = getApplicationMetadataFactory();
+        IDirectory ebaFile = FileSystem.getFSRoot(new File(jarFile.getName()));
         IFile applicationManifestFile = ebaFile.getFile(AppConstants.APPLICATION_MF);
         Manifest applicationManifest;
         if (applicationManifestFile != null) {
@@ -134,38 +134,38 @@ public class ApplicationConfigBuilder im
         } else {
             applicationManifest = new Manifest();
         }
-        ManifestDefaultsInjector.updateManifest(applicationManifest, ebaFile.getName(), ebaFile);

+        ManifestDefaultsInjector.updateManifest(applicationManifest, ebaFile.getName(), ebaFile);
         ApplicationMetadata metadata = factory.createApplicationMetadata(applicationManifest);
-        return ApplicationInstaller.getConfigId(metadata);        
+        return ApplicationInstaller.getConfigId(metadata);
     }
-    
-    public DeploymentContext buildConfiguration(boolean inPlaceDeployment, 
-                                                Artifact configId, 
+
+    public DeploymentContext buildConfiguration(boolean inPlaceDeployment,
+                                                Artifact configId,
                                                 Object plan,
-                                                JarFile jarFile, 
-                                                Collection<ConfigurationStore> configurationStores,

-                                                ArtifactResolver artifactResolver, 
-                                                ConfigurationStore targetConfigurationStore)

+                                                JarFile jarFile,
+                                                Collection<ConfigurationStore> configurationStores,
+                                                ArtifactResolver artifactResolver,
+                                                ConfigurationStore targetConfigurationStore)
         throws IOException, DeploymentException {
-                
+
         AriesApplicationManager appManager = getAriesApplicationManager();
-        
+
         AriesApplication app = null;
         try {
             app = appManager.createApplication(FileSystem.getFSRoot(new File(jarFile.getName())));
         } catch (Exception e) {
             throw new DeploymentException("Error creating Aries Application", e);
         }
-        
+
         try {
             app = appManager.resolve(app);
         } catch (Exception e) {
             throw new DeploymentException("Error resolving Aries Application", e);
         }
-                
+
         DeploymentContext context = installer.startInstall(app, targetConfigurationStore);
-        
+
         return context;
     }
-    
+
 }

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java?rev=1065200&r1=1065199&r2=1065200&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
Sun Jan 30 06:54:07 2011
@@ -24,10 +24,12 @@ import org.apache.aries.application.Appl
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 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.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
@@ -54,28 +56,32 @@ import org.slf4j.LoggerFactory;
  */
 @GBean
 public class ApplicationInstaller implements GBeanLifecycle {
-    
+
     private static final Logger LOG = LoggerFactory.getLogger(ApplicationInstaller.class);
-    
+
     private Kernel kernel;
-    private BundleContext bundleContext;   
+    private BundleContext bundleContext;
     private AbstractName abstractName;
     private ServiceRegistration registration;
     private ConfigurationManager configurationManager;
     private Collection<ConfigurationStore> configurationStores;
+    private Environment defaultEnvironment;
 
-    public ApplicationInstaller(@ParamReference(name="Store", namingType = "ConfigurationStore")
Collection<ConfigurationStore> configurationStores,
+    public ApplicationInstaller(
+                                @ParamReference(name="Store", namingType = "ConfigurationStore")
Collection<ConfigurationStore> configurationStores,
+                                @ParamAttribute(name = "defaultEnvironment") Environment
defaultEnvironment,
                                 @ParamSpecial(type = SpecialAttributeType.kernel) Kernel
kernel,
                                 @ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext,
-                                @ParamSpecial(type = SpecialAttributeType.abstractName) AbstractName
abstractName)  
+                                @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);
+        this.defaultEnvironment = defaultEnvironment;
     }
-    
+
     public void doStart() throws Exception {
         registration = bundleContext.registerService(ApplicationInstaller.class.getName(),
this, null);
     }
@@ -89,48 +95,50 @@ public class ApplicationInstaller implem
     public void doFail() {
         doStop();
     }
-                
+
     protected ConfigurationManager getConfigurationManager() {
         return configurationManager;
     }
-    
-    public DeploymentContext startInstall(AriesApplication app, ConfigurationStore targetConfigurationStore)

+
+    public DeploymentContext startInstall(AriesApplication app, ConfigurationStore targetConfigurationStore)
         throws ConfigurationAlreadyExistsException, IOException, DeploymentException {
-                                
+
         Artifact configId = getConfigId(app.getApplicationMetadata());
-        
+
         targetConfigurationStore.createNewConfigurationDir(configId);
-        
+
         Environment environment = new Environment();
         environment.setConfigId(configId);
-        
+
+        EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
+
         Naming naming = kernel.getNaming();
         AbstractName moduleName = naming.createRootName(configId, configId.toString(), "AriesApplication");
         //Use a temporary folder to hold the extracted files for analysis use
         File tempDirectory = FileUtils.createTempDir();
         try {
-            DeploymentContext context = new DeploymentContext(tempDirectory,            
   
+            DeploymentContext context = new DeploymentContext(tempDirectory,
                             null,
                             environment,
                             moduleName,
                             ConfigurationModuleType.EBA,
                             naming,
                             configurationManager,
-                            null, 
+                            null,
                             bundleContext);
-                                    
+
             context.flush();
             context.initializeConfiguration();
-                        
+
             app.store(tempDirectory);
-                        
+
             AbstractName name = naming.createChildName(moduleName, "AriesApplication", "GBean");
             GBeanData data = new GBeanData(name, ApplicationGBean.class);
             data.setAttribute("configId", configId);
             data.setReferencePattern("Installer", abstractName);
-            
+
             context.addGBean(data);
-            
+
             return context;
         } catch (DeploymentException e) {
             e.printStackTrace();
@@ -141,7 +149,7 @@ public class ApplicationInstaller implem
         }
     }
 
-    public ConfigurationData finishInstall(DeploymentContext context, ConfigurationStore
targetConfigurationStore)  
+    public ConfigurationData finishInstall(DeploymentContext context, ConfigurationStore
targetConfigurationStore)
         throws ConfigurationAlreadyExistsException, DeploymentException {
         try {
             ConfigurationData configurationData = context.getConfigurationData();
@@ -154,7 +162,7 @@ public class ApplicationInstaller implem
             try { context.close(); } catch (IOException e) {}
         }
     }
-    
+
     public void install(AriesApplication app) throws ConfigurationAlreadyExistsException,
IOException, DeploymentException {
         ConfigurationStore store = configurationStores.iterator().next();
         if (store == null) {
@@ -162,7 +170,7 @@ public class ApplicationInstaller implem
         }
         DeploymentContext context = startInstall(app, store);
         ConfigurationData configurationData = finishInstall(context, store);
-        
+
         try {
             configurationManager.loadConfiguration(configurationData.getId());
             configurationManager.startConfiguration(configurationData.getId());
@@ -171,15 +179,15 @@ public class ApplicationInstaller implem
             throw new DeploymentException("", e);
         }
     }
-            
+
     public static Artifact getConfigId(ApplicationMetadata metadata) {
         return createArtifact("application", metadata.getApplicationSymbolicName(), metadata.getApplicationVersion());
     }
-    
+
     private static Artifact createArtifact(String group, String symbolicName, Version version)
{
         return new Artifact(group, symbolicName, getVersion(version), "eba");
     }
-    
+
     private static String getVersion(Version version) {
         String str = version.getMajor() + "." + version.getMinor() + "." + version.getMicro();
         String qualifier = version.getQualifier();
@@ -188,5 +196,5 @@ public class ApplicationInstaller implem
         }
         return str;
     }
-    
+
 }



Mime
View raw message