1 |
//---PACKAGE DECLARATION--- |
2 |
package uk.ac.ukc.iscream.filter; |
3 |
|
4 |
//---IMPORTS--- |
5 |
import uk.ac.ukc.iscream.core.*; |
6 |
import uk.ac.ukc.iscream.componentmanager.*; |
7 |
import uk.ac.ukc.iscream.filter.*; |
8 |
import uk.ac.ukc.iscream.util.*; |
9 |
import java.net.InetAddress; |
10 |
|
11 |
/** |
12 |
* Passes inbound data from other Filters to a FilterThread |
13 |
* |
14 |
* @author $Author: tdb1 $ |
15 |
* @version $Id: FilterServant.java,v 1.12 2001/01/12 00:45:25 tdb1 Exp $ |
16 |
*/ |
17 |
class FilterServant extends FilterPOA { |
18 |
|
19 |
//---FINAL ATTRIBUTES--- |
20 |
|
21 |
/** |
22 |
* The current CVS revision of this class |
23 |
*/ |
24 |
public final String REVISION = "$Revision: 1.12 $"; |
25 |
|
26 |
//---STATIC METHODS--- |
27 |
|
28 |
//---CONSTRUCTORS--- |
29 |
|
30 |
/** |
31 |
* Creates a new Filter. |
32 |
* |
33 |
* @param logger a Logger to use |
34 |
*/ |
35 |
public FilterServant(int TCPListenPort, int UDPListenPort, Queue queue) { |
36 |
_TCPListenPort = TCPListenPort; |
37 |
_UDPListenPort = UDPListenPort; |
38 |
_queue = queue; |
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 |
/** |
73 |
* Provides information to the FilterManager |
74 |
*/ |
75 |
public String getUDPPort() { |
76 |
return new Integer(_UDPListenPort).toString(); |
77 |
} |
78 |
|
79 |
/** |
80 |
* Provides information to the FilterManager |
81 |
*/ |
82 |
public String getTCPPort() { |
83 |
return new Integer(_TCPListenPort).toString(); |
84 |
} |
85 |
|
86 |
/** |
87 |
* Provides information to the FilterManager |
88 |
*/ |
89 |
public String getHostName() { |
90 |
try { |
91 |
return InetAddress.getLocalHost().getHostName(); |
92 |
} catch (java.net.UnknownHostException e) { |
93 |
_logger.write(toString(), Logger.ERROR, e.getMessage()); |
94 |
} |
95 |
return null; |
96 |
} |
97 |
|
98 |
|
99 |
//---ATTRIBUTES--- |
100 |
|
101 |
/** |
102 |
* This is the friendly identifier of the |
103 |
* component this class is running in. |
104 |
* eg, a Filter may be called "filter1", |
105 |
* If this class does not have an owning |
106 |
* component, a name from the configuration |
107 |
* can be placed here. This name could also |
108 |
* be changed to null for utility classes. |
109 |
*/ |
110 |
private String _name = FilterMain.NAME; |
111 |
|
112 |
/** |
113 |
* This holds a reference to the |
114 |
* system logger that is being used. |
115 |
*/ |
116 |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
117 |
|
118 |
/** |
119 |
* Our Queue object |
120 |
*/ |
121 |
private Queue _queue; |
122 |
|
123 |
/** |
124 |
* The UDP port we're listening on |
125 |
*/ |
126 |
private int _UDPListenPort; |
127 |
|
128 |
/** |
129 |
* The TCP port we're listening on |
130 |
*/ |
131 |
private int _TCPListenPort; |
132 |
|
133 |
//---STATIC ATTRIBUTES--- |
134 |
|
135 |
} |