From ba1bcc3ca8abd9a14ba185bb4f7bc95460336c3a Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 2 Nov 2009 17:11:29 +0000 Subject: Only stop the bundle if it is started by the provider git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@831974 13f79535-47bb-0310-9956-ffa450edef68 --- .../osgi/runtime/OSGiImplementationProvider.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'java/sca/modules') diff --git a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java index 5744d7336f..9111a7d03c 100644 --- a/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java +++ b/java/sca/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java @@ -64,6 +64,7 @@ public class OSGiImplementationProvider implements ImplementationProvider { private RuntimeComponent component; private ProxyFactoryExtensionPoint proxyFactoryExtensionPoint; private Bundle osgiBundle; + private boolean startedByMe; private OSGiImplementation implementation; private List registrations = new ArrayList(); private OSGiImplementationFactory implementationFactory; @@ -89,6 +90,7 @@ public class OSGiImplementationProvider implements ImplementationProvider { 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 @@ public class OSGiImplementationProvider implements ImplementationProvider { } } 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); } } -- cgit v1.2.3