geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r926611 - in /geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder: ApplicationGBean.java ApplicationInstaller.java GeronimoApplicationContext.java
Date Tue, 23 Mar 2010 15:19:24 GMT
Author: gawor
Date: Tue Mar 23 15:19:23 2010
New Revision: 926611

URL: http://svn.apache.org/viewvc?rev=926611&view=rev
Log:
GERONIMO-4971: Reimplement application start/stop

Modified:
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationInstaller.java
    geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java

Modified: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java?rev=926611&r1=926610&r2=926611&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/ApplicationGBean.java
Tue Mar 23 15:19:23 2010
@@ -33,11 +33,13 @@ import org.apache.aries.application.mana
 import org.apache.aries.application.management.AriesApplicationContext.ApplicationState;
 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;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.osgi.BundleUtils;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
@@ -54,34 +56,38 @@ public class ApplicationGBean implements
         
     private static final Logger LOG = LoggerFactory.getLogger(ApplicationGBean.class);
     
-    private BundleContext bundleContext;
-    private ApplicationInstaller installer;
+    private final Bundle bundle;
+    private final ApplicationInstaller installer;
+    private final Artifact configId;
     private GeronimoApplication application;
     private ApplicationState applicationState;
     private Set<Bundle> applicationBundles;
     
     public ApplicationGBean(@ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
-                            @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext
bundleContext,
+                            @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle,
+                            @ParamAttribute(name="configId") Artifact configId, 
                             @ParamReference(name="Installer") ApplicationInstaller installer)

         throws Exception {
-        this.bundleContext = bundleContext;
+        this.bundle = bundle;
         this.installer = installer;
+        this.configId = configId;
                 
         // XXX: fix me
-        DeploymentMetadataFactory deploymentFactory = getDeploymentMetadataFactory();
-        ApplicationMetadataFactory applicationFactory = getApplicationMetadataFactory();
+        BundleContext bundleContext = bundle.getBundleContext();
+        DeploymentMetadataFactory deploymentFactory = getDeploymentMetadataFactory(bundleContext);
+        ApplicationMetadataFactory applicationFactory = getApplicationMetadataFactory(bundleContext);
         
-        this.application = new GeronimoApplication(bundleContext.getBundle(), applicationFactory,
deploymentFactory);
+        this.application = new GeronimoApplication(bundle, applicationFactory, deploymentFactory);
         
         install();
         
         GeronimoApplicationContextManager applicationManager = 
-            (GeronimoApplicationContextManager) getApplicationContextManager();
+            (GeronimoApplicationContextManager) getApplicationContextManager(bundleContext);
         applicationManager.registerApplicationContext(new GeronimoApplicationContext(this));
     }
     
     protected Bundle getBundle() {
-        return bundleContext.getBundle();
+        return bundle;
     }
     
     protected AriesApplication getAriesApplication() {
@@ -96,7 +102,7 @@ public class ApplicationGBean implements
         return applicationState;
     }
         
-    private AriesApplicationContextManager getApplicationContextManager() {
+    private AriesApplicationContextManager getApplicationContextManager(BundleContext bundleContext)
{
         ServiceReference ref = 
             bundleContext.getServiceReference(AriesApplicationContextManager.class.getName());
         if (ref != null) {
@@ -106,7 +112,7 @@ public class ApplicationGBean implements
         }
     }
     
-    private DeploymentMetadataFactory getDeploymentMetadataFactory() {
+    private DeploymentMetadataFactory getDeploymentMetadataFactory(BundleContext bundleContext)
{
         ServiceReference ref = 
             bundleContext.getServiceReference(DeploymentMetadataFactory.class.getName());
         if (ref != null) {
@@ -116,7 +122,7 @@ public class ApplicationGBean implements
         }
     }
     
-    private ApplicationMetadataFactory getApplicationMetadataFactory() {
+    private ApplicationMetadataFactory getApplicationMetadataFactory(BundleContext bundleContext)
{
         ServiceReference ref = 
             bundleContext.getServiceReference(ApplicationMetadataFactory.class.getName());
         if (ref != null) {
@@ -128,6 +134,8 @@ public class ApplicationGBean implements
     
     private void install() throws Exception {
 
+        BundleContext bundleContext = bundle.getBundleContext();
+        
         AriesApplicationResolver resolver = null;
 
         ServiceReference ref = bundleContext.getServiceReference(AriesApplicationResolver.class.getName());
@@ -242,7 +250,25 @@ public class ApplicationGBean implements
         doStop();
     }
    
-    protected void uninstall() {
+    protected void applicationStart() throws BundleException {
+        try {
+            installer.getConfigurationManager().loadConfiguration(configId);
+            installer.getConfigurationManager().startConfiguration(configId);
+        } catch (Exception e) {
+            throw new BundleException("Failed to start application", e);            
+        }
+    }
+    
+    protected void applicationStop() throws BundleException {
+        try {
+            installer.getConfigurationManager().unloadConfiguration(configId);
+            bundle.stop();
+        } catch (Exception e) {
+            throw new BundleException("Failed to start application", e);            
+        }
+    }
+    
+    protected void applicationUninstall() {
         LOG.debug("Uninstalling {}", application.getApplicationMetadata().getApplicationScope());
         
         // uninstall application bundles
@@ -260,7 +286,7 @@ public class ApplicationGBean implements
         
         // uninstall application bundle         
         try {
-            bundleContext.getBundle().uninstall();
+            bundle.uninstall();
         } catch (Exception e) {
             e.printStackTrace();
         }        

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=926611&r1=926610&r2=926611&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
Tue Mar 23 15:19:23 2010
@@ -90,6 +90,10 @@ public class ApplicationInstaller implem
         doStop();
     }
                 
+    protected ConfigurationManager getConfigurationManager() {
+        return configurationManager;
+    }
+    
     public DeploymentContext startInstall(AriesApplication app, ConfigurationStore targetConfigurationStore)

         throws ConfigurationAlreadyExistsException, DeploymentException {
                                 
@@ -120,6 +124,7 @@ public class ApplicationInstaller implem
                         
             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);

Modified: 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=926611&r1=926610&r2=926611&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java
(original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/GeronimoApplicationContext.java
Tue Mar 23 15:19:23 2010
@@ -47,14 +47,14 @@ public class GeronimoApplicationContext 
     }
 
     public void start() throws BundleException {
-        applicationGBean.getBundle().start();
+        applicationGBean.applicationStart();
     }
 
     public void stop() throws BundleException {
-        applicationGBean.getBundle().stop();
+        applicationGBean.applicationStop();
     }
   
     protected void uninstall() {
-        applicationGBean.uninstall();
+        applicationGBean.applicationUninstall();
     }
 }



Mime
View raw message