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.5
Committed: Wed Feb 21 22:48:20 2001 UTC (23 years, 2 months ago) by tdb
Branch: MAIN
Changes since 1.4: +115 -35 lines
Log Message:
Removed all the debugging and testing stuff that I originally wrote. This is now
along the lines of the new structure, although it will need a lot more work :)

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.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.*;
9
10 /**
11 * A startup component for the Local Clients.
12 *
13 * @author $Author$
14 * @version $Id$
15 */
16 public class ClientMain implements Component {
17
18 //---FINAL ATTRIBUTES---
19
20 /**
21 * The current CVS revision of this class
22 */
23 public static final String REVISION = "$Revision: 1.1 $";
24
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
42 _logger.write(toString(), Logger.SYSINIT, "coming up");
43
44 // configuration variables we require
45 int queueMonitorInterval = 0;
46
47 Configuration config = _refman.getCM().getConfiguration("LocalClient");
48 if (config == null) {
49 throw new ComponentStartException("Unable to obtain configuration for component");
50 }
51 else {
52 try {
53 // get the configuration properties we need
54 queueMonitorInterval = Integer.parseInt(config.getProperty("Queue.MonitorInterval"));
55 } catch (org.omg.CORBA.MARSHAL e) {
56 throw new ComponentStartException("Unable to obtain requried configuration property for component");
57 }
58 }
59
60 _logger.write(toString(), Logger.SYSINIT, "configured");
61
62 // setup the servant
63 _logger.write(toString(), Logger.SYSINIT, "starting servant");
64
65 Client client;
66
67 try {
68 ClientServant ref = new ClientServant();
69 org.omg.CORBA.Object objRef = _refman.getRootPOA().servant_to_reference(ref);
70 client = ClientHelper.narrow(objRef);
71
72 // this name maybe shouldn't be static
73 objRef = _refman.getCORBARef("iscream.ClientInterface.CorbaListener");
74 CorbaClientListener listener = CorbaClientListenerHelper.narrow(objRef);
75
76 _logger.write(toString(), Logger.SYSINIT, "connecting");
77 CorbaControlHandler handler = listener.connect(client);
78 handler.startData();
79 }
80 catch(Exception e) {
81 // not sure what to do here
82 // so we just log the error
83 _logger.write(toString(), Logger.ERROR, "ERROR - " + e.getMessage());
84 }
85
86 _logger.write(toString(), Logger.SYSINIT, "started");
87
88 }
89
90 /**
91 * Overrides the {@link java.lang.Object#toString() Object.toString()}
92 * method to provide clean logging (every class should have this).
93 *
94 * This uses the uk.ac.ukc.iscream.util.FormatName class
95 * to format the toString()
96 *
97 * @return the name of this class and its CVS revision
98 */
99 public String toString() {
100 return FormatName.getName(
101 NAME,
102 getClass().getName(),
103 REVISION);
104 }
105
106 //---PRIVATE METHODS---
107
108 //---ACCESSOR/MUTATOR METHODS---
109
110 //---ATTRIBUTES---
111
112 /**
113 * This holds a reference to the
114 * system logger that is being used.
115 */
116 private Logger _logger = ReferenceManager.getInstance().getLogger();
117
118 /**
119 * A reference to the reference manager in use
120 */
121 private ReferenceManager _refman = ReferenceManager.getInstance();
122
123 //---STATIC ATTRIBUTES---
124
125 }