ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/ClientMain.java
Revision: 1.16
Committed: Thu Mar 15 22:12:22 2001 UTC (23 years, 2 months ago) by tdb
Branch: MAIN
Changes since 1.15: +2 -24 lines
Log Message:
Seems I missed updating the configuration sections in these files.

File Contents

# User Rev Content
1 tdb 1.5 //---PACKAGE DECLARATION---
2 tdb 1.15 package uk.org.iscream.client;
3 tdb 1.1
4 tdb 1.5 //---IMPORTS---
5 tdb 1.15 import uk.org.iscream.clientinterface.*;
6     import uk.org.iscream.componentmanager.*;
7     import uk.org.iscream.core.*;
8     import uk.org.iscream.util.*;
9 tdb 1.5
10     /**
11     * A startup component for the Local Clients.
12     *
13 tdb 1.13 * @author $Author: tdb1 $
14 tdb 1.16 * @version $Id: ClientMain.java,v 1.15 2001/03/14 23:25:29 tdb1 Exp $
15 tdb 1.5 */
16     public class ClientMain implements Component {
17    
18     //---FINAL ATTRIBUTES---
19    
20     /**
21     * The current CVS revision of this class
22     */
23 tdb 1.16 public static final String REVISION = "$Revision: 1.15 $";
24 tdb 1.5
25     /**
26     * The friendly name for this component, used by
27     * all related classes.
28     */
29     public static final String NAME = "LocalClient";
30    
31     //---STATIC METHODS---
32    
33     //---CONSTRUCTORS---
34    
35     //---PUBLIC METHODS---
36    
37     /**
38     * This starts the Local Client component
39     */
40     public void start() throws ComponentStartException {
41 tdb 1.6 // get references to key objects
42 tdb 1.13 _logger = _refman.getLogger();
43 tdb 1.5
44     _logger.write(toString(), Logger.SYSINIT, "coming up");
45    
46 ajm 1.9 // setup the queues, this must be done before both managers are setup
47 tdb 1.7 // setup a Queue for the servant -> monitor manager
48 ajm 1.9 _monitorQueue = new Queue();
49 tdb 1.10 // setup a Queue for the monitors -> alert manager
50 ajm 1.9 _alerterQueue = new Queue();
51 tdb 1.5
52 tdb 1.7 // setup the servant and connect
53     _logger.write(toString(), Logger.SYSINIT, "starting servant and connecting");
54 tdb 1.1 try {
55 ajm 1.9 ClientServant ref = new ClientServant(_monitorQueue);
56 tdb 1.5 org.omg.CORBA.Object objRef = _refman.getRootPOA().servant_to_reference(ref);
57 tdb 1.7 Client client = ClientHelper.narrow(objRef);
58 tdb 1.5
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 tdb 1.8 CorbaControlHandler handler = listener.connect(client, NAME);
65 tdb 1.5 handler.startData();
66 tdb 1.1 }
67 tdb 1.5 catch(Exception e) {
68     // not sure what to do here
69     // so we just log the error
70     _logger.write(toString(), Logger.ERROR, "ERROR - " + e.getMessage());
71 tdb 1.1 }
72 tdb 1.7
73     // setup the MonitorManager
74 ajm 1.9 MonitorManager monMan = MonitorManager.getInstance();
75     monMan.start();
76    
77     // setup the AlerterManager
78     AlerterManager alertMan = AlerterManager.getInstance();
79     alertMan.start();
80    
81 tdb 1.5 _logger.write(toString(), Logger.SYSINIT, "started");
82    
83     }
84 tdb 1.12
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 tdb 1.14 System.err.println(toString() + ": Dependency Failure: "+e);
104 tdb 1.12 return false;
105     } catch(PropertyNotFoundException e) {
106 tdb 1.14 System.err.println(toString() + ": Unable to obtain configuration: "+e);
107 tdb 1.12 return false;
108     }
109     // dependency check suceeded
110     return true;
111     }
112    
113 tdb 1.5 /**
114     * Overrides the {@link java.lang.Object#toString() Object.toString()}
115     * method to provide clean logging (every class should have this).
116     *
117 tdb 1.15 * This uses the uk.org.iscream.util.FormatName class
118 tdb 1.5 * to format the toString()
119     *
120     * @return the name of this class and its CVS revision
121     */
122     public String toString() {
123     return FormatName.getName(
124     NAME,
125     getClass().getName(),
126     REVISION);
127 tdb 1.1 }
128 tdb 1.5
129     //---PRIVATE METHODS---
130    
131     //---ACCESSOR/MUTATOR METHODS---
132    
133     //---ATTRIBUTES---
134    
135     /**
136     * This holds a reference to the
137     * system logger that is being used.
138     */
139 tdb 1.6 private Logger _logger;
140 tdb 1.5
141     /**
142     * A reference to the reference manager in use
143     */
144 tdb 1.13 private ReferenceManager _refman = ReferenceManager.getInstance();
145 tdb 1.5
146     //---STATIC ATTRIBUTES---
147 ajm 1.9
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 tdb 1.1
158     }