1 |
//---PACKAGE DECLARATION--- |
2 |
package uk.ac.ukc.iscream.clientinterface; |
3 |
|
4 |
//---IMPORTS--- |
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; |
10 |
|
11 |
/** |
12 |
* A client interface servant |
13 |
* This keeps a track of all connected clients to |
14 |
* the system and passes data to their handlers. |
15 |
* |
16 |
* Currently it has limited client management facilities. |
17 |
* |
18 |
* @author $Author: tdb1 $ |
19 |
* @version $Id: ClientInterfaceServant.java,v 1.5 2001/01/18 23:07:00 tdb1 Exp $ |
20 |
*/ |
21 |
class ClientInterfaceServant extends ClientInterfacePOA { |
22 |
|
23 |
//---FINAL ATTRIBUTES--- |
24 |
|
25 |
/** |
26 |
* The current CVS revision of this class |
27 |
*/ |
28 |
public final String REVISION = "$Revision: 1.5 $"; |
29 |
|
30 |
//---STATIC METHODS--- |
31 |
|
32 |
//---CONSTRUCTORS--- |
33 |
|
34 |
/** |
35 |
* Creates a new ClientInterfaceServant. |
36 |
*/ |
37 |
public ClientInterfaceServant() { |
38 |
// here would be a nice place to pass in local clients |
39 |
_clients = new LinkedList(); |
40 |
_logger.write(toString(), Logger.SYSINIT, "created"); |
41 |
} |
42 |
|
43 |
//---PUBLIC METHODS--- |
44 |
|
45 |
/** |
46 |
* Method to receive a string over corba. |
47 |
* |
48 |
* @param xml the String of XML to print out |
49 |
*/ |
50 |
public void receiveXML(String xml) { |
51 |
Iterator i = _clients.iterator(); |
52 |
while(i.hasNext()) { |
53 |
((ClientDataHandler) i.next()).receiveXML(xml); |
54 |
} |
55 |
} |
56 |
|
57 |
/** |
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 |
/** |
78 |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
79 |
* method to provide clean logging (every class should have this). |
80 |
* |
81 |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
82 |
* to format the toString() |
83 |
* |
84 |
* @return the name of this class and its CVS revision |
85 |
*/ |
86 |
public String toString() { |
87 |
return FormatName.getName( |
88 |
_name, |
89 |
getClass().getName(), |
90 |
REVISION); |
91 |
} |
92 |
|
93 |
//---PRIVATE METHODS--- |
94 |
|
95 |
//---ACCESSOR/MUTATOR METHODS--- |
96 |
|
97 |
//---ATTRIBUTES--- |
98 |
|
99 |
/** |
100 |
* This is the friendly identifier of the |
101 |
* component this class is running in. |
102 |
* eg, a Filter may be called "filter1", |
103 |
* If this class does not have an owning |
104 |
* component, a name from the configuration |
105 |
* can be placed here. This name could also |
106 |
* be changed to null for utility classes. |
107 |
*/ |
108 |
private String _name = ClientInterfaceMain.NAME; |
109 |
|
110 |
/** |
111 |
* This holds a reference to the |
112 |
* system logger that is being used. |
113 |
*/ |
114 |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
115 |
|
116 |
private LinkedList _clients; |
117 |
|
118 |
//---STATIC ATTRIBUTES--- |
119 |
|
120 |
} |