1 |
tdb |
1.1 |
//---PACKAGE DECLARATION--- |
2 |
tdb |
1.7 |
package uk.ac.ukc.iscream.filter; |
3 |
tdb |
1.1 |
|
4 |
|
|
//---IMPORTS--- |
5 |
|
|
import uk.ac.ukc.iscream.core.*; |
6 |
tdb |
1.13 |
import uk.ac.ukc.iscream.componentmanager.*; |
7 |
tdb |
1.1 |
import uk.ac.ukc.iscream.filter.*; |
8 |
ajm |
1.10 |
import uk.ac.ukc.iscream.util.*; |
9 |
tdb |
1.4 |
import java.net.InetAddress; |
10 |
tdb |
1.1 |
|
11 |
|
|
/** |
12 |
ajm |
1.11 |
* Passes inbound data from other Filters to a FilterThread |
13 |
tdb |
1.1 |
* |
14 |
tdb |
1.13 |
* @author $Author: tdb1 $ |
15 |
tdb |
1.14 |
* @version $Id: FilterServant.java,v 1.13 2001/01/18 23:15:50 tdb1 Exp $ |
16 |
tdb |
1.1 |
*/ |
17 |
|
|
class FilterServant extends FilterPOA { |
18 |
|
|
|
19 |
|
|
//---FINAL ATTRIBUTES--- |
20 |
|
|
|
21 |
|
|
/** |
22 |
|
|
* The current CVS revision of this class |
23 |
|
|
*/ |
24 |
tdb |
1.14 |
public final String REVISION = "$Revision: 1.13 $"; |
25 |
tdb |
1.1 |
|
26 |
|
|
//---STATIC METHODS--- |
27 |
|
|
|
28 |
|
|
//---CONSTRUCTORS--- |
29 |
|
|
|
30 |
|
|
/** |
31 |
tdb |
1.14 |
* Creates a new FilterServant. |
32 |
tdb |
1.1 |
* |
33 |
tdb |
1.14 |
* @param TCPListenPort the TCP port this filter is listening on |
34 |
|
|
* @param UDPListenPort the UDP port this filter is listening on |
35 |
|
|
* @param queue the Queue this filter is using |
36 |
tdb |
1.1 |
*/ |
37 |
tdb |
1.12 |
public FilterServant(int TCPListenPort, int UDPListenPort, Queue queue) { |
38 |
tdb |
1.9 |
_TCPListenPort = TCPListenPort; |
39 |
|
|
_UDPListenPort = UDPListenPort; |
40 |
tdb |
1.12 |
_queue = queue; |
41 |
tdb |
1.1 |
} |
42 |
tdb |
1.9 |
|
43 |
tdb |
1.1 |
//---PUBLIC METHODS--- |
44 |
|
|
|
45 |
|
|
/** |
46 |
|
|
* Method to receive a string over corba. |
47 |
|
|
* |
48 |
tdb |
1.14 |
* @param xml the String of XML to queue |
49 |
tdb |
1.1 |
*/ |
50 |
|
|
public void receiveXML(String xml) { |
51 |
tdb |
1.12 |
_queue.add(xml); |
52 |
tdb |
1.1 |
} |
53 |
|
|
|
54 |
|
|
/** |
55 |
|
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
56 |
|
|
* method to provide clean logging (every class should have this). |
57 |
|
|
* |
58 |
ajm |
1.11 |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
59 |
|
|
* to format the toString() |
60 |
|
|
* |
61 |
tdb |
1.1 |
* @return the name of this class and its CVS revision |
62 |
|
|
*/ |
63 |
|
|
public String toString() { |
64 |
ajm |
1.11 |
return FormatName.getName( |
65 |
|
|
_name, |
66 |
|
|
getClass().getName(), |
67 |
|
|
REVISION); |
68 |
tdb |
1.1 |
} |
69 |
|
|
|
70 |
|
|
//---PRIVATE METHODS--- |
71 |
|
|
|
72 |
|
|
//---ACCESSOR/MUTATOR METHODS--- |
73 |
|
|
|
74 |
ajm |
1.11 |
/** |
75 |
|
|
* Provides information to the FilterManager |
76 |
|
|
*/ |
77 |
tdb |
1.4 |
public String getUDPPort() { |
78 |
tdb |
1.9 |
return new Integer(_UDPListenPort).toString(); |
79 |
tdb |
1.4 |
} |
80 |
|
|
|
81 |
ajm |
1.11 |
/** |
82 |
|
|
* Provides information to the FilterManager |
83 |
|
|
*/ |
84 |
tdb |
1.4 |
public String getTCPPort() { |
85 |
tdb |
1.9 |
return new Integer(_TCPListenPort).toString(); |
86 |
tdb |
1.4 |
} |
87 |
|
|
|
88 |
ajm |
1.11 |
/** |
89 |
|
|
* Provides information to the FilterManager |
90 |
|
|
*/ |
91 |
tdb |
1.4 |
public String getHostName() { |
92 |
|
|
try { |
93 |
|
|
return InetAddress.getLocalHost().getHostName(); |
94 |
|
|
} catch (java.net.UnknownHostException e) { |
95 |
tdb |
1.9 |
_logger.write(toString(), Logger.ERROR, e.getMessage()); |
96 |
tdb |
1.4 |
} |
97 |
|
|
return null; |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
|
101 |
tdb |
1.1 |
//---ATTRIBUTES--- |
102 |
|
|
|
103 |
|
|
/** |
104 |
ajm |
1.11 |
* This is the friendly identifier of the |
105 |
|
|
* component this class is running in. |
106 |
|
|
* eg, a Filter may be called "filter1", |
107 |
|
|
* If this class does not have an owning |
108 |
|
|
* component, a name from the configuration |
109 |
|
|
* can be placed here. This name could also |
110 |
|
|
* be changed to null for utility classes. |
111 |
tdb |
1.1 |
*/ |
112 |
ajm |
1.11 |
private String _name = FilterMain.NAME; |
113 |
|
|
|
114 |
tdb |
1.1 |
/** |
115 |
ajm |
1.11 |
* This holds a reference to the |
116 |
|
|
* system logger that is being used. |
117 |
tdb |
1.1 |
*/ |
118 |
ajm |
1.11 |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
119 |
tdb |
1.3 |
|
120 |
|
|
/** |
121 |
tdb |
1.12 |
* Our Queue object |
122 |
tdb |
1.3 |
*/ |
123 |
tdb |
1.12 |
private Queue _queue; |
124 |
tdb |
1.4 |
|
125 |
ajm |
1.11 |
/** |
126 |
|
|
* The UDP port we're listening on |
127 |
|
|
*/ |
128 |
tdb |
1.9 |
private int _UDPListenPort; |
129 |
ajm |
1.11 |
|
130 |
|
|
/** |
131 |
|
|
* The TCP port we're listening on |
132 |
|
|
*/ |
133 |
tdb |
1.9 |
private int _TCPListenPort; |
134 |
tdb |
1.1 |
|
135 |
|
|
//---STATIC ATTRIBUTES--- |
136 |
|
|
|
137 |
|
|
} |