1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.filter; |
2 |
> |
package uk.org.iscream.cms.server.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.*; |
5 |
> |
import uk.org.iscream.cms.server.core.*; |
6 |
> |
import uk.org.iscream.cms.server.componentmanager.*; |
7 |
> |
import uk.org.iscream.cms.server.filter.*; |
8 |
|
import java.net.Socket; |
9 |
|
import java.net.ServerSocket; |
10 |
|
import java.io.OutputStream; |
11 |
|
import java.io.IOException; |
12 |
|
import java.net.InetAddress; |
13 |
|
import java.net.UnknownHostException; |
14 |
< |
import uk.ac.ukc.iscream.util.*; |
14 |
> |
import uk.org.iscream.cms.server.util.*; |
15 |
|
|
16 |
|
/** |
17 |
|
* Reads TCP Heartbeats from the host applications. |
39 |
|
* @param port The port that the TCPReader will listen on |
40 |
|
*/ |
41 |
|
public TCPReader(int port, Queue queue) { |
42 |
+ |
// set the Thread name |
43 |
+ |
setName("filter.TCPReader"); |
44 |
+ |
|
45 |
|
_port = port; |
46 |
|
_queue = queue; |
47 |
|
_logger.write(toString(), Logger.SYSINIT, "started"); |
59 |
|
* and then passing them off to other processes to deal with. |
60 |
|
*/ |
61 |
|
public void run(){ |
62 |
< |
ServerSocket listenPort=null; |
63 |
< |
// We use this boolean so we can break out of the while loop if we want |
64 |
< |
boolean run = true; |
62 |
> |
// get our ACL from the configuration |
63 |
> |
ACL tcpACL = null; |
64 |
> |
try { |
65 |
> |
String stringACL = ConfigurationProxy.getInstance().getProperty(FilterMain.NAME, "Filter.TCPACL"); |
66 |
> |
tcpACL = new ACL(stringACL); |
67 |
> |
} |
68 |
> |
catch(PropertyNotFoundException e) { |
69 |
> |
_logger.write(toString(), Logger.WARNING, "No ACL found for TCPReader: " + e); |
70 |
> |
} |
71 |
> |
|
72 |
> |
ServerSocket listenPort=null; |
73 |
|
try{ |
74 |
|
// Setup the ServerSocket so that clients can connect |
75 |
< |
listenPort = new ServerSocket(_port); |
75 |
> |
// use an ACLServerSocket if we have an ACL |
76 |
> |
if(tcpACL != null) { |
77 |
> |
listenPort = new ACLServerSocket(tcpACL, _port); |
78 |
> |
} |
79 |
> |
else { |
80 |
> |
listenPort = new ServerSocket(_port); |
81 |
> |
} |
82 |
|
} |
83 |
|
catch(IOException e){ |
84 |
|
} |
85 |
+ |
|
86 |
|
// Log what machine/port we're listening on |
87 |
|
try{ |
88 |
|
_logger.write(toString(), Logger.SYSMSG, "TCPReader listening on " |
94 |
|
_logger.write(toString(), Logger.SYSMSG, "TCPReader listening on UnknownHost " |
95 |
|
+"port "+listenPort.getLocalPort()); |
96 |
|
} |
97 |
+ |
|
98 |
+ |
// We use this boolean so we can break out of the while loop if we want |
99 |
+ |
boolean run = true; |
100 |
+ |
|
101 |
|
// Loop round constantly until we decide to stop |
102 |
|
while(run){ |
103 |
|
Socket hostSocket=null; |
131 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
132 |
|
* method to provide clean logging (every class should have this). |
133 |
|
* |
134 |
< |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
134 |
> |
* This uses the uk.org.iscream.cms.server.util.NameFormat class |
135 |
|
* to format the toString() |
136 |
|
* |
137 |
|
* @return the name of this class and its CVS revision |