ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/clientinterface/CorbaControlHandlerServant.java
Revision: 1.4
Committed: Mon Feb 12 02:23:52 2001 UTC (23 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.3: +5 -3 lines
Log Message:
Now monitor the Queue here every 60 seconds, reporting back to the Queue in
the PacketSorter class.

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.clientinterface;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.util.*;
6 import uk.ac.ukc.iscream.componentmanager.*;
7 import uk.ac.ukc.iscream.core.*;
8 import uk.ac.ukc.iscream.client.*;
9
10
11 /**
12 * Acts as a Control Handler to a CORBA based client.
13 *
14 * !!! FUNDAMENTAL DESIGN PROBLEM !!!
15 * !!! Need a way to "shutdown" this class !!!
16 *
17 * @author $Author: tdb1 $
18 * @version $Id: CorbaControlHandlerServant.java,v 1.3 2001/02/05 00:58:46 tdb1 Exp $
19 */
20 class CorbaControlHandlerServant extends CorbaControlHandlerPOA {
21
22 //---FINAL ATTRIBUTES---
23
24 /**
25 * The current CVS revision of this class
26 */
27 public final String REVISION = "$Revision: 1.3 $";
28
29 //---STATIC METHODS---
30
31 //---CONSTRUCTORS---
32
33 /**
34 * Construct a new CorbaControlHandlerServant.
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 */
39 public CorbaControlHandlerServant(PacketSorter packetSorter, Client client) {
40 _packetSorter = packetSorter;
41 _hostList = "";
42 _client = client;
43 _dataHandler = null;
44 _logger.write(toString(), Logger.SYSINIT, "created");
45 }
46
47 //---PUBLIC METHODS---
48
49 /**
50 * Start sending data to the client.
51 *
52 * @return a boolean stating whether the attempt to start succeeded
53 */
54 public boolean startData() {
55 if(_dataHandler == null) {
56 // create a new DataHandler
57 CorbaDataHandler dh = new CorbaDataHandler(_client);
58 // register the Queue
59 _packetSorter.register(dh.getQueue(), _hostList);
60 // startup a monitor on the DataHandler's queue, every minute
61 dh.getQueue().startMonitor(60*1000, _packetSorter.getQueue(), _name);
62 // start the DataHandler running
63 dh.start();
64 // keep a reference
65 _dataHandler = dh;
66 return true;
67 }
68 else {
69 return false;
70 }
71 }
72
73 /**
74 * Stop sending data to the client.
75 *
76 * @return a boolean stating whether the attempt to stop succeeded
77 */
78 public boolean stopData() {
79 if(_dataHandler != null) {
80 // deregister the Queue
81 _packetSorter.deregister(_dataHandler.getQueue(), _hostList);
82 // stop the DataHandler
83 _dataHandler.shutdown();
84 // destroy the reference
85 _dataHandler = null;
86 return true;
87 }
88 else {
89 return false;
90 }
91 }
92
93 /**
94 * Sets the host list for the Client to the requested semi-colon separated
95 * list of hostnames. This will only succeed if we are not sending data.
96 *
97 * @param hostList A semi-colon separated list of hostnames to use.
98 * @return Whether the request succeeded.
99 */
100 public boolean setHostList(String hostList) {
101 if(_dataHandler == null) {
102 _hostList = hostList;
103 return true;
104 }
105 else {
106 return false;
107 }
108 }
109
110 /**
111 * Overrides the {@link java.lang.Object#toString() Object.toString()}
112 * method to provide clean logging (every class should have this).
113 *
114 * This uses the uk.ac.ukc.iscream.util.NameFormat class
115 * to format the toString()
116 *
117 * @return the name of this class and its CVS revision
118 */
119 public String toString() {
120 return FormatName.getName(
121 _name,
122 getClass().getName(),
123 REVISION);
124 }
125
126 //---PRIVATE METHODS---
127
128 //---ACCESSOR/MUTATOR METHODS---
129
130 //---ATTRIBUTES---
131
132 /**
133 * This is the friendly identifier of the
134 * component this class is running in.
135 * eg, a Filter may be called "filter1",
136 * If this class does not have an owning
137 * component, a name from the configuration
138 * can be placed here. This name could also
139 * be changed to null for utility classes.
140 */
141 private String _name = ClientInterfaceMain.NAME;
142
143 /**
144 * This holds a reference to the
145 * system logger that is being used.
146 */
147 private Logger _logger = ReferenceManager.getInstance().getLogger();
148
149 /**
150 * A reference to the PacketSorter.
151 */
152 private PacketSorter _packetSorter;
153
154 /**
155 * The host list the Client has requested
156 */
157 private String _hostList;
158
159 /**
160 * The "servant" part of the client we're connected to.
161 */
162 private Client _client;
163
164 /**
165 * A reference to our DataHandler, if we have one
166 */
167 private CorbaDataHandler _dataHandler;
168
169 //---STATIC ATTRIBUTES---
170
171 }