You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/11/02 18:11:29 UTC

svn commit: r831974 - /tuscany/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java

Author: rfeng
Date: Mon Nov  2 17:11:29 2009
New Revision: 831974

URL: http://svn.apache.org/viewvc?rev=831974&view=rev
Log:
Only stop the bundle if it is started by the provider

Modified:
    tuscany/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java

Modified: tuscany/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java?rev=831974&r1=831973&r2=831974&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java (original)
+++ tuscany/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java Mon Nov  2 17:11:29 2009
@@ -64,6 +64,7 @@
     private RuntimeComponent component;
     private ProxyFactoryExtensionPoint proxyFactoryExtensionPoint;
     private Bundle osgiBundle;
+    private boolean startedByMe;
     private OSGiImplementation implementation;
     private List<ServiceRegistration> registrations = new ArrayList<ServiceRegistration>();
     private OSGiImplementationFactory implementationFactory;
@@ -89,6 +90,7 @@
             int state = osgiBundle.getState();
             if ((state & Bundle.STARTING) == 0 && (state & Bundle.ACTIVE) == 0) {
                 osgiBundle.start();
+                startedByMe = true;
             }
         } catch (BundleException e) {
             throw new ServiceRuntimeException(e);
@@ -157,13 +159,18 @@
             }
         }
         registrations.clear();
-        try {
-            int state = osgiBundle.getState();
-            if ((state & Bundle.STOPPING) == 0 && (state & Bundle.ACTIVE) != 0) {
-                osgiBundle.stop();
+        // [REVIEW] Shoud it take care of stopping the bundle?
+        if (startedByMe) {
+            try {
+                int state = osgiBundle.getState();
+                if ((state & Bundle.STOPPING) == 0 && (state & Bundle.ACTIVE) != 0) {
+                    osgiBundle.stop();
+                }
+            } catch (BundleException e) {
+                throw new ServiceRuntimeException(e);
+            } finally {
+                startedByMe = false;
             }
-        } catch (BundleException e) {
-            throw new ServiceRuntimeException(e);
         }
     }