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.9
Committed: Fri Mar 2 00:15:59 2001 UTC (23 years, 2 months ago) by ajm
Branch: MAIN
Changes since 1.8: +34 -7 lines
Log Message:
Makefile now compiles the alerter manager.
MonitorManager is now fleshed out.
ClientMain is now fleshed out.

File Contents

# User Rev Content
1 tdb 1.5 //---PACKAGE DECLARATION---
2 tdb 1.1 package uk.ac.ukc.iscream.client;
3    
4 tdb 1.5 //---IMPORTS---
5 tdb 1.1 import uk.ac.ukc.iscream.clientinterface.*;
6     import uk.ac.ukc.iscream.componentmanager.*;
7 tdb 1.5 import uk.ac.ukc.iscream.core.*;
8     import uk.ac.ukc.iscream.util.*;
9    
10     /**
11     * A startup component for the Local Clients.
12     *
13 tdb 1.6 * @author $Author: tdb1 $
14 ajm 1.9 * @version $Id: ClientMain.java,v 1.8 2001/02/28 19:02:58 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 ajm 1.9 public static final String REVISION = "$Revision: 1.8 $";
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     _refman = ReferenceManager.getInstance();
43     _logger = ReferenceManager.getInstance().getLogger();
44 tdb 1.5
45     _logger.write(toString(), Logger.SYSINIT, "coming up");
46    
47     // configuration variables we require
48     int queueMonitorInterval = 0;
49    
50     Configuration config = _refman.getCM().getConfiguration("LocalClient");
51     if (config == null) {
52     throw new ComponentStartException("Unable to obtain configuration for component");
53     }
54     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");
64    
65 ajm 1.9 // setup the queues, this must be done before both managers are setup
66     String queueName;
67 tdb 1.7 // setup a Queue for the servant -> monitor manager
68 ajm 1.9 _monitorQueue = new Queue();
69 tdb 1.7 // startup a monitor on this queue
70 ajm 1.9 queueName = NAME + " MonitorManager";
71     _monitorQueue.startMonitor(queueMonitorInterval*1000, queueName);
72    
73     // setup a Queue for the monitors -> alert manager
74     _alerterQueue = new Queue();
75     // startup a monitor on this queue
76     queueName = NAME + " MonitorManager";
77     _alerterQueue.startMonitor(queueMonitorInterval*1000, queueName);
78    
79    
80 tdb 1.5
81 tdb 1.7 // setup the servant and connect
82     _logger.write(toString(), Logger.SYSINIT, "starting servant and connecting");
83 tdb 1.1 try {
84 ajm 1.9 ClientServant ref = new ClientServant(_monitorQueue);
85 tdb 1.5 org.omg.CORBA.Object objRef = _refman.getRootPOA().servant_to_reference(ref);
86 tdb 1.7 Client client = ClientHelper.narrow(objRef);
87 tdb 1.5
88     // this name maybe shouldn't be static
89     objRef = _refman.getCORBARef("iscream.ClientInterface.CorbaListener");
90     CorbaClientListener listener = CorbaClientListenerHelper.narrow(objRef);
91    
92     _logger.write(toString(), Logger.SYSINIT, "connecting");
93 tdb 1.8 CorbaControlHandler handler = listener.connect(client, NAME);
94 tdb 1.5 handler.startData();
95 tdb 1.1 }
96 tdb 1.5 catch(Exception e) {
97     // not sure what to do here
98     // so we just log the error
99     _logger.write(toString(), Logger.ERROR, "ERROR - " + e.getMessage());
100 tdb 1.1 }
101 tdb 1.7
102     // setup the MonitorManager
103 ajm 1.9 MonitorManager monMan = MonitorManager.getInstance();
104     monMan.start();
105    
106     // setup the AlerterManager
107    
108 tdb 1.5
109 ajm 1.9 AlerterManager alertMan = AlerterManager.getInstance();
110     alertMan.start();
111    
112 tdb 1.5 _logger.write(toString(), Logger.SYSINIT, "started");
113    
114     }
115    
116     /**
117     * Overrides the {@link java.lang.Object#toString() Object.toString()}
118     * method to provide clean logging (every class should have this).
119     *
120     * This uses the uk.ac.ukc.iscream.util.FormatName class
121     * to format the toString()
122     *
123     * @return the name of this class and its CVS revision
124     */
125     public String toString() {
126     return FormatName.getName(
127     NAME,
128     getClass().getName(),
129     REVISION);
130 tdb 1.1 }
131 tdb 1.5
132     //---PRIVATE METHODS---
133    
134     //---ACCESSOR/MUTATOR METHODS---
135    
136     //---ATTRIBUTES---
137    
138     /**
139     * This holds a reference to the
140     * system logger that is being used.
141     */
142 tdb 1.6 private Logger _logger;
143 tdb 1.5
144     /**
145     * A reference to the reference manager in use
146     */
147 tdb 1.6 private ReferenceManager _refman;
148 tdb 1.5
149     //---STATIC ATTRIBUTES---
150 ajm 1.9
151     /**
152     * A queue for the alerter manager
153     */
154     public static Queue _alerterQueue;
155    
156     /**
157     * A queue for the monitor manager
158     */
159     public static Queue _monitorQueue;
160 tdb 1.1
161     }