Mail Archive Home | fractal-commits List | July 2008 Index
| <-- Date Index --> | <-- Thread Index --> |
Support stopFc. Fix for http://www.scorware.org/projects/SCOrWare/bugtracker/Support_stopFc_for_RmiServerBridge
--- trunk/fractal-bf/connectors/rmi/src/main/java/org/objectweb/fractal/bf/connectors/rmi/RmiServerBridge.java 2008-07-25 12:00:39 UTC (rev 8322)
+++ trunk/fractal-bf/connectors/rmi/src/main/java/org/objectweb/fractal/bf/connectors/rmi/RmiServerBridge.java 2008-07-26 18:41:32 UTC (rev 8323)
@@ -90,6 +90,8 @@
*/
private static HttpServer HTTP_SERVER;
+ private Registry registry;
+
/**
* Default constructor.
*/
@@ -199,8 +201,9 @@
RmiServerBridge.server.add(rmiSkeleton);
Remote remote = UnicastRemoteObject.exportObject(rmiSkeleton, 0);
- Registry registry = locateRegistry();
-
+ if (registry == null) {
+ registry = locateRegistry();
+ }
log.fine("Going to bind RMI skeleton into the RMI registry..");
registry.bind(name, remote);
log.fine("RMI skeleton successefully bound into registry");
@@ -355,7 +358,13 @@
* @see org.objectweb.fractal.api.control.LifeCycleController#stopFc()
*/
public void stopFc() throws IllegalLifeCycleException {
- throw new UnsupportedOperationException("not implemented yet");
+ try {
+ this.registry.unbind(this.name);
+ this.state = LifeCycleController.STOPPED;
+ } catch (Exception e) {
+ throw new RmiConnectorException(
+ "Cannot unbind the service from the RMI registry", e);
+ }
}
--- trunk/fractal-bf/connectors/rmi/src/test/java/org/objectweb/fractal/bf/connectors/rmi/RmiServerBridgeTest.java 2008-07-25 12:00:39 UTC (rev 8322)
+++ trunk/fractal-bf/connectors/rmi/src/test/java/org/objectweb/fractal/bf/connectors/rmi/RmiServerBridgeTest.java 2008-07-26 18:41:32 UTC (rev 8323)
@@ -40,6 +40,7 @@
import org.objectweb.fractal.adl.FactoryFactory;
import org.objectweb.fractal.api.Component;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;
+import org.objectweb.fractal.api.control.LifeCycleController;
import org.objectweb.fractal.bf.AbstractSkeleton;
/**
@@ -106,6 +107,22 @@
}
@Test
+ public void testStopFc() throws IllegalLifeCycleException, AccessException,
+ RemoteException {
+ // start it
+ bridge.startFc();
+ Integer registeredServices = new Integer(RMI_REGISTRY.list().length);
+ assertThat(registeredServices, is(new Integer(1)));
+ assertThat(bridge.getFcState(), is(LifeCycleController.STARTED));
+ // now stop it
+ bridge.stopFc();
+ registeredServices = new Integer(RMI_REGISTRY.list().length);
+ assertThat(registeredServices, is(new Integer(0)));
+ assertThat(bridge.getFcState(), is(LifeCycleController.STOPPED));
+
+ }
+
+ @Test
public void testListFc() {
String[] itfs = bridge.listFc();
assertEquals(2, itfs.length);
| <-- Date Index --> | <-- Thread Index --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.