5 |
|
import uk.ac.ukc.iscream.core.*; |
6 |
|
import uk.ac.ukc.iscream.util.*; |
7 |
|
import uk.ac.ukc.iscream.componentmanager.*; |
8 |
– |
import java.util.LinkedList; |
9 |
– |
import java.util.Iterator; |
8 |
|
|
9 |
|
/** |
10 |
< |
* A client interface servant |
11 |
< |
* This keeps a track of all connected clients to |
12 |
< |
* the system and passes data to their handlers. |
10 |
> |
* This class, a servant, listens for incoming data sent to it |
11 |
> |
* using CORBA. This data is then queued in the PacketSorter. |
12 |
> |
* It does no processing of the data, and is only a seperate |
13 |
> |
* class to keep the CORBA stuff out of the PacketSorter. |
14 |
|
* |
16 |
– |
* Currently it has limited client management facilities. |
17 |
– |
* |
15 |
|
* @author $Author$ |
16 |
|
* @version $Id$ |
17 |
|
*/ |
30 |
|
|
31 |
|
/** |
32 |
|
* Creates a new ClientInterfaceServant. |
33 |
+ |
* |
34 |
+ |
* @param packetSorter a reference to the PacketSorter object being used |
35 |
|
*/ |
36 |
< |
public ClientInterfaceServant() { |
37 |
< |
// here would be a nice place to pass in local clients |
39 |
< |
_clients = new LinkedList(); |
36 |
> |
public ClientInterfaceServant(PacketSorter packetSorter) { |
37 |
> |
_queue = packetSorter.getQueue(); |
38 |
|
_logger.write(toString(), Logger.SYSINIT, "created"); |
39 |
|
} |
40 |
|
|
41 |
|
//---PUBLIC METHODS--- |
42 |
|
|
43 |
|
/** |
44 |
< |
* Method to receive a string over corba. |
44 |
> |
* Method to receive a string over CORBA. |
45 |
|
* |
46 |
< |
* @param xml the String of XML to print out |
46 |
> |
* @param xml the XML string to be queued for processing. |
47 |
|
*/ |
48 |
|
public void receiveXML(String xml) { |
49 |
< |
Iterator i = _clients.iterator(); |
52 |
< |
while(i.hasNext()) { |
53 |
< |
((ClientDataHandler) i.next()).receiveXML(xml); |
54 |
< |
} |
49 |
> |
_queue.add(xml); |
50 |
|
} |
51 |
|
|
52 |
|
/** |
58 |
– |
* Simply adds clients to a linked list |
59 |
– |
* |
60 |
– |
* @param newClient a reference to the client to add |
61 |
– |
*/ |
62 |
– |
public void register(ClientDataHandler newClient) { |
63 |
– |
_logger.write(toString(), Logger.SYSMSG, "registered client - " + newClient.toString()); |
64 |
– |
_clients.add(newClient); |
65 |
– |
} |
66 |
– |
|
67 |
– |
/** |
68 |
– |
* Simply removes a client from a linked list |
69 |
– |
* |
70 |
– |
* @param client a reference to the client to be removed |
71 |
– |
*/ |
72 |
– |
public void deregister(ClientDataHandler client) { |
73 |
– |
_logger.write(toString(), Logger.SYSMSG, "deregistered client - " + client.toString()); |
74 |
– |
_clients.remove(client); |
75 |
– |
} |
76 |
– |
|
77 |
– |
/** |
53 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
54 |
|
* method to provide clean logging (every class should have this). |
55 |
|
* |
88 |
|
*/ |
89 |
|
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
90 |
|
|
91 |
< |
private LinkedList _clients; |
91 |
> |
/** |
92 |
> |
* A reference to the Queue we'll add data to. This is |
93 |
> |
* actually located in the PacketSorter. |
94 |
> |
*/ |
95 |
> |
private Queue _queue; |
96 |
|
|
97 |
|
//---STATIC ATTRIBUTES--- |
98 |
|
|