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/CorbaClientListenerServant.java
Revision: 1.6
Committed: Wed Feb 28 19:04:00 2001 UTC (23 years, 3 months ago) by tdb
Branch: MAIN
Changes since 1.5: +5 -4 lines
Log Message:
Now requires a client send a name. This is to enable each handler to be
identified from the others. With TCP ones, this was quite easily done with the
hostname (which isn't perfect), but with corba a name was required.

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.clientinterface;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.core.*;
6 import uk.ac.ukc.iscream.util.*;
7 import uk.ac.ukc.iscream.componentmanager.*;
8 import uk.ac.ukc.iscream.client.*;
9
10 /**
11 * This class, a servant, listens for incoming connections from CORBA based
12 * clients. Once it receives a connection it creates and assigns a CorbaControlHandler
13 * object to it. The CorbaControlHandler will then handle all requests on behalf of the
14 * client, and will send the client data.
15 *
16 * @author $Author: tdb1 $
17 * @version $Id: CorbaClientListenerServant.java,v 1.5 2001/02/21 19:11:28 tdb1 Exp $
18 */
19 class CorbaClientListenerServant extends CorbaClientListenerPOA {
20
21 //---FINAL ATTRIBUTES---
22
23 /**
24 * The current CVS revision of this class
25 */
26 public final String REVISION = "$Revision: 1.5 $";
27
28 //---STATIC METHODS---
29
30 //---CONSTRUCTORS---
31
32 /**
33 * Creates a new CorbaClientListenerServant.
34 *
35 * @param packetSorter a reference to the PacketSorter object being used
36 * @param queueMonitorInterval the interval at which to monitor the Queue
37 */
38 public CorbaClientListenerServant(PacketSorter packetSorter, int queueMonitorInterval) {
39 _packetSorter = packetSorter;
40 _queueMonitorInterval = queueMonitorInterval;
41 _logger.write(toString(), Logger.SYSINIT, "created");
42 }
43
44 //---PUBLIC METHODS---
45
46 /**
47 * Allows a CORBA client to connect to the server.
48 *
49 * @param client a reference to the "servant" part of the connecting client.
50 * @param name a name to identify the client.
51 * @return a CorbaControlHandler reference.
52 */
53 public CorbaControlHandler connect(Client client, String name) {
54 CorbaControlHandlerServant cchServant = new CorbaControlHandlerServant(_packetSorter, client, _queueMonitorInterval, name);
55 org.omg.CORBA.Object objRef;
56 try {
57 objRef = _refman.getRootPOA().servant_to_reference(cchServant);
58 } catch (Exception e) {
59 objRef = null;
60 _logger.write(toString(), Logger.ERROR, "Error creating CorbaControlHandler: "+e);
61 }
62 CorbaControlHandler corbaHandler = CorbaControlHandlerHelper.narrow(objRef);
63 return corbaHandler;
64 }
65
66 /**
67 * Overrides the {@link java.lang.Object#toString() Object.toString()}
68 * method to provide clean logging (every class should have this).
69 *
70 * This uses the uk.ac.ukc.iscream.util.NameFormat class
71 * to format the toString()
72 *
73 * @return the name of this class and its CVS revision
74 */
75 public String toString() {
76 return FormatName.getName(
77 _name,
78 getClass().getName(),
79 REVISION);
80 }
81
82 //---PRIVATE METHODS---
83
84 //---ACCESSOR/MUTATOR METHODS---
85
86 //---ATTRIBUTES---
87
88 /**
89 * This is the friendly identifier of the
90 * component this class is running in.
91 * eg, a Filter may be called "filter1",
92 * If this class does not have an owning
93 * component, a name from the configuration
94 * can be placed here. This name could also
95 * be changed to null for utility classes.
96 */
97 private String _name = ClientInterfaceMain.NAME;
98
99 /**
100 * This holds a reference to the
101 * system logger that is being used.
102 */
103 private Logger _logger = ReferenceManager.getInstance().getLogger();
104
105 /**
106 * A reference to the reference manager in use
107 */
108 private ReferenceManager _refman = ReferenceManager.getInstance();
109
110 /**
111 * A reference to the PacketSorter.
112 */
113 private PacketSorter _packetSorter;
114
115 /**
116 * The interval at which to monitor Queues.
117 */
118 private int _queueMonitorInterval;
119
120 //---STATIC ATTRIBUTES---
121
122 }