From d88b2af71307638c59e819285efaa91b8a1bd495 Mon Sep 17 00:00:00 2001 From: rfeng Date: Wed, 17 Jun 2009 16:14:58 +0000 Subject: Add a LifeCycleListener interface so that extension points or extension can be called back upon the start/stop of the extension point registry git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@785699 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java | 2 +- .../sca/host/rmi/DefaultRMIHostExtensionPoint.java | 16 ++++++++++------ .../apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java | 5 ----- .../java/org/apache/tuscany/sca/host/rmi/RMIHost.java | 5 ----- 4 files changed, 11 insertions(+), 17 deletions(-) (limited to 'java/sca/modules/host-rmi/src') diff --git a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java index f98ce018e5..99a6a5fab7 100644 --- a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java +++ b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java @@ -155,7 +155,7 @@ public class DefaultRMIHost implements RMIHost { } } - public void destroy() { + public void stop() { for (Registry registry : rmiRegistries.values()) { try { UnicastRemoteObject.unexportObject(registry, false); diff --git a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java index edfda79dd0..b7435a1f84 100644 --- a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java +++ b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java @@ -22,15 +22,14 @@ package org.apache.tuscany.sca.host.rmi; import java.util.ArrayList; import java.util.List; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.core.LifeCycleListener; /** * Default implementation of an RMI host extension point. * * @version $Rev$ $Date$ */ -public class DefaultRMIHostExtensionPoint implements RMIHostExtensionPoint, ModuleActivator { +public class DefaultRMIHostExtensionPoint implements RMIHostExtensionPoint, LifeCycleListener { private List rmiHosts = new ArrayList(); @@ -40,6 +39,9 @@ public class DefaultRMIHostExtensionPoint implements RMIHostExtensionPoint, Modu public void addRMIHost(RMIHost rmiHost) { rmiHosts.add(rmiHost); + if(rmiHost instanceof LifeCycleListener) { + ((LifeCycleListener) rmiHost).start(); + } } public void removeRMIHost(RMIHost rmiHost) { @@ -50,12 +52,14 @@ public class DefaultRMIHostExtensionPoint implements RMIHostExtensionPoint, Modu return rmiHosts; } - public void start(ExtensionPointRegistry registry) { + public void start() { } - public void stop(ExtensionPointRegistry registry) { + public void stop() { for (RMIHost host : rmiHosts) { - host.destroy(); + if(host instanceof LifeCycleListener) { + ((LifeCycleListener) host).stop(); + } } } } diff --git a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java index e2fad5d9b5..2f3e2311ed 100644 --- a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java +++ b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java @@ -59,9 +59,4 @@ public class ExtensibleRMIHost implements RMIHost { protected RMIHost getDefaultHost() { return rmiHosts.getRMIHosts().get(0); } - - public void destroy() { - getDefaultHost().destroy(); - } - } diff --git a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java index b85cc2fc2a..bf8659c254 100644 --- a/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java +++ b/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java @@ -57,9 +57,4 @@ public interface RMIHost { * @throws RMIHostRuntimeException */ Remote findService(String uri) throws RMIHostException, RMIHostRuntimeException; - - /** - * Destroy the host. It can be used to unbind the RMI registry - */ - void destroy(); } -- cgit v1.2.3