diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-16 12:38:47 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-04-16 12:38:47 +0000 |
commit | 908cb6c56ed33cfaef79bffe1328785a76081264 (patch) | |
tree | 3b18e07b7bf1f4bbf35f5b4e0701e78944e146e4 /branches/sca-java-1.x/modules/core/src/main/java | |
parent | 109743dc29fe6980795191d880aaade02739fb4a (diff) |
TUSCANY-2851, fix exceptions during init processing of java components to call destroy
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@765611 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/core/src/main/java')
3 files changed, 49 insertions, 4 deletions
diff --git a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java index 7e7ab7a9e4..7a1965198a 100644 --- a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java +++ b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/CompositeScopeContainer.java @@ -50,7 +50,20 @@ public class CompositeScopeContainer<KEY> extends AbstractScopeContainer<KEY> { public synchronized InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException { if (wrapper == null) { wrapper = createInstanceWrapper(); - wrapper.start(); + try { + wrapper.start(); + } catch (ThreadDeath td) { + throw td; + } catch (Throwable e) { + try { + wrapper.stop(); + } catch (ThreadDeath td) { + throw td; + } catch (Throwable e2) { + } + wrapper = null; + throw new TargetInitializationException(e); + } } return wrapper; } diff --git a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java index f11a61e662..8fdfcc63c9 100644 --- a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java +++ b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/RequestScopeContainer.java @@ -62,6 +62,14 @@ public class RequestScopeContainer extends AbstractScopeContainer<Thread> { // synchronized (destroyQueues) { // destroyQueues.clear(); // } + for (InstanceWrapper ctx : wrappers.values()) { + try { + ctx.stop(); + } catch (ThreadDeath td) { + throw td; + } catch (Throwable e2) { + } + } lifecycleState = STOPPED; } @@ -72,8 +80,20 @@ public class RequestScopeContainer extends AbstractScopeContainer<Thread> { } if (ctx == null) { ctx = super.createInstanceWrapper(); - ctx.start(); - wrappers.put(Thread.currentThread(), ctx); + try { + ctx.start(); + wrappers.put(Thread.currentThread(), ctx); + } catch (ThreadDeath td) { + throw td; + } catch (Throwable e) { + try { + ctx.stop(); + } catch (ThreadDeath td) { + throw td; + } catch (Throwable e2) { + } + throw new TargetInitializationException(e); + } } return ctx; } diff --git a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainer.java b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainer.java index a2c0edb9b4..24125b154c 100644 --- a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainer.java +++ b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/StatelessScopeContainer.java @@ -36,7 +36,19 @@ public class StatelessScopeContainer<KEY> extends AbstractScopeContainer<KEY> { public InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException { InstanceWrapper ctx = createInstanceWrapper(); - ctx.start(); + try { + ctx.start(); + } catch (ThreadDeath td) { + throw td; + } catch (Throwable e) { + try { + ctx.stop(); + } catch (ThreadDeath td) { + throw td; + } catch (Throwable e2) { + } + throw new TargetInitializationException(e); + } return ctx; } |