35 |
|
* |
36 |
|
* @param packetSorter A reference to the PacketSorter in the component |
37 |
|
* @param client A reference to the "servant" part of the connecting client. |
38 |
+ |
* @param queueMonitorInterval The interval at which to monitor our Queue. |
39 |
+ |
* @param clientname A name to identify the client. |
40 |
|
*/ |
41 |
< |
public CorbaControlHandlerServant(PacketSorter packetSorter, Client client) { |
41 |
> |
public CorbaControlHandlerServant(PacketSorter packetSorter, Client client, String clientname) { |
42 |
|
_packetSorter = packetSorter; |
43 |
|
_hostList = ""; |
44 |
|
_client = client; |
45 |
+ |
_clientname = clientname; |
46 |
|
_dataHandler = null; |
47 |
|
_logger.write(toString(), Logger.SYSINIT, "created"); |
48 |
|
} |
60 |
|
CorbaDataHandler dh = new CorbaDataHandler(_client); |
61 |
|
// register the Queue |
62 |
|
_packetSorter.register(dh.getQueue(), _hostList); |
63 |
< |
// startup a monitor on the DataHandler's queue, every minute |
64 |
< |
dh.getQueue().startMonitor(60*1000, _packetSorter.getQueue(), _name); |
63 |
> |
try { |
64 |
> |
// startup a monitor on the DataHandler's queue |
65 |
> |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
66 |
> |
int queueMonitorInterval = Integer.parseInt(cp.getProperty("ClientInterface", "Queue.MonitorInterval")); |
67 |
> |
String queueName = _name + " CorbaHandler:"+_clientname; |
68 |
> |
dh.getQueue().startMonitor(queueMonitorInterval*1000, _packetSorter.getQueue(), queueName); |
69 |
> |
} catch (PropertyNotFoundException e) { |
70 |
> |
_logger.write(toString(), Logger.WARNING, "failed to find queue monitor config, disabling. " + e); |
71 |
> |
} |
72 |
|
// start the DataHandler running |
73 |
|
dh.start(); |
74 |
|
// keep a reference |
118 |
|
} |
119 |
|
|
120 |
|
/** |
121 |
+ |
* Disconnect, this will shutdown the data and unhook from |
122 |
+ |
* the CORBA ORB. |
123 |
+ |
*/ |
124 |
+ |
public void disconnect() { |
125 |
+ |
// close the data handler |
126 |
+ |
stopData(); |
127 |
+ |
// disconnect from the ORB |
128 |
+ |
try { |
129 |
+ |
byte[] oid = _refman.getRootPOA().servant_to_id(this); |
130 |
+ |
_refman.getRootPOA().deactivate_object(oid); |
131 |
+ |
} catch(Exception e) { |
132 |
+ |
_logger.write(this.toString(), Logger.ERROR, "disconnect failed: "+e); |
133 |
+ |
} |
134 |
+ |
} |
135 |
+ |
|
136 |
+ |
/** |
137 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
138 |
|
* method to provide clean logging (every class should have this). |
139 |
|
* |
171 |
|
* system logger that is being used. |
172 |
|
*/ |
173 |
|
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
174 |
+ |
|
175 |
+ |
/** |
176 |
+ |
* A reference to the reference manager in use |
177 |
+ |
*/ |
178 |
+ |
private ReferenceManager _refman = ReferenceManager.getInstance(); |
179 |
|
|
180 |
|
/** |
181 |
|
* A reference to the PacketSorter. |
196 |
|
* A reference to our DataHandler, if we have one |
197 |
|
*/ |
198 |
|
private CorbaDataHandler _dataHandler; |
199 |
+ |
|
200 |
+ |
/** |
201 |
+ |
* A name to identify the client |
202 |
+ |
*/ |
203 |
+ |
private String _clientname; |
204 |
|
|
205 |
|
//---STATIC ATTRIBUTES--- |
206 |
|
|