OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | fractal-commits List | July 2008 Index

<--  Date Index  --> <--  Thread Index  -->

[fractal-commits] [8323] trunk/fractal-bf/connectors/rmi/src: Support stopFc.


Title: [8323] trunk/fractal-bf/connectors/rmi/src: Support stopFc.
Revision
8323
Author
ervalerio
Date
2008-07-26 20:41:32 +0200 (Sat, 26 Jul 2008)

Log Message

Support stopFc. Fix for http://www.scorware.org/projects/SCOrWare/bugtracker/Support_stopFc_for_RmiServerBridge

Modified Paths

Diff

Modified: trunk/fractal-bf/connectors/rmi/src/main/java/org/objectweb/fractal/bf/connectors/rmi/RmiServerBridge.java (8322 => 8323)


--- 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);
+		}
 
 	}
 

Modified: trunk/fractal-bf/connectors/rmi/src/test/java/org/objectweb/fractal/bf/connectors/rmi/RmiServerBridgeTest.java (8322 => 8323)


--- 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  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.