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 java.util.LinkedList; |
8 |
< |
import java.util.Iterator; |
9 |
< |
|
10 |
< |
/** |
11 |
< |
* A client interface servant |
12 |
< |
* |
13 |
< |
* @author $Author$ |
14 |
< |
* @version $Id$ |
15 |
< |
*/ |
16 |
< |
class ClientInterfaceServant extends ClientInterfacePOA { |
17 |
< |
|
18 |
< |
//---FINAL ATTRIBUTES--- |
19 |
< |
|
20 |
< |
/** |
21 |
< |
* The current CVS revision of this class |
22 |
< |
*/ |
23 |
< |
public final String REVISION = "$Revision$"; |
24 |
< |
|
25 |
< |
//---STATIC METHODS--- |
26 |
< |
|
27 |
< |
//---CONSTRUCTORS--- |
28 |
< |
|
29 |
< |
/** |
30 |
< |
* Creates a new ClientInterfaceServant. |
31 |
< |
* |
32 |
< |
*/ |
33 |
< |
public ClientInterfaceServant() { |
34 |
< |
// here would be a nice place to pass in local clients |
35 |
< |
_clients = new LinkedList(); |
36 |
< |
_logger.write(this.toString(), Logger.SYSINIT, "created"); |
37 |
< |
} |
38 |
< |
|
39 |
< |
//---PUBLIC METHODS--- |
40 |
< |
|
41 |
< |
/** |
42 |
< |
* Method to receive a string over corba. |
43 |
< |
* |
44 |
< |
* @param xml the String of XML to print out |
45 |
< |
*/ |
46 |
< |
public void receiveXML(String xml) { |
47 |
< |
_logger.write(this.toString(), Logger.DEBUG, "got data - " + xml); |
48 |
< |
_logger.write(this.toString(), Logger.DEBUG, "passing to clients"); |
49 |
< |
Iterator i = _clients.iterator(); |
50 |
< |
while(i.hasNext()) { |
51 |
< |
((ClientHandler) i.next()).receiveXML(xml); |
52 |
< |
} |
53 |
< |
} |
54 |
< |
|
55 |
< |
public void register(ClientHandler newClient) { |
56 |
< |
_logger.write(this.toString(), Logger.SYSMSG, "registered client - " + newClient.toString()); |
57 |
< |
_clients.add(newClient); |
58 |
< |
} |
59 |
< |
|
60 |
< |
/** |
61 |
< |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
62 |
< |
* method to provide clean logging (every class should have this). |
63 |
< |
* |
64 |
< |
* @return the name of this class and its CVS revision |
65 |
< |
*/ |
66 |
< |
public String toString() { |
67 |
< |
return this.getClass().getName() + "{" + _name + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
68 |
< |
} |
69 |
< |
|
70 |
< |
//---PRIVATE METHODS--- |
71 |
< |
|
72 |
< |
//---ACCESSOR/MUTATOR METHODS--- |
73 |
< |
|
74 |
< |
//---ATTRIBUTES--- |
75 |
< |
|
76 |
< |
/** |
77 |
< |
* Reference to a Logger |
78 |
< |
*/ |
79 |
< |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
80 |
< |
|
81 |
< |
/** |
82 |
< |
* Our name |
83 |
< |
*/ |
84 |
< |
private String _name = ReferenceManager.getInstance().getName(); |
85 |
< |
|
86 |
< |
private LinkedList _clients; |
87 |
< |
|
88 |
< |
//---STATIC ATTRIBUTES--- |
89 |
< |
|
90 |
< |
} |
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 |
> |
* Adds data to a Queue as it's received over CORBA. |
14 |
> |
* |
15 |
> |
* Currently it has limited client management facilities. |
16 |
> |
* |
17 |
> |
* @author $Author$ |
18 |
> |
* @version $Id$ |
19 |
> |
*/ |
20 |
> |
class ClientInterfaceServant extends ClientInterfacePOA { |
21 |
> |
|
22 |
> |
//---FINAL ATTRIBUTES--- |
23 |
> |
|
24 |
> |
/** |
25 |
> |
* The current CVS revision of this class |
26 |
> |
*/ |
27 |
> |
public final String REVISION = "$Revision$"; |
28 |
> |
|
29 |
> |
//---STATIC METHODS--- |
30 |
> |
|
31 |
> |
//---CONSTRUCTORS--- |
32 |
> |
|
33 |
> |
/** |
34 |
> |
* Creates a new ClientInterfaceServant. |
35 |
> |
*/ |
36 |
> |
public ClientInterfaceServant(Queue queue) { |
37 |
> |
_queue = queue; |
38 |
> |
_logger.write(toString(), Logger.SYSINIT, "created"); |
39 |
> |
} |
40 |
> |
|
41 |
> |
//---PUBLIC METHODS--- |
42 |
> |
|
43 |
> |
/** |
44 |
> |
* Method to receive a string over corba. |
45 |
> |
* |
46 |
> |
* @param xml the String of XML to print out |
47 |
> |
*/ |
48 |
> |
public void receiveXML(String xml) { |
49 |
> |
_queue.add(xml); |
50 |
> |
} |
51 |
> |
|
52 |
> |
/** |
53 |
> |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
54 |
> |
* method to provide clean logging (every class should have this). |
55 |
> |
* |
56 |
> |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
57 |
> |
* to format the toString() |
58 |
> |
* |
59 |
> |
* @return the name of this class and its CVS revision |
60 |
> |
*/ |
61 |
> |
public String toString() { |
62 |
> |
return FormatName.getName( |
63 |
> |
_name, |
64 |
> |
getClass().getName(), |
65 |
> |
REVISION); |
66 |
> |
} |
67 |
> |
|
68 |
> |
//---PRIVATE METHODS--- |
69 |
> |
|
70 |
> |
//---ACCESSOR/MUTATOR METHODS--- |
71 |
> |
|
72 |
> |
//---ATTRIBUTES--- |
73 |
> |
|
74 |
> |
/** |
75 |
> |
* This is the friendly identifier of the |
76 |
> |
* component this class is running in. |
77 |
> |
* eg, a Filter may be called "filter1", |
78 |
> |
* If this class does not have an owning |
79 |
> |
* component, a name from the configuration |
80 |
> |
* can be placed here. This name could also |
81 |
> |
* be changed to null for utility classes. |
82 |
> |
*/ |
83 |
> |
private String _name = ClientInterfaceMain.NAME; |
84 |
> |
|
85 |
> |
/** |
86 |
> |
* This holds a reference to the |
87 |
> |
* system logger that is being used. |
88 |
> |
*/ |
89 |
> |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
90 |
> |
|
91 |
> |
private Queue _queue; |
92 |
> |
|
93 |
> |
//---STATIC ATTRIBUTES--- |
94 |
> |
|
95 |
> |
} |