1 |
|
//---PACKAGE DECLARATION--- |
2 |
< |
package uk.ac.ukc.iscream.client; |
2 |
> |
package uk.org.iscream.client; |
3 |
|
|
4 |
|
//---IMPORTS--- |
5 |
< |
import uk.ac.ukc.iscream.clientinterface.*; |
6 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
7 |
< |
import uk.ac.ukc.iscream.core.*; |
8 |
< |
import uk.ac.ukc.iscream.util.*; |
5 |
> |
import uk.org.iscream.clientinterface.*; |
6 |
> |
import uk.org.iscream.componentmanager.*; |
7 |
> |
import uk.org.iscream.core.*; |
8 |
> |
import uk.org.iscream.util.*; |
9 |
|
|
10 |
|
/** |
11 |
|
* A startup component for the Local Clients. |
39 |
|
*/ |
40 |
|
public void start() throws ComponentStartException { |
41 |
|
// get references to key objects |
42 |
< |
_refman = ReferenceManager.getInstance(); |
43 |
< |
_logger = ReferenceManager.getInstance().getLogger(); |
42 |
> |
_logger = _refman.getLogger(); |
43 |
|
|
44 |
|
_logger.write(toString(), Logger.SYSINIT, "coming up"); |
46 |
– |
|
47 |
– |
// configuration variables we require |
48 |
– |
int queueMonitorInterval = 0; |
45 |
|
|
46 |
< |
Configuration config = _refman.getCM().getConfiguration("LocalClient"); |
47 |
< |
if (config == null) { |
48 |
< |
throw new ComponentStartException("Unable to obtain configuration for component"); |
49 |
< |
} |
50 |
< |
else { |
55 |
< |
try { |
56 |
< |
// get the configuration properties we need |
57 |
< |
queueMonitorInterval = Integer.parseInt(config.getProperty("Queue.MonitorInterval")); |
58 |
< |
} catch (org.omg.CORBA.MARSHAL e) { |
59 |
< |
throw new ComponentStartException("Unable to obtain requried configuration property for component"); |
60 |
< |
} |
61 |
< |
} |
62 |
< |
|
63 |
< |
_logger.write(toString(), Logger.SYSINIT, "configured"); |
46 |
> |
// setup the queues, this must be done before both managers are setup |
47 |
> |
// setup a Queue for the servant -> monitor manager |
48 |
> |
_monitorQueue = new Queue(); |
49 |
> |
// setup a Queue for the monitors -> alert manager |
50 |
> |
_alerterQueue = new Queue(); |
51 |
|
|
52 |
< |
// setup the servant |
53 |
< |
_logger.write(toString(), Logger.SYSINIT, "starting servant"); |
67 |
< |
|
68 |
< |
Client client; |
69 |
< |
|
52 |
> |
// setup the servant and connect |
53 |
> |
_logger.write(toString(), Logger.SYSINIT, "starting servant and connecting"); |
54 |
|
try { |
55 |
< |
ClientServant ref = new ClientServant(); |
55 |
> |
ClientServant ref = new ClientServant(_monitorQueue); |
56 |
|
org.omg.CORBA.Object objRef = _refman.getRootPOA().servant_to_reference(ref); |
57 |
< |
client = ClientHelper.narrow(objRef); |
57 |
> |
Client client = ClientHelper.narrow(objRef); |
58 |
|
|
59 |
|
// this name maybe shouldn't be static |
60 |
|
objRef = _refman.getCORBARef("iscream.ClientInterface.CorbaListener"); |
61 |
|
CorbaClientListener listener = CorbaClientListenerHelper.narrow(objRef); |
62 |
|
|
63 |
|
_logger.write(toString(), Logger.SYSINIT, "connecting"); |
64 |
< |
CorbaControlHandler handler = listener.connect(client); |
64 |
> |
CorbaControlHandler handler = listener.connect(client, NAME); |
65 |
|
handler.startData(); |
66 |
|
} |
67 |
|
catch(Exception e) { |
70 |
|
_logger.write(toString(), Logger.ERROR, "ERROR - " + e.getMessage()); |
71 |
|
} |
72 |
|
|
73 |
+ |
// setup the MonitorManager |
74 |
+ |
MonitorManager monMan = MonitorManager.getInstance(); |
75 |
+ |
monMan.start(); |
76 |
+ |
|
77 |
+ |
// setup the AlerterManager |
78 |
+ |
AlerterManager alertMan = AlerterManager.getInstance(); |
79 |
+ |
alertMan.start(); |
80 |
+ |
|
81 |
|
_logger.write(toString(), Logger.SYSINIT, "started"); |
82 |
|
|
83 |
|
} |
84 |
< |
|
84 |
> |
|
85 |
|
/** |
86 |
+ |
* Does a dependency check. Used mainly at startup to |
87 |
+ |
* see if the required dependencies (components) are up |
88 |
+ |
* and running. |
89 |
+ |
* |
90 |
+ |
* @return a boolean value, true if the depdencies are satisfied |
91 |
+ |
*/ |
92 |
+ |
public boolean depCheck() { |
93 |
+ |
try { |
94 |
+ |
org.omg.CORBA.Object obj; |
95 |
+ |
// first check the ConfigurationManager is alive |
96 |
+ |
obj = _refman.getCORBARef("iscream.ConfigurationManager"); |
97 |
+ |
// then get some info on the CLI |
98 |
+ |
ConfigurationProxy cp = ConfigurationProxy.getInstance(); |
99 |
+ |
String cli = cp.getProperty("RootFilter", "RootFilter.realtimeInterfaceName"); |
100 |
+ |
// finally check the CLI is alive |
101 |
+ |
obj = _refman.getCORBARef("iscream.ClientInterface." + cli); |
102 |
+ |
} catch(ComponentCORBAException e) { |
103 |
+ |
System.err.println(toString() + ": Dependency Failure: "+e); |
104 |
+ |
return false; |
105 |
+ |
} catch(PropertyNotFoundException e) { |
106 |
+ |
System.err.println(toString() + ": Unable to obtain configuration: "+e); |
107 |
+ |
return false; |
108 |
+ |
} |
109 |
+ |
// dependency check suceeded |
110 |
+ |
return true; |
111 |
+ |
} |
112 |
+ |
|
113 |
+ |
/** |
114 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
115 |
|
* method to provide clean logging (every class should have this). |
116 |
|
* |
117 |
< |
* This uses the uk.ac.ukc.iscream.util.FormatName class |
117 |
> |
* This uses the uk.org.iscream.util.FormatName class |
118 |
|
* to format the toString() |
119 |
|
* |
120 |
|
* @return the name of this class and its CVS revision |
141 |
|
/** |
142 |
|
* A reference to the reference manager in use |
143 |
|
*/ |
144 |
< |
private ReferenceManager _refman; |
144 |
> |
private ReferenceManager _refman = ReferenceManager.getInstance(); |
145 |
|
|
146 |
|
//---STATIC ATTRIBUTES--- |
147 |
+ |
|
148 |
+ |
/** |
149 |
+ |
* A queue for the alerter manager |
150 |
+ |
*/ |
151 |
+ |
public static Queue _alerterQueue; |
152 |
+ |
|
153 |
+ |
/** |
154 |
+ |
* A queue for the monitor manager |
155 |
+ |
*/ |
156 |
+ |
public static Queue _monitorQueue; |
157 |
|
|
158 |
|
} |