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 java.net.Socket; |
9 |
|
import java.net.ServerSocket; |
11 |
|
import java.io.IOException; |
12 |
|
import java.net.InetAddress; |
13 |
|
import java.net.UnknownHostException; |
14 |
< |
import org.omg.CORBA.*; |
13 |
< |
import org.omg.CosNaming.*; |
14 |
> |
import uk.ac.ukc.iscream.util.*; |
15 |
|
|
16 |
|
/** |
17 |
< |
* A socket listener to listen for new hosts registering with the system. |
17 |
< |
* When a host makes a connection, the connecton is past to an instance |
18 |
< |
* of the HostInit class, which handles further communication. |
17 |
> |
* Reads TCP Heartbeats from the host applications. |
18 |
|
* |
19 |
|
* @author $Author$ |
20 |
|
* @version $Id$ |
33 |
|
//---CONSTRUCTORS--- |
34 |
|
|
35 |
|
/** |
36 |
< |
* Constructs a new listener |
36 |
> |
* Constructs a new TCPReader |
37 |
|
* |
38 |
< |
* @param logger a reference to the logger we are using |
39 |
< |
* @param configManager a reference to the ConfigurationManager we are using |
41 |
< |
* @param port The port that the server will listen on. |
38 |
> |
* @param queue A reference to our Queue |
39 |
> |
* @param port The port that the TCPReader will listen on |
40 |
|
*/ |
41 |
< |
public TCPReader(Logger logger, ConfigurationManager configManager, int port, Filter parent) { |
44 |
< |
_logger = logger; |
45 |
< |
_configManager = configManager; |
41 |
> |
public TCPReader(int port, Queue queue) { |
42 |
|
_port = port; |
43 |
< |
_parent = parent; |
43 |
> |
_queue = queue; |
44 |
|
_logger.write(toString(), Logger.SYSINIT, "started"); |
45 |
|
} |
46 |
|
|
92 |
|
// If we've stopped on the line above we won't want to try this ! |
93 |
|
if(run){ |
94 |
|
try { |
95 |
< |
// Setup the HostInit so it can carry on communications with the host |
96 |
< |
TCPReaderInit init = new TCPReaderInit(hostSocket, _configManager, _logger, _parent); |
95 |
> |
// Setup the TCPReaderInit and start it |
96 |
> |
TCPReaderInit init = new TCPReaderInit(hostSocket, _queue); |
97 |
|
// and start it |
98 |
|
init.start(); |
99 |
|
} catch (IOException e) { |
109 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
110 |
|
* method to provide clean logging (every class should have this). |
111 |
|
* |
112 |
+ |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
113 |
+ |
* to format the toString() |
114 |
+ |
* |
115 |
|
* @return the name of this class and its CVS revision |
116 |
|
*/ |
117 |
|
public String toString() { |
118 |
< |
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
118 |
> |
return FormatName.getName( |
119 |
> |
_name, |
120 |
> |
getClass().getName(), |
121 |
> |
REVISION); |
122 |
|
} |
123 |
|
|
124 |
|
//---PRIVATE METHODS--- |
128 |
|
//---ATTRIBUTES--- |
129 |
|
|
130 |
|
/** |
131 |
< |
* A reference to the logger the system is using |
131 |
> |
* This is the friendly identifier of the |
132 |
> |
* component this class is running in. |
133 |
> |
* eg, a Filter may be called "filter1", |
134 |
> |
* If this class does not have an owning |
135 |
> |
* component, a name from the configuration |
136 |
> |
* can be placed here. This name could also |
137 |
> |
* be changed to null for utility classes. |
138 |
|
*/ |
139 |
< |
Logger _logger; |
140 |
< |
|
139 |
> |
private String _name = FilterMain.NAME; |
140 |
> |
|
141 |
|
/** |
142 |
< |
* A reference to the configurator the system is using |
142 |
> |
* This holds a reference to the |
143 |
> |
* system logger that is being used. |
144 |
|
*/ |
145 |
< |
ConfigurationManager _configManager; |
145 |
> |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
146 |
|
|
147 |
|
/** |
148 |
|
* The port on which the server should listen. |
149 |
|
*/ |
150 |
|
private int _port; |
151 |
|
|
152 |
< |
private Filter _parent; |
152 |
> |
/** |
153 |
> |
* A reference to our Queue |
154 |
> |
*/ |
155 |
> |
private Queue _queue; |
156 |
|
|
157 |
|
//---STATIC ATTRIBUTES--- |
158 |
|
|