From 6daac2ac36b76c7c48b10846ce078c7b3b0cd6af Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 9 Feb 2011 14:01:46 +0000 Subject: TUSCANY-3834 - continue stopping components in the case of exceptions thrown during a previous component stop. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1068894 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/core/assembly/CompositeActivatorImpl.java | 78 ++++++++++++++-------- .../sca/core/scope/CompositeScopeContainer.java | 1 + 2 files changed, 50 insertions(+), 29 deletions(-) (limited to 'sca-java-1.x/trunk/modules') diff --git a/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java b/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java index c5ffbc4a46..af3e6061a8 100644 --- a/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java +++ b/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivatorImpl.java @@ -739,13 +739,17 @@ public class CompositeActivatorImpl implements CompositeActivator { for (Binding binding : service.getBindings()) { final ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service).getBindingProvider(binding); if (bindingProvider != null) { - // Allow bindings to read properties. Requires PropertyPermission read in security policy. - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - bindingProvider.stop(); - return null; - } - }); + try { + // Allow bindings to read properties. Requires PropertyPermission read in security policy. + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + bindingProvider.stop(); + return null; + } + }); + } catch (Throwable ex){ + logger.log(Level.SEVERE, ex.getMessage(), ex); + } } } } @@ -758,26 +762,34 @@ public class CompositeActivatorImpl implements CompositeActivator { for (Binding binding : reference.getBindings()) { final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(binding); if (bindingProvider != null) { - // Allow bindings to read properties. Requires PropertyPermission read in security policy. - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - bindingProvider.stop(); - return null; - } - }); + try { + // Allow bindings to read properties. Requires PropertyPermission read in security policy. + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + bindingProvider.stop(); + return null; + } + }); + } catch (Throwable ex){ + logger.log(Level.SEVERE, ex.getMessage(), ex); + } } } for (Endpoint endpoint : reference.getEndpoints()) { final EndpointResolver endpointResolver = runtimeRef.getEndpointResolver(endpoint); if (endpointResolver != null) { - // Allow endpoint resolvers to do any shutdown reference manipulation - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - endpointResolver.stop(); - return null; - } - }); + try { + // Allow endpoint resolvers to do any shutdown reference manipulation + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + endpointResolver.stop(); + return null; + } + }); + } catch (Throwable ex){ + logger.log(Level.SEVERE, ex.getMessage(), ex); + } } } } @@ -787,13 +799,17 @@ public class CompositeActivatorImpl implements CompositeActivator { } else { final ImplementationProvider implementationProvider = ((RuntimeComponent)component).getImplementationProvider(); if (implementationProvider != null) { - // Allow bindings to read properties. Requires PropertyPermission read in security policy. - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - implementationProvider.stop(); - return null; - } - }); + try { + // Allow bindings to read properties. Requires PropertyPermission read in security policy. + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + implementationProvider.stop(); + return null; + } + }); + } catch (Throwable ex){ + logger.log(Level.SEVERE, ex.getMessage(), ex); + } } } @@ -801,7 +817,11 @@ public class CompositeActivatorImpl implements CompositeActivator { ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component; if (runtimeComponent.getScopeContainer() != null && runtimeComponent.getScopeContainer().getLifecycleState() != ScopeContainer.STOPPED) { - runtimeComponent.getScopeContainer().stop(); + try { + runtimeComponent.getScopeContainer().stop(); + } catch (Throwable ex){ + logger.log(Level.SEVERE, ex.getMessage(), ex); + } } } diff --git a/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java b/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java index 7a1965198a..8c727ec76e 100644 --- a/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java +++ b/sca-java-1.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java @@ -40,6 +40,7 @@ public class CompositeScopeContainer extends AbstractScopeContainer { try { wrapper.stop(); } catch (TargetDestructionException e) { + wrapper = null; throw new IllegalStateException(e); } } -- cgit v1.2.3