diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-27 01:23:40 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-27 01:23:40 +0000 |
commit | 3635a0ee6f59980439ec043f2251d950e4ffb8a4 (patch) | |
tree | df7870b015abf1b4e6559d8045fb81293e7e7b31 /java/sca/modules/node-impl | |
parent | d8da679db3c406c9c56cc14d047645d0cebb7afd (diff) |
Add optional life cycle control for extension points (for example, RMI extension point needs to unexport the registry)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@778955 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-impl')
2 files changed, 12 insertions, 4 deletions
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index 6bca9fc9e7..dfdbc54f13 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -129,13 +129,23 @@ public class NodeFactoryImpl extends NodeFactory { private WorkScheduler workScheduler; private StAXArtifactProcessorExtensionPoint xmlProcessors; + /** + * Automatically destroy the factory when last node is stopped. Subclasses + * can set this flag. + */ + protected boolean autoDestroy = true; + @Override public Node createNode(NodeConfiguration configuration) { return new NodeImpl(this, configuration); } protected Node removeNode(NodeConfiguration configuration) { - return nodes.remove(getNodeKey(configuration)); + Node node = nodes.remove(getNodeKey(configuration)); + if (autoDestroy && nodes.isEmpty()) { + destroy(); + } + return node; } protected void addNode(NodeConfiguration configuration, Node node) { @@ -195,6 +205,7 @@ public class NodeFactoryImpl extends NodeFactory { // Stop and destroy the work manager workScheduler.destroy(); + extensionPoints.destroy(); inited = false; } } diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index ac53f805df..febf4033e8 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -114,9 +114,6 @@ public class NodeImpl implements Node, Client { manager.removeNode(configuration); this.compositeActivator = null; this.proxyFactory = null; - if (manager.getNodes().isEmpty()) { - manager.destroy(); - } } catch (ActivationException e) { throw new IllegalStateException(e); |