View Javadoc

1   package nl.tudelft.goal.ut2004.visualizer.connection;
2   
3   import java.rmi.RemoteException;
4   import java.rmi.server.UnicastRemoteObject;
5   
6   import cz.cuni.amis.pogamut.base.agent.IAgentId;
7   import eis.exceptions.ManagementException;
8   
9   /**
10   * Acts as a client for the visualizer. Mediates the interaction between the
11   * actual client and the visualizer by providing listeners.
12   * 
13   * @author M.P. Korstanje
14   * @param <VisualizerClientListener>
15   * 
16   */
17  public final class EnvironmentServiceMediator extends UnicastRemoteObject
18  		implements EnvironmentService {
19  
20  	/**
21  	 * Serial Version UID
22  	 */
23  	private static final long serialVersionUID = 201210291347L;
24  	
25  	private final IAgentId id;
26  	private EnvironmentServiceListener listener;
27  
28  	public EnvironmentServiceMediator(IAgentId id) throws RemoteException {
29  		this.id = id;
30  	}
31  
32  	public void setListener(EnvironmentServiceListener listener) {
33  		this.listener = listener;
34  	}
35  
36  	public void removeListener() {
37  		listener = null;
38  	}
39  
40  	@Override
41  	public void addBot(AddBotCommand parameters) throws RemoteException,
42  			ManagementException {
43  		listener.addBot(parameters);
44  	}
45  
46  	@Override
47  	public IAgentId getAgentId() throws RemoteException {
48  		return id;
49  	}
50  
51  	public String toString(){
52  		String name = id.getToken();
53  		return name;
54  	}
55  }