geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1132745 - in /geronimo/server/trunk/plugins/aries: geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ geronimo-aries/src/main/java/org/apache/geronimo/aries/
Date Mon, 06 Jun 2011 20:17:41 GMT
Author: gawor
Date: Mon Jun  6 20:17:41 2011
New Revision: 1132745

URL: http://svn.apache.org/viewvc?rev=1132745&view=rev
Log:
GERONIMO-5996: Development mode for Aries applications - allow applications to be re-resolved
each time they are started

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

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=1132745&r1=1132744&r2=1132745&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
Mon Jun  6 20:17:41 2011
@@ -139,6 +139,11 @@ public class ApplicationConfigBuilder im
         return ApplicationInstaller.getConfigId(metadata);
     }
 
+    private static boolean getResolveOnDeploy() {
+        String property = System.getProperty("org.apache.geronimo.aries.resolveApplicationOnDeploy",
"true");
+        return Boolean.parseBoolean(property);
+    }
+
     public DeploymentContext buildConfiguration(boolean inPlaceDeployment,
                                                 Artifact configId,
                                                 Object plan,
@@ -157,7 +162,7 @@ public class ApplicationConfigBuilder im
             throw new DeploymentException("Error creating Aries Application", e);
         }
 
-        if (!app.isResolved()) {
+        if (!app.isResolved() && getResolveOnDeploy()) {
             try {
                 app = appManager.resolve(app);
             } catch (Exception e) {

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java?rev=1132745&r1=1132744&r2=1132745&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationGBean.java
Mon Jun  6 20:17:41 2011
@@ -42,6 +42,7 @@ import org.apache.aries.application.mana
 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.ResolverException;
 import org.apache.aries.application.management.AriesApplicationContext.ApplicationState;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
@@ -104,6 +105,8 @@ public class ApplicationGBean implements
             applicationFactory = getService(applicationFactoryReference, ApplicationMetadataFactory.class);
         
             this.application = new GeronimoApplication(bundle, applicationFactory, deploymentFactory);
+            
+            install(deploymentFactory);
         } finally {
             if (deploymentFactory != null) {
                 bundleContext.ungetService(deploymentFactoryReference);
@@ -112,8 +115,6 @@ public class ApplicationGBean implements
                 bundleContext.ungetService(applicationFactoryReference);
             }
         }
-        
-        install();
                         
         ServiceReference applicationManagerReference = 
             bundleContext.getServiceReference(AriesApplicationContextManager.class.getName());
@@ -315,7 +316,21 @@ public class ApplicationGBean implements
         return applicationState;
     }
     
-    private void install() throws Exception {
+    private DeploymentMetadata getDeploymentMetadata(AriesApplicationResolver resolver, DeploymentMetadataFactory
deploymentFactory) throws ResolverException {
+        DeploymentMetadata meta = application.getDeploymentMetadata();
+        if (meta == null) {
+            // try to resolve the application
+            LOG.debug("Resolving {} application.", application.getApplicationMetadata().getApplicationScope());
+            Set<BundleInfo> requiredBundles = resolver.resolve(application);
+            meta = deploymentFactory.createDeploymentMetadata(application, requiredBundles);
+            LOG.debug("Resolved application bundles: {} ", requiredBundles);
+        } else {
+            LOG.debug("Application {} is resolved.", application.getApplicationMetadata().getApplicationScope());
+        }
+        return meta;
+    }
+    
+    private void install(DeploymentMetadataFactory deploymentFactory) throws Exception {
 
         BundleContext bundleContext = bundle.getBundleContext();
         
@@ -324,19 +339,20 @@ public class ApplicationGBean implements
         
         ServiceReference resolverRef = bundleContext.getServiceReference(AriesApplicationResolver.class.getName());
         ServiceReference packageAdminRef = bundleContext.getServiceReference(PackageAdmin.class.getName());
-                
-        DeploymentMetadata meta = application.getDeploymentMetadata();
-        
-        List<DeploymentContent> deploymentContentsBundles = meta.getApplicationDeploymentContents();
-        List<DeploymentContent> provisionBundles = meta.getApplicationProvisionBundles();
-        
-        List<DeploymentContent> bundlesToInstall = new ArrayList<DeploymentContent>();
-        bundlesToInstall.addAll(deploymentContentsBundles);
-        bundlesToInstall.addAll(provisionBundles);
-        
+                              
         applicationBundles = new HashSet<Bundle>();
         try {
             resolver = getService(resolverRef, AriesApplicationResolver.class);
+            
+            DeploymentMetadata meta = getDeploymentMetadata(resolver, deploymentFactory);
+            
+            List<DeploymentContent> deploymentContentsBundles = meta.getApplicationDeploymentContents();
+            List<DeploymentContent> provisionBundles = meta.getApplicationProvisionBundles();
+            
+            List<DeploymentContent> bundlesToInstall = new ArrayList<DeploymentContent>();
+            bundlesToInstall.addAll(deploymentContentsBundles);
+            bundlesToInstall.addAll(provisionBundles);
+            
             packageAdmin = getService(packageAdminRef, PackageAdmin.class);
             
             for (DeploymentContent content : bundlesToInstall) {

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java?rev=1132745&r1=1132744&r2=1132745&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/ApplicationInstaller.java
Mon Jun  6 20:17:41 2011
@@ -145,11 +145,9 @@ public class ApplicationInstaller implem
 
             return context;
         } catch (DeploymentException e) {
-            e.printStackTrace();
             throw e;
         } catch (Exception e) {
-            e.printStackTrace();
-            throw new DeploymentException("", e);
+            throw new DeploymentException("Error deploying application", e);
         }
     }
 
@@ -160,8 +158,7 @@ public class ApplicationInstaller implem
             targetConfigurationStore.install(configurationData);
             return configurationData;
         } catch (Exception e) {
-            e.printStackTrace();
-            throw new DeploymentException("", e);
+            throw new DeploymentException("Error installing application", e);
         } finally {
             try { context.close(); } catch (IOException e) {}
         }
@@ -179,8 +176,7 @@ public class ApplicationInstaller implem
             configurationManager.loadConfiguration(configurationData.getId());
             configurationManager.startConfiguration(configurationData.getId());
         } catch (Exception e) {
-            e.printStackTrace();
-            throw new DeploymentException("", e);
+            throw new DeploymentException("Error installing application", e);
         }
     }
 

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java?rev=1132745&r1=1132744&r2=1132745&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries/src/main/java/org/apache/geronimo/aries/GeronimoApplication.java
Mon Jun  6 20:17:41 2011
@@ -41,15 +41,16 @@ import org.osgi.framework.Bundle;
  */
 public class GeronimoApplication implements AriesApplication {
     
+    private final ApplicationMetadata applicationMetadata;
+    private final Set<BundleInfo> bundleInfo;
     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());
   
+        URL applicationMF = bundle.getEntry(AppConstants.APPLICATION_MF);
+        applicationMetadata = applicationFactory.parseApplicationMetadata(applicationMF.openStream());
         
         bundleInfo = new HashSet<BundleInfo>();
         Enumeration<URL> e = bundle.findEntries("/", "*", true);
@@ -63,10 +64,15 @@ public class GeronimoApplication impleme
                 bundleInfo.add(new SimpleBundleInfo(applicationFactory, bm, url.toExternalForm()));
             }
         }
+        
+        URL deploymentMF = bundle.getEntry(AppConstants.DEPLOYMENT_MF);
+        if (deploymentMF != null) {
+            deploymentMetadata = deploymentFactory.createDeploymentMetadata(deploymentMF.openStream());
+        }
     }
 
     public ApplicationMetadata getApplicationMetadata() {
-        return deploymentMetadata.getApplicationMetadata();
+        return applicationMetadata;
     }
 
     public Set<BundleInfo> getBundleInfo() {
@@ -78,7 +84,7 @@ public class GeronimoApplication impleme
     }
 
     public boolean isResolved() {
-        return true;
+        return (deploymentMetadata != null);
     }
 
     public void store(File arg0) throws FileNotFoundException, IOException {



Mime
View raw message