5 |
|
import uk.ac.ukc.iscream.core.*; |
6 |
|
import uk.ac.ukc.iscream.filter.*; |
7 |
|
import uk.ac.ukc.iscream.util.*; |
8 |
+ |
import uk.ac.ukc.iscream.componentmanager.*; |
9 |
|
import java.net.Socket; |
10 |
|
import java.io.*; |
11 |
|
|
12 |
|
/** |
13 |
|
* Handles setting up a host. |
14 |
+ |
* This class provides a host with appropriate configuration |
15 |
+ |
* and a reference to a Filter to which it should pass data. |
16 |
|
* |
17 |
|
* @author $Author$ |
18 |
|
* @version $Id$ |
141 |
|
} |
142 |
|
|
143 |
|
} catch (Exception e) { |
144 |
< |
_logger.write(toString(), Logger.ERROR, "ERROR: " + e.getMessage()); |
144 |
> |
_logger.write(toString(), Logger.ERROR, "ERROR - " + e.getMessage()); |
145 |
|
} |
146 |
|
|
147 |
|
_socketOut.flush(); |
160 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
161 |
|
* method to provide clean logging (every class should have this). |
162 |
|
* |
163 |
+ |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
164 |
+ |
* to format the toString() |
165 |
+ |
* |
166 |
|
* @return the name of this class and its CVS revision |
167 |
|
*/ |
168 |
|
public String toString() { |
169 |
< |
return this.getClass().getName() + "{" + _socket.getInetAddress().getHostName() |
170 |
< |
+ "}(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
171 |
< |
|
169 |
> |
return FormatName.getName( |
170 |
> |
_name, |
171 |
> |
getClass().getName(), |
172 |
> |
REVISION); |
173 |
|
} |
174 |
|
|
175 |
|
//---PRIVATE METHODS--- |
179 |
|
//---ATTRIBUTES--- |
180 |
|
|
181 |
|
/** |
182 |
< |
* A reference to the logger the system is using |
182 |
> |
* This holds a reference to the |
183 |
> |
* system logger that is being used. |
184 |
|
*/ |
185 |
< |
Logger _logger = ReferenceManager.getInstance().getLogger(); |
185 |
> |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
186 |
|
|
187 |
|
/** |
188 |
|
* A reference to the Configuration Manager the system is using |
189 |
|
*/ |
190 |
< |
ConfigurationManager _configManager = ReferenceManager.getInstance().getCM(); |
190 |
> |
private ConfigurationManager _configManager = ReferenceManager.getInstance().getCM(); |
191 |
|
|
192 |
< |
Socket _socket; |
193 |
< |
BufferedReader _socketIn; |
194 |
< |
PrintWriter _socketOut; |
192 |
> |
/** |
193 |
> |
* This is the friendly identifier of the |
194 |
> |
* component this class is running in. |
195 |
> |
* eg, a Filter may be called "filter1", |
196 |
> |
* If this class does not have an owning |
197 |
> |
* component, a name from the configuration |
198 |
> |
* can be placed here. This name could also |
199 |
> |
* be changed to null for utility classes. |
200 |
> |
*/ |
201 |
> |
private String _name = FilterManager.NAME; |
202 |
> |
|
203 |
> |
/** |
204 |
> |
* The socket this class uses |
205 |
> |
*/ |
206 |
> |
private Socket _socket; |
207 |
> |
|
208 |
> |
/** |
209 |
> |
* Used for the input stream of this socket |
210 |
> |
*/ |
211 |
> |
private BufferedReader _socketIn; |
212 |
> |
|
213 |
> |
/** |
214 |
> |
* Used for the output stream of this socket |
215 |
> |
*/ |
216 |
> |
private PrintWriter _socketOut; |
217 |
|
|
218 |
|
//---STATIC ATTRIBUTES--- |
219 |
|
|