[or-cvs] r11633: replaced EventSource by locally unique String to simplify re (in puppetor/trunk/src/de/uniba/wiai/lspi/puppetor: . examples groovy impl rmi)

kloesing at seul.org kloesing at seul.org
Tue Sep 25 15:28:58 UTC 2007


Author: kloesing
Date: 2007-09-25 11:28:58 -0400 (Tue, 25 Sep 2007)
New Revision: 11633

Removed:
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventSource.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/LogListener.java
Modified:
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientApplication.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Event.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ServerApplication.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AccessingPublicWebServerOverTor.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPrivateTorNetwork.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPublicTorNetwork.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingHiddenServiceToPublicTorNetwork.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/RmiPuppetzShell.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ClientApplicationImpl.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventImpl.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventManagerImpl.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithOutDir.java
Log:
replaced EventSource by locally unique String to simplify remote access on the EventManager

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientApplication.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientApplication.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ClientApplication.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -40,7 +40,7 @@
  * 
  * @author kloesing
  */
-public interface ClientApplication extends EventSource {
+public interface ClientApplication {
 
 	/**
 	 * <p>
@@ -92,4 +92,12 @@
 	 *             Thrown if no requests have been started before.
 	 */
 	public abstract void stopRequest();
+	
+
+	/**
+	 * Returns the name of this client.
+	 * 
+	 * @return The name of this client.
+	 */
+	public abstract String getClientApplicationName();
 }

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Event.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Event.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Event.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -48,12 +48,12 @@
 public interface Event extends Serializable {
 
 	/**
-	 * Returns the source of this event, which can be a Tor process or a
-	 * client/server application running as thread in the background.
+	 * Returns the name of the source of this event, which can be a Tor process
+	 * or a client/server application running as thread in the background.
 	 * 
 	 * @return The event source.
 	 */
-	public abstract EventSource getSource();
+	public abstract String getSource();
 
 	/**
 	 * Returns the type of this event.

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventManager.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -37,14 +37,13 @@
 
 /**
  * The <code>EventManager</code> is the central place for a test run to manage
- * asynchronous events by Tor processes and client/server applications running
- * as threads in the background. A test application can either register event
- * listeners to be notified asynchronously about events when they occur, or
- * synchronize with an event by being blocked until the certain event occurs.
+ * asynchronous events by Tor processes and client or server applications
+ * running as threads in the background. A test application can either register
+ * event listeners to be notified asynchronously about events when they occur,
+ * or synchronize with an event by being blocked until the certain event occurs.
  * 
  * @author kloesing
  */
-
 public interface EventManager extends Remote {
 
 	/**
@@ -58,8 +57,9 @@
 	 * registering. This method can be invoked in any node or network state.
 	 * 
 	 * @param source
-	 *            The source of events that the listener is interested in. May
-	 *            not be <code>null</code>.
+	 *            The name of the source of events that the listener is
+	 *            interested in. May not be <code>null</code> and must be the
+	 *            name of a previously created node, client, or server.
 	 * @param listener
 	 *            The listener that wants to be notified about events from the
 	 *            given <code>source</code>. If the <code>listener</code>
@@ -72,11 +72,11 @@
 	 *         empty list is returned instead of <code>null</code>.
 	 * @throws IllegalArgumentException
 	 *             Thrown if <code>null</code> is passed for either of the
-	 *             parameters.
+	 *             parameters or if <code>source</code> is not known.
 	 * @throws RemoteException
 	 *             Thrown if an error occurs when accessed remotely.
 	 */
-	public abstract List<Event> addEventListener(EventSource source,
+	public abstract List<Event> addEventListener(String source,
 			EventListener listener) throws RemoteException;
 
 	/**
@@ -105,15 +105,17 @@
 	 * 
 	 * @param source
 	 *            The source of the events that the invoking thread is
-	 *            interested in. May not be <code>null</code>.
+	 *            interested in. May not be <code>null</code> and must be the
+	 *            name of a previously created node, client, or server.
 	 * @throws IllegalArgumentException
-	 *             Thrown if <code>null</code> is passed as parameter.
+	 *             Thrown if <code>null</code> is passed as parameter or if
+	 *             <code>source</code> is unknown.
 	 * @return List of all previously observed events from the given
 	 *         <code>source</code>.
 	 * @throws RemoteException
 	 *             Thrown if an error occurs when accessed remotely.
 	 */
-	public abstract List<Event> getEventHistory(EventSource source)
+	public abstract List<Event> getEventHistory(String source)
 			throws RemoteException;
 
 	/**
@@ -122,19 +124,20 @@
 	 * 
 	 * @param source
 	 *            The source of the event that the invoking thread is interested
-	 *            in. May not be <code>null</code>.
+	 *            in. May not be <code>null</code> and must be the name of a
+	 *            previously created node, client, or server.
 	 * @param event
 	 *            The event that the invoking thread is interested int. May not
 	 *            be <code>null</code>.
 	 * @throws IllegalArgumentException
 	 *             Thrown if <code>null</code> is passed for either of the
-	 *             parameters.
+	 *             parameters or if <code>source</code> is unknown.
 	 * @return <code>true</code> if the event has been observed from the
 	 *         source before, <code>false</code> otherwise.
 	 * @throws RemoteException
 	 *             Thrown if an error occurs when accessed remotely.
 	 */
-	public abstract boolean hasEventOccured(EventSource source, EventType event)
+	public abstract boolean hasEventOccured(String source, EventType event)
 			throws RemoteException;
 
 	/**
@@ -167,17 +170,18 @@
 	 * 
 	 * @param source
 	 *            The source of the event that the invoking thread is willing to
-	 *            wait for. May not be <code>null</code>.
+	 *            wait for. May not be <code>null</code> and must be the name
+	 *            of a previously created node, client, or server.
 	 * @param event
 	 *            The event that the invoking thread is willing to wait for from
 	 *            the given <code>source</code>. May not be <code>null</code>.
 	 * @throws IllegalArgumentException
 	 *             Thrown if <code>null</code> is passed for either of the
-	 *             parameters.
+	 *             parameters or if <code>source</code> is unknown.
 	 * @throws RemoteException
 	 *             Thrown if an error occurs when accessed remotely.
 	 */
-	public abstract void waitForAnyOccurence(EventSource source, EventType event)
+	public abstract void waitForAnyOccurence(String source, EventType event)
 			throws RemoteException;
 
 	/**
@@ -189,7 +193,8 @@
 	 * 
 	 * @param source
 	 *            The source of the event that the invoking thread is willing to
-	 *            wait for. May not be <code>null</code>.
+	 *            wait for. May not be <code>null</code> and must be the name
+	 *            of a previously created node, client, or server.
 	 * @param event
 	 *            The event that the invoking thread is willing to wait for from
 	 *            the given <code>source</code>. May not be <code>null</code>.
@@ -202,13 +207,12 @@
 	 *         otherwise.
 	 * @throws IllegalArgumentException
 	 *             Thrown if an invalid value is passed for either of the
-	 *             parameters.
+	 *             parameters or if <code>source</code> is unknown.
 	 * @throws RemoteException
 	 *             Thrown if an error occurs when accessed remotely.
 	 */
-	public abstract boolean waitForAnyOccurence(EventSource source,
-			EventType event, long maximumTimeToWaitInMillis)
-			throws RemoteException;
+	public abstract boolean waitForAnyOccurence(String source, EventType event,
+			long maximumTimeToWaitInMillis) throws RemoteException;
 
 	/**
 	 * Blocks the invoking thread until the next <code>event</code> is fired
@@ -220,18 +224,19 @@
 	 * 
 	 * @param source
 	 *            The source of the event that the invoking thread is willing to
-	 *            wait for. May not be <code>null</code>.
+	 *            wait for. May not be <code>null</code> and must be the name
+	 *            of a previously created node, client, or server.
 	 * @param event
 	 *            The event that the invoking thread is willing to wait for from
 	 *            the given <code>source</code>. May not be <code>null</code>.
 	 * @throws IllegalArgumentException
 	 *             Thrown if <code>null</code> is passed for either of the
-	 *             parameters.
+	 *             parameters or if <code>source</code> is unknown.
 	 * @throws RemoteException
 	 *             Thrown if an error occurs when accessed remotely.
 	 */
-	public abstract void waitForNextOccurence(EventSource source,
-			EventType event) throws RemoteException;
+	public abstract void waitForNextOccurence(String source, EventType event)
+			throws RemoteException;
 
 	/**
 	 * Blocks the invoking thread until the next <code>event</code> is fired
@@ -242,7 +247,8 @@
 	 * 
 	 * @param source
 	 *            The source of the event that the invoking thread is willing to
-	 *            wait for. May not be <code>null</code>.
+	 *            wait for. May not be <code>null</code> and must be the name
+	 *            of a previously created node, client, or server.
 	 * @param event
 	 *            The event that the invoking thread is willing to wait for from
 	 *            the given <code>source</code>. May not be <code>null</code>.
@@ -255,11 +261,11 @@
 	 *         otherwise.
 	 * @throws IllegalArgumentException
 	 *             Thrown if an invalid value is passed for either of the
-	 *             parameters.
+	 *             parameters or if <code>source</code> is unknown.
 	 * @throws RemoteException
 	 *             Thrown if an error occurs when accessed remotely.
 	 */
-	public abstract boolean waitForNextOccurence(EventSource source,
+	public abstract boolean waitForNextOccurence(String source,
 			EventType event, long maximumTimeToWaitInMillis)
 			throws RemoteException;
 

Deleted: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventSource.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventSource.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/EventSource.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2007, Karsten Loesing
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * 
- *     * Neither the names of the copyright owners nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.uniba.wiai.lspi.puppetor;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-/**
- * Super-interface of those interfaces that can be the source for events.
- * 
- * @author kloesing
- */
-public interface EventSource extends Remote {
-
-	/**
-	 * Returns the name of this event source.
-	 * 
-	 * @return The name of this event source
-	 * @throws RemoteException
-	 *             Thrown if an error occurs when accessed remotely.
-	 */
-	public abstract String getName() throws RemoteException;
-}

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -40,9 +40,6 @@
 import java.util.Map;
 import java.util.Set;
 
-// TODO this does not look good! we should not depend on groovy types here!
-import de.uniba.wiai.lspi.puppetor.groovy.LogListener;
-
 /**
  * A Network instance constitutes the central object of any test run and is
  * aware of the node configuration. It creates all nodes for this configuration
@@ -52,7 +49,7 @@
  * 
  * @author kloesing
  */
-public interface Network extends EventSource, Remote {
+public interface Network extends Remote {
 
 	/**
 	 * <p>
@@ -120,7 +117,8 @@
 	 * @param clientApplicationName
 	 *            The name for this client application, which is used for
 	 *            logging purposes only. May neither be <code>null</code> or a
-	 *            zero-length string.
+	 *            zero-length string. The name needs to be unique in this
+	 *            network.
 	 * @param targetAddress
 	 *            The target for requests sent by this client application. Can
 	 *            be an IP address, a domain name, or an onion address. May
@@ -461,7 +459,8 @@
 	 * @param serverApplicationName
 	 *            The name for this server application, which is used for
 	 *            logging purposes only. May neither be <code>null</code> or a
-	 *            zero-length string.
+	 *            zero-length string. The name needs to be unique in this
+	 *            network.
 	 * @return Reference to the created server application.
 	 * @throws IllegalArgumentException
 	 *             Thrown if an invalid value is given as server application
@@ -479,7 +478,8 @@
 	 * @param serverApplicationName
 	 *            The name for this server application, which is used for
 	 *            logging purposes only. May neither be <code>null</code> or a
-	 *            zero-length string.
+	 *            zero-length string. The name needs to be unique in this
+	 *            network.
 	 * @param serverPort
 	 *            The TCP port on which the server will wait for incoming
 	 *            requests. May not be negative or greater than 65535.
@@ -793,17 +793,4 @@
 	 */
 	public abstract void mergeNetworks(Network remoteNetwork)
 			throws RemoteException;
-
-	/**
-	 * TODO Unconfirmed!
-	 * 
-	 * Register a listener at the network to notify about new networks.
-	 * 
-	 * @param listener
-	 *            The listener to register (groovy shell).
-	 * @throws RemoteException
-	 *             Thrown if an error occurs when accessed remotely.
-	 */
-	public abstract void addLogListener(LogListener listener)
-			throws RemoteException;
 }

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ProxyNode.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -71,7 +71,7 @@
  * 
  * @author kloesing
  */
-public interface ProxyNode extends EventSource, Remote {
+public interface ProxyNode extends Remote {
 
 	/**
 	 * Adds the entries for a hidden service to the configuration of this node.

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ServerApplication.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ServerApplication.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/ServerApplication.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -39,7 +39,7 @@
  * 
  * @author kloesing
  */
-public interface ServerApplication extends EventSource {
+public interface ServerApplication {
 
 	/**
 	 * Starts listening for incoming <code>HTTP GET</code> requests from
@@ -59,4 +59,11 @@
 	 *             Thrown if <code>listen</code> has not been invoked before.
 	 */
 	public abstract void stopListening();
+
+	/**
+	 * Returns the name of this server.
+	 * 
+	 * @return The name of this server.
+	 */
+	public abstract String getServerApplicationName();
 }

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AccessingPublicWebServerOverTor.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AccessingPublicWebServerOverTor.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AccessingPublicWebServerOverTor.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -119,15 +119,15 @@
 		EventManager manager = network.getEventManager();
 
 		// register event handler for client application events
-		manager.addEventListener(client, clientEventListener);
+		manager.addEventListener(client.getClientApplicationName(),
+				clientEventListener);
 
 		// perform at most three request with a timeout of 20 seconds each
 		client.performRequest(3, 20000, true);
 
 		// block this thread as long as client requests are running
-		manager
-				.waitForAnyOccurence(client,
-						EventType.CLIENT_REQUESTS_PERFORMED);
+		manager.waitForAnyOccurence(client.getClientApplicationName(),
+				EventType.CLIENT_REQUESTS_PERFORMED);
 
 		// wait a second before shutting down the proxy
 		try {

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPrivateTorNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPrivateTorNetwork.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPrivateTorNetwork.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -115,7 +115,7 @@
 
 		// wait for 3 minutes that the proxy has published its first RSD
 
-		if (!manager.waitForAnyOccurence(router1,
+		if (!manager.waitForAnyOccurence(router1.getNodeName(),
 				EventType.BOB_DESC_PUBLISHED_RECEIVED, 3L * 60L * 1000L)) {
 			// failed to publish an RSD
 			System.out.println("Failed to publish an RSD!");
@@ -145,16 +145,17 @@
 
 			}
 		};
-		manager.addEventListener(client, clientAndServerEventListener);
-		manager.addEventListener(server, clientAndServerEventListener);
+		manager.addEventListener(client.getClientApplicationName(),
+				clientAndServerEventListener);
+		manager.addEventListener(server.getServerApplicationName(),
+				clientAndServerEventListener);
 
 		// perform at most five request with a timeout of 45 seconds each
 		client.performRequest(5, 45000, true);
 
 		// wait for request to be performed
-		manager
-				.waitForAnyOccurence(client,
-						EventType.CLIENT_REQUESTS_PERFORMED);
+		manager.waitForAnyOccurence(client.getClientApplicationName(),
+				EventType.CLIENT_REQUESTS_PERFORMED);
 
 		// shut down nodes
 		network.shutdownNodes();

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPublicTorNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPublicTorNetwork.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingAndAccessingHiddenServiceOverPublicTorNetwork.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -102,7 +102,7 @@
 		EventManager manager = network.getEventManager();
 
 		// wait for 3 minutes that the proxy has published its first RSD
-		if (!manager.waitForAnyOccurence(proxy1,
+		if (!manager.waitForAnyOccurence(proxy1.getNodeName(),
 				EventType.BOB_DESC_PUBLISHED_RECEIVED, 3L * 60L * 1000L)) {
 
 			// failed to publish an RSD
@@ -152,8 +152,10 @@
 		};
 
 		// register event handler for client and server application events
-		manager.addEventListener(client, clientAndServerEventListener);
-		manager.addEventListener(server, clientAndServerEventListener);
+		manager.addEventListener(client.getClientApplicationName(),
+				clientAndServerEventListener);
+		manager.addEventListener(server.getServerApplicationName(),
+				clientAndServerEventListener);
 
 		// start server
 		server.listen();
@@ -162,9 +164,8 @@
 		client.performRequest(5, 45000, true);
 
 		// block this thread as long as client requests are running
-		manager
-				.waitForAnyOccurence(client,
-						EventType.CLIENT_REQUESTS_PERFORMED);
+		manager.waitForAnyOccurence(client.getClientApplicationName(),
+				EventType.CLIENT_REQUESTS_PERFORMED);
 
 		// shut down proxy
 		network.shutdownNodes();

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingHiddenServiceToPublicTorNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingHiddenServiceToPublicTorNetwork.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/AdvertisingHiddenServiceToPublicTorNetwork.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -102,7 +102,7 @@
 		EventManager manager = network.getEventManager();
 
 		// register event handler for proxy events
-		manager.addEventListener(proxy, proxyEventListener);
+		manager.addEventListener(proxy.getNodeName(), proxyEventListener);
 
 		// start proxy node and wait until it has opened a circuit with a
 		// timeout of 5 seconds

Deleted: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/LogListener.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/LogListener.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/LogListener.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2007, Patrick Geyer, Johannes Jungkunst, Karsten Loesing,
- * Stefan Schilling
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * 
- *     * Neither the names of the copyright owners nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- *  
- * WARNING! This class is untested, yet! Don't rely on it!
- *
- */
-package de.uniba.wiai.lspi.puppetor.groovy;
-
-import de.uniba.wiai.lspi.puppetor.EventListener;
-
-/**
- * TODO Unconfirmed
- * 
- * The interface realizes the observer pattern to notify the groovy shell about
- * new networks.
- * 
- * @author pgeyer, jjungkunst, sschilling
- */
-public interface LogListener {
-
-	/**
-	 * Creates a new tab in groovy shell.
-	 * 
-	 * @param tabName
-	 *            The name of the new tab.
-	 */
-	public abstract EventListener addLogTab(String tabName);
-
-	public abstract void printToConsoleTab(String stringToPrint);
-
-}

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/RmiPuppetzShell.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/RmiPuppetzShell.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/groovy/RmiPuppetzShell.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -73,7 +73,7 @@
  * 
  * @author pgeyer, jjungkunst, sschilling
  */
-public class RmiPuppetzShell extends JFrame implements LogListener {
+public class RmiPuppetzShell extends JFrame {
 
 	/**
 	 * The shell that evaluates the groovy commands.
@@ -112,12 +112,6 @@
 	private JSplitPane jSplitPane = null;
 
 	/**
-	 * The String representation to which the MetaNetwork will be bound in the
-	 * groovy environment.
-	 */
-	private String bindingName = "metaNetwork";
-
-	/**
 	 * The tabbedpane that provides tabs for the different networks and the
 	 * console
 	 */
@@ -157,23 +151,21 @@
 		// binds network on the shell
 		try {
 			shell.setVariable("shell", this);
-			consoleJTextArea.append("Network bound to: " + "shell" + "\n");
+			consoleJTextArea.append("Welcome, type \"shell.[method]\" to use!"
+					+ "\n");
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
 	}
 
 	/**
-	 * Lookup the already running metaNetwork.
+	 * Lookup an already running network.
 	 * 
 	 * @param remoteHost
 	 *            The IpAddress where the RMI registry is running.
 	 * @param bindingName
 	 *            The name whereby the stub is bound.
-	 * @throws NotBoundException
-	 * @throws RemoteException
 	 * @throws MalformedURLException
-	 * @throws MalformedURLException
 	 *             Thrown to indicate that a malformed URL has occurred. Either
 	 *             no legal protocol could be found in a specification string or
 	 *             the string could not be parsed.
@@ -191,12 +183,8 @@
 		Network network = (Network) Naming.lookup("rmi://" + remoteHost + "/"
 				+ bindingName);
 
-		// adds the listener to the network
-		try {
-			network.addLogListener(this);
-		} catch (RemoteException e) {
-			e.printStackTrace();
-		}
+		// register eventlistener
+		network.getEventManager().addEventListener(addLogTab(bindingName));
 
 		// binds network on the shell
 		try {
@@ -208,8 +196,7 @@
 	}
 
 	/**
-	 * This method initializes the window. The metaNetwork is bound to
-	 * <code>bindingName<code>.
+	 * This method initializes the window.
 	 */
 	private void initialize() {
 		this.setSize(new Dimension(531, 256));
@@ -398,8 +385,4 @@
 		}
 		return elStub;
 	}
-
-	public void printToConsoleTab(String stringToPrint) {
-		this.consoleJTextArea.append(stringToPrint + "\n");
-	}
 }

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ClientApplicationImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ClientApplicationImpl.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ClientApplicationImpl.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -154,7 +154,8 @@
 					// send event to event manager
 					eventManager.observeInternalEvent(
 							timeBeforeConnectionAttempt,
-							ClientApplicationImpl.this,
+							ClientApplicationImpl.this
+									.getClientApplicationName(),
 							EventType.CLIENT_SENDING_REQUEST,
 							"Sending request.");
 
@@ -182,7 +183,8 @@
 						// send event to event manager
 						eventManager.observeInternalEvent(System
 								.currentTimeMillis(),
-								ClientApplicationImpl.this,
+								ClientApplicationImpl.this
+								.getClientApplicationName(),
 								EventType.CLIENT_REPLY_RECEIVED,
 								"Received response.");
 
@@ -206,7 +208,8 @@
 						// send event to event manager
 						eventManager.observeInternalEvent(System
 								.currentTimeMillis(),
-								ClientApplicationImpl.this,
+								ClientApplicationImpl.this
+								.getClientApplicationName(),
 								EventType.CLIENT_GAVE_UP_REQUEST,
 								"Giving up request.");
 
@@ -222,7 +225,8 @@
 						// send event to event manager
 						eventManager.observeInternalEvent(System
 								.currentTimeMillis(),
-								ClientApplicationImpl.this,
+								ClientApplicationImpl.this
+								.getClientApplicationName(),
 								EventType.CLIENT_GAVE_UP_REQUEST,
 								"Giving up request.");
 
@@ -270,7 +274,8 @@
 
 				// send event to event manager
 				eventManager.observeInternalEvent(System.currentTimeMillis(),
-						ClientApplicationImpl.this,
+						ClientApplicationImpl.this
+						.getClientApplicationName(),
 						EventType.CLIENT_REQUESTS_PERFORMED,
 						"Requests performed.");
 
@@ -464,7 +469,7 @@
 				+ ", socksPort=" + this.socksPort;
 	}
 
-	public String getName() {
-		return this.clientApplicationName;
+	public String getClientApplicationName() {
+		return clientApplicationName;
 	}
 }

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/DirectoryNodeImpl.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -48,6 +48,7 @@
  * 
  * @author karsten
  */
+ at SuppressWarnings("serial")
 public class DirectoryNodeImpl extends RouterNodeImpl implements DirectoryNode {
 
 	/**

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventImpl.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventImpl.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -34,7 +34,6 @@
 import java.util.Date;
 
 import de.uniba.wiai.lspi.puppetor.Event;
-import de.uniba.wiai.lspi.puppetor.EventSource;
 import de.uniba.wiai.lspi.puppetor.EventType;
 
 /**
@@ -42,12 +41,13 @@
  * 
  * @author kloesing
  */
+ at SuppressWarnings("serial")
 public class EventImpl implements Event {
 
 	/**
 	 * The source of this event.
 	 */
-	private EventSource source;
+	private String source;
 
 	/**
 	 * The type of this event.
@@ -79,7 +79,7 @@
 	 *            Either the log message that led to firing this event, or an
 	 *            internal message.
 	 */
-	EventImpl(long occurrenceTime, EventSource source, EventType type,
+	EventImpl(long occurrenceTime, String source, EventType type,
 			String message) {
 		// time may be 0 and type null
 		this.occurrenceTime = occurrenceTime;
@@ -88,7 +88,7 @@
 		this.message = message;
 	}
 
-	public EventSource getSource() {
+	public String getSource() {
 		return this.source;
 	}
 

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventManagerImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventManagerImpl.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/EventManagerImpl.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -53,19 +53,19 @@
 import de.uniba.wiai.lspi.puppetor.Event;
 import de.uniba.wiai.lspi.puppetor.EventListener;
 import de.uniba.wiai.lspi.puppetor.EventManager;
-import de.uniba.wiai.lspi.puppetor.EventSource;
 import de.uniba.wiai.lspi.puppetor.EventType;
 
 /**
  * Implementation of <code>EventManager</code>.
  */
+ at SuppressWarnings("serial")
 public class EventManagerImpl extends UnicastRemoteObject implements
 		EventManager {
 
 	/**
 	 * Registered event handlers for specific sources.
 	 */
-	private Map<EventSource, Set<EventListener>> eventHandlers;
+	private Map<String, Set<EventListener>> eventHandlers;
 
 	/**
 	 * Registered event handlers for all sources.
@@ -81,9 +81,15 @@
 	/**
 	 * Events observed so far.
 	 */
-	private Map<EventSource, List<Event>> observedEvents;
+	private Map<String, List<Event>> observedEvents;
 
 	/**
+	 * Set of all registered event sources. This is required to cross-check
+	 * requests for events from a given source to avoid typos.
+	 */
+	private Set<String> eventSources;
+
+	/**
 	 * Creates a new <code>EventManagerImpl</code> for the network with name
 	 * <code>networkName</code> and initializes it.
 	 * 
@@ -110,9 +116,10 @@
 				networkName);
 
 		// create data structures
-		this.observedEvents = new HashMap<EventSource, List<Event>>();
-		this.eventHandlers = new HashMap<EventSource, Set<EventListener>>();
+		this.observedEvents = new HashMap<String, List<Event>>();
+		this.eventHandlers = new HashMap<String, Set<EventListener>>();
 		this.eventHandlersForAllSources = new HashSet<EventListener>();
+		this.eventSources = new HashSet<String>();
 
 		// start thread to parse events
 		Thread eventParseThread = new Thread() {
@@ -133,7 +140,7 @@
 		this.logger.exiting(this.getClass().getName(), "EventManagerImpl");
 	}
 
-	public synchronized List<Event> addEventListener(EventSource source,
+	public synchronized List<Event> addEventListener(String source,
 			EventListener listener) {
 
 		// log entering
@@ -141,7 +148,8 @@
 				new Object[] { source, listener });
 
 		// check parameters
-		if (source == null || listener == null) {
+		if (source == null || listener == null
+				|| !this.eventSources.contains(source)) {
 			IllegalArgumentException e = new IllegalArgumentException();
 			this.logger.throwing(this.getClass().getName(), "addEventListener",
 					e);
@@ -192,14 +200,14 @@
 		return;
 	}
 
-	public synchronized List<Event> getEventHistory(EventSource source) {
+	public synchronized List<Event> getEventHistory(String source) {
 
 		// log entering
 		this.logger.entering(this.getClass().getName(), "getEventHistory",
 				source);
 
 		// check parameter
-		if (source == null) {
+		if (source == null || !this.eventSources.contains(source)) {
 			IllegalArgumentException e = new IllegalArgumentException();
 			this.logger.throwing(this.getClass().getName(), "getEventHistory",
 					e);
@@ -221,15 +229,15 @@
 		return result;
 	}
 
-	public synchronized boolean hasEventOccured(EventSource source,
-			EventType type) {
+	public synchronized boolean hasEventOccured(String source, EventType type) {
 
 		// log entering
 		this.logger.entering(this.getClass().getName(), "hasEventOccured",
 				new Object[] { source, type });
 
 		// check parameters
-		if (source == null || type == null) {
+		if (source == null || type == null
+				|| !this.eventSources.contains(source)) {
 			IllegalArgumentException e = new IllegalArgumentException();
 			this.logger.throwing(this.getClass().getName(), "hasEventOccured",
 					e);
@@ -259,6 +267,8 @@
 	private List<EventImpl> unparsedLogStatements = new LinkedList<EventImpl>();
 
 	/**
+	 * TODO document me
+	 * 
 	 * stores either events produced by ourself or unparsed Tor log events for
 	 * later parsing by a background thread in invocation order
 	 * 
@@ -266,9 +276,21 @@
 	 * contain anything of interest, the event will be discarded
 	 * 
 	 * @param source
+	 *            The event source.
 	 * @param logMessage
+	 *            The log message.
+	 * @throws IllegalArgumentException
+	 *             Thrown if the source is unknown.
 	 */
-	synchronized void observeUnparsedEvent(EventSource source, String logMessage) {
+	synchronized void observeUnparsedEvent(String source, String logMessage) {
+
+		if (!this.eventSources.contains(source)) {
+			IllegalArgumentException e = new IllegalArgumentException();
+			this.logger.throwing(this.getClass().getName(),
+					"observeInternalEvent", e);
+			throw e;
+		}
+
 		this.unparsedLogStatements.add(new EventImpl(0, source, null,
 				logMessage));
 		notifyAll();
@@ -285,9 +307,19 @@
 	 *            The event type.
 	 * @param message
 	 *            The event message.
+	 * @throws IllegalArgumentException
+	 *             Thrown if the source is unknown.
 	 */
-	synchronized void observeInternalEvent(long occurrenceTime,
-			EventSource source, EventType type, String message) {
+	synchronized void observeInternalEvent(long occurrenceTime, String source,
+			EventType type, String message) {
+
+		if (!this.eventSources.contains(source)) {
+			IllegalArgumentException e = new IllegalArgumentException();
+			this.logger.throwing(this.getClass().getName(),
+					"observeInternalEvent", e);
+			throw e;
+		}
+
 		this.unparsedLogStatements.add(new EventImpl(occurrenceTime, source,
 				type, message));
 		notifyAll();
@@ -435,7 +467,7 @@
 	 */
 	synchronized void observeEvent(Event event) {
 
-		EventSource source = event.getSource();
+		String source = event.getSource();
 
 		// log entering
 		this.logger.entering(this.getClass().getName(), "observeEvent",
@@ -535,15 +567,15 @@
 		this.logger.exiting(this.getClass().getName(), "removeEventListener");
 	}
 
-	public synchronized void waitForAnyOccurence(EventSource source,
-			EventType event) {
+	public synchronized void waitForAnyOccurence(String source, EventType event) {
 
 		// log entering
 		this.logger.entering(this.getClass().getName(), "waitForAnyOccurence",
 				new Object[] { source, event });
 
 		// check parameters
-		if (source == null || event == null) {
+		if (source == null || event == null
+				|| !this.eventSources.contains(source)) {
 			IllegalArgumentException e = new IllegalArgumentException();
 			this.logger.throwing(this.getClass().getName(),
 					"waitForAnyOccurence", e);
@@ -559,7 +591,7 @@
 
 	}
 
-	public synchronized boolean waitForAnyOccurence(EventSource source,
+	public synchronized boolean waitForAnyOccurence(String source,
 			EventType event, long maximumTimeToWaitInMillis) {
 
 		// log entering
@@ -567,7 +599,8 @@
 				new Object[] { source, event, maximumTimeToWaitInMillis });
 
 		// check parameters
-		if (source == null || event == null) {
+		if (source == null || event == null
+				|| !this.eventSources.contains(source)) {
 			IllegalArgumentException e = new IllegalArgumentException();
 			this.logger.throwing(this.getClass().getName(),
 					"waitForAnyOccurence", e);
@@ -593,15 +626,15 @@
 		return result;
 	}
 
-	public synchronized void waitForNextOccurence(EventSource source,
-			EventType event) {
+	public synchronized void waitForNextOccurence(String source, EventType event) {
 
 		// log entering
 		this.logger.entering(this.getClass().getName(), "waitForNextOccurence",
 				new Object[] { source, event });
 
 		// check parameters
-		if (source == null || event == null) {
+		if (source == null || event == null
+				|| !this.eventSources.contains(source)) {
 			IllegalArgumentException e = new IllegalArgumentException();
 			this.logger.throwing(this.getClass().getName(),
 					"waitForNextOccurence", e);
@@ -616,7 +649,7 @@
 		this.logger.exiting(this.getClass().getName(), "waitForNextOccurence");
 	}
 
-	public synchronized boolean waitForNextOccurence(EventSource source,
+	public synchronized boolean waitForNextOccurence(String source,
 			EventType type, long maximumTimeToWaitInMillis) {
 
 		// log entering
@@ -624,7 +657,8 @@
 				new Object[] { source, type, maximumTimeToWaitInMillis });
 
 		// check parameters
-		if (source == null || type == null) {
+		if (source == null || type == null
+				|| !this.eventSources.contains(source)) {
 			IllegalArgumentException e = new IllegalArgumentException();
 			this.logger.throwing(this.getClass().getName(),
 					"waitForNextOccurence", e);
@@ -706,4 +740,13 @@
 		}
 	}
 
+	/**
+	 * Adds the given <code>name</code> as possible event source.
+	 * 
+	 * @param name
+	 *            The name of the node, client, or server to add.
+	 */
+	void addEventSource(String name) {
+		this.eventSources.add(name);
+	}
 }

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -40,7 +40,6 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -61,13 +60,13 @@
 import de.uniba.wiai.lspi.puppetor.RouterNode;
 import de.uniba.wiai.lspi.puppetor.ServerApplication;
 import de.uniba.wiai.lspi.puppetor.TorProcessException;
-import de.uniba.wiai.lspi.puppetor.groovy.LogListener;
 
 /**
  * Implementation of <code>Network</code>.
  * 
  * @author kloesing
  */
+ at SuppressWarnings("serial")
 public class NetworkImpl extends UnicastRemoteObject implements Network {
 
 	/**
@@ -242,13 +241,41 @@
 	private NetworkState networkState = NetworkState.CONFIGURING_NODES;
 
 	/**
+	 * All clients contained in this network. It is important that we store and
+	 * work only with interface types to assure that all operations could also
+	 * be performed by the application itself.
+	 */
+	private Map<String, ClientApplication> clients = new HashMap<String, ClientApplication>();
+
+	/**
+	 * All servers contained in this network. It is important that we store and
+	 * work only with interface types to assure that all operations could also
+	 * be performed by the application itself.
+	 */
+	private Map<String, ServerApplication> servers = new HashMap<String, ServerApplication>();
+
+	/**
 	 * All nodes contained in this network. It is important that we store and
 	 * work only with interface types to assure that all operations could also
 	 * be performed by the application itself.
 	 */
-	private HashMap<String, ProxyNode> nodes = new HashMap<String, ProxyNode>();
+	private Map<String, ProxyNode> nodes = new HashMap<String, ProxyNode>();
 
 	/**
+	 * Determines if the given <code>name</code> is unique in this network.
+	 * 
+	 * @param name
+	 *            Name to look up.
+	 * @return <code>true</code> if no entity was created with this name,
+	 *         <code>false</code> otherwise.
+	 */
+	private boolean isLocallyUnique(String name) {
+		return (!this.clients.containsKey(name)
+				&& !this.servers.containsKey(name) && !this.nodes
+				.containsKey(name));
+	}
+
+	/**
 	 * Directory that contains status information of all nodes contained in this
 	 * network.
 	 */
@@ -364,7 +391,7 @@
 
 		// fail on first node that is not up
 		for (ProxyNode node : this.nodes.values()) {
-			if (!eventManager.hasEventOccured(node,
+			if (!eventManager.hasEventOccured(node.getNodeName(),
 					EventType.NODE_CIRCUIT_OPENED)) {
 
 				// log exiting and return false
@@ -475,10 +502,25 @@
 				new Object[] { clientApplicationName, targetAddress,
 						targetPort, socksPort });
 
+		// check if client name is locally unique
+		if (!this.isLocallyUnique(clientApplicationName)) {
+			IllegalArgumentException e = new IllegalArgumentException(
+					"There is already an entity with name "
+							+ clientApplicationName + " in this network!");
+			this.logger.throwing(this.getClass().getName(), "createClient", e);
+			throw e;
+		}
+
 		// create client; parameter checking is done in constructor
 		ClientApplicationImpl client = new ClientApplicationImpl(this,
 				clientApplicationName, targetAddress, targetPort, socksPort);
 
+		// add new client to clients collection
+		this.clients.put(clientApplicationName, client);
+
+		// add name to event manager as event source
+		this.eventManager.addEventSource(clientApplicationName);
+		
 		// log exiting and return client
 		this.logger.exiting(this.getClass().getName(), "createClient", client);
 		return client;
@@ -501,10 +543,11 @@
 			throw e;
 		}
 
-		// check if there is already a node with this name
-		if (this.nodes.containsKey(nodeName)) {
+		// check if node name is locally unique
+		if (!this.isLocallyUnique(nodeName)) {
 			IllegalArgumentException e = new IllegalArgumentException(
-					"There is already a node with name " + nodeName);
+					"There is already an entity with name " + nodeName
+							+ " in this network!");
 			this.logger.throwing(this.getClass().getName(), "createDirectory",
 					e);
 			throw e;
@@ -516,7 +559,10 @@
 
 		// add new directory node to nodes collection
 		this.nodes.put(nodeName, dir);
-
+		
+		// add name to event manager as event source
+		this.eventManager.addEventSource(nodeName);
+		
 		// log exiting and return directory node
 		this.logger.exiting(this.getClass().getName(), "createDirectory", dir);
 		return dir;
@@ -580,10 +626,11 @@
 		this.logger.entering(this.getClass().getName(), "createProxy",
 				new Object[] { nodeName, controlPort, socksPort });
 
-		// check if there is already a node with this name
-		if (this.nodes.containsKey(nodeName)) {
+		// check if node name is locally unique
+		if (!this.isLocallyUnique(nodeName)) {
 			IllegalArgumentException e = new IllegalArgumentException(
-					"There is already a node with name " + nodeName);
+					"There is already an entity with name " + nodeName
+							+ " in this network!");
 			this.logger.throwing(this.getClass().getName(), "createProxy", e);
 			throw e;
 		}
@@ -595,6 +642,9 @@
 		// add new proxy node to nodes collection
 		this.nodes.put(nodeName, proxy);
 
+		// add name to event manager as event source
+		this.eventManager.addEventSource(nodeName);
+		
 		// log exiting and return proxy node
 		this.logger.exiting(this.getClass().getName(), "createProxy", proxy);
 		return proxy;
@@ -624,14 +674,14 @@
 				new Object[] { nodeName, controlPort, socksPort, orPort,
 						dirPort, serverIpAddress });
 
-		// check if there is already a node with this name
-		if (this.nodes.containsKey(nodeName)) {
+		// check if node name is locally unique
+		if (!this.isLocallyUnique(nodeName)) {
 			IllegalArgumentException e = new IllegalArgumentException(
-					"There is already a node with name " + nodeName);
+					"There is already an entity with name " + nodeName
+							+ " in this network!");
 			this.logger.throwing(this.getClass().getName(), "createRouter", e);
 			throw e;
 		}
-
 		// create router node; parameter checking is done in constructor
 		RouterNode router = new RouterNodeImpl(this, nodeName, controlPort,
 				socksPort, orPort, dirPort, serverIpAddress);
@@ -639,6 +689,9 @@
 		// add new router node to nodes collection
 		this.nodes.put(nodeName, router);
 
+		// add name to event manager as event source
+		this.eventManager.addEventSource(nodeName);
+		
 		// log exiting and return router node
 		this.logger.exiting(this.getClass().getName(), "createRouter", router);
 		return router;
@@ -701,10 +754,25 @@
 		this.logger.entering(this.getClass().getName(), "createServer",
 				new Object[] { serverApplicationName, serverPort });
 
+		// check if server name is locally unique
+		if (!this.isLocallyUnique(serverApplicationName)) {
+			IllegalArgumentException e = new IllegalArgumentException(
+					"There is already an entity with name "
+							+ serverApplicationName + " in this network!");
+			this.logger.throwing(this.getClass().getName(), "createServer", e);
+			throw e;
+		}
+
 		// create server; parameter checking is done in constructor
 		ServerApplicationImpl server = new ServerApplicationImpl(this,
 				serverApplicationName, serverPort);
 
+		// add new server to servers collection
+		this.servers.put(serverApplicationName, server);
+
+		// add name to event manager as event source
+		this.eventManager.addEventSource(serverApplicationName);
+		
 		// log exiting and return server
 		this.logger.exiting(this.getClass().getName(), "createServer", server);
 		return server;
@@ -818,14 +886,15 @@
 		// create and register a new event handler for each node
 		final Thread sleepingThread = Thread.currentThread();
 		for (ProxyNode node : this.nodes.values()) {
-			eventManager.addEventListener(node, new EventListener() {
-				public void handleEvent(Event event) {
-					if (event.getType() == EventType.NODE_CIRCUIT_OPENED) {
-						sleepingThread.interrupt();
-						eventManager.removeEventListener(this);
-					}
-				}
-			});
+			eventManager.addEventListener(node.getNodeName(),
+					new EventListener() {
+						public void handleEvent(Event event) {
+							if (event.getType() == EventType.NODE_CIRCUIT_OPENED) {
+								sleepingThread.interrupt();
+								eventManager.removeEventListener(this);
+							}
+						}
+					});
 		}
 
 		// walk through wait-check-hup loop until there are no tries left
@@ -1068,26 +1137,16 @@
 
 	/* ***** TODO The following code is still unconfirmed!! ***** */
 
-	/**
-	 * Collection of all registered listeners.
-	 */
-	private List<LogListener> listeners = new LinkedList<LogListener>();
+	public void addEventListener(EventListener listener) throws RemoteException {
 
-	/**
-	 * Collection of all connected networks.
-	 */
-	private HashMap<String, Network> allNetworks = new HashMap<String, Network>();
-
-	public void addLogListener(LogListener listener) {
-
 		// log entering
-		logger.entering(this.getClass().getName(), "addLogListener");
+		logger.entering(this.getClass().getName(), "addEventListener");
 
-		// adds the listener to the local collection
-		this.listeners.add(listener);
+		// register the listener
+		this.eventManager.addEventListener(listener);
 
 		// log exiting
-		logger.exiting(this.getClass().getName(), "addLogListener");
+		logger.exiting(this.getClass().getName(), "addEventListener");
 	}
 
 	public Network connectNetwork(String remoteHost, String bindingName)
@@ -1100,16 +1159,6 @@
 		Network network = (Network) Naming.lookup("rmi://" + remoteHost + "/"
 				+ bindingName);
 
-		// add the network to the allNetworks collection
-		allNetworks.put(bindingName, network);
-
-		// nodify the grooy shell about the new network and register
-		// eventlistener
-		// only if at least one listener is available
-		if (listeners.size() != 0) {
-			notifyListener(network.getEventManager(), bindingName);
-		}
-
 		// log exiting
 		logger.exiting(this.getClass().getName(), "connectNetwork");
 		return network;
@@ -1322,24 +1371,4 @@
 		// log exiting
 		logger.exiting(this.getClass().getName(), "hupRouters");
 	}
-
-	private void notifyListener(EventManager manager, String tabName) {
-
-		// log entering
-		logger.entering(this.getClass().getName(), "notifyListener");
-
-		for (LogListener listener : listeners) {
-			EventListener tabListener = listener.addLogTab(tabName);
-			try {
-				// adds listener to eventmanager
-				manager.addEventListener(tabListener);
-
-				// log exiting
-				logger.exiting(this.getClass().getName(), "notifyListener");
-			} catch (RemoteException e) {
-				logger.log(Level.SEVERE,
-						"Caught a remote exception while notifyListener!");
-			}
-		}
-	}
 }

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ProxyNodeImpl.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -59,6 +59,7 @@
  * 
  * @author kloesing
  */
+ at SuppressWarnings("serial")
 public class ProxyNodeImpl extends UnicastRemoteObject implements ProxyNode {
 
 	/**
@@ -639,8 +640,8 @@
 		this.nodeState = NodeState.SHUT_DOWN;
 
 		// fire event
-		eventManager.observeInternalEvent(System.currentTimeMillis(), this,
-				EventType.NODE_STOPPED, "Node stopped.");
+		eventManager.observeInternalEvent(System.currentTimeMillis(), this
+				.getNodeName(), EventType.NODE_STOPPED, "Node stopped.");
 
 		// log exiting
 		this.logger.exiting(this.getClass().getName(), "shutdown");
@@ -754,8 +755,8 @@
 				String line = null;
 				try {
 					while ((line = br.readLine()) != null) {
-						eventManager.observeUnparsedEvent(ProxyNodeImpl.this,
-								line);
+						eventManager.observeUnparsedEvent(ProxyNodeImpl.this
+								.getNodeName(), line);
 					}
 				} catch (IOException e) {
 
@@ -818,7 +819,7 @@
 		// wait for Tor to open the control port
 		this.logger.log(Level.FINER,
 				"Waiting for Tor to open its control port...");
-		if (!this.eventManager.waitForAnyOccurence(this,
+		if (!this.eventManager.waitForAnyOccurence(this.nodeName,
 				EventType.NODE_CONTROL_PORT_OPENED, maximumTimeToWaitInMillis)) {
 
 			// Tor did not open its control port
@@ -853,8 +854,8 @@
 		this.nodeState = NodeState.RUNNING;
 
 		// fire event
-		eventManager.observeInternalEvent(System.currentTimeMillis(), this,
-				EventType.NODE_STARTED, "Node started.");
+		eventManager.observeInternalEvent(System.currentTimeMillis(), this
+				.getNodeName(), EventType.NODE_STARTED, "Node started.");
 
 		// log exiting and return with success
 		this.logger.exiting(this.getClass().getName(), "startNode", true);
@@ -924,10 +925,6 @@
 				.exiting(this.getClass().getName(), "writeConfigurationFile");
 	}
 
-	public String getName() {
-		return this.nodeName;
-	}
-
 	public int getSocksPort() {
 		return this.socksPort;
 	}

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/RouterNodeImpl.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -52,6 +52,7 @@
  * @author kloesing
  * 
  */
+ at SuppressWarnings("serial")
 public class RouterNodeImpl extends ProxyNodeImpl implements RouterNode {
 
 	/**

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/ServerApplicationImpl.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -95,7 +95,7 @@
 
 				// send event to event manager
 				eventManager.observeInternalEvent(System.currentTimeMillis(),
-						ServerApplicationImpl.this,
+						ServerApplicationImpl.this.getServerApplicationName(),
 						EventType.SERVER_RECEIVING_REQUEST_SENDING_REPLY,
 						"Receiving request.");
 
@@ -361,7 +361,7 @@
 				+ this.serverPort;
 	}
 
-	public String getName() {
+	public String getServerApplicationName() {
 		return this.serverApplicationName;
 	}
 }

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithOutDir.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithOutDir.java	2007-09-25 15:19:10 UTC (rev 11632)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/rmi/MergingNetworkWithOutDir.java	2007-09-25 15:28:58 UTC (rev 11633)
@@ -244,6 +244,7 @@
 
 		try {
 			// collects the dirNetwork stub
+			// TODO make this configurable
 			Network dirNetwork = network.connectNetwork("192.168.1.10", "with");
 			System.out.println("Network with connected ...");
 



More information about the tor-commits mailing list