ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/rootfilter/CorbaClientListenerServant.java
Revision: 1.1
Committed: Mon May 5 22:05:14 2003 UTC (21 years ago) by tdb
Branch: MAIN
Log Message:
Tidy up of the client interface code - more commonly known as the
"right hand side of the server". Right since the start the filter
side of the server has been nice and tree like - every Filter sent
data to another Filter. At the top of the tree there was a "special"
Filter known as the RootFilter, which to the other Filters just
looked like a normal Filter. This was nice, and simple, and expandable.

The Client Interface on the other hand was messy. The root filter
had some hacky wrapper threads which pulled from a queue and pushed
to the relevant client interfaces (one for real time stuff, and the
other for databases). There was no simple room for expandability -
it was all hardwired to do just what was needed at the time.

This commit changes that. A Client Interface now connects to another
Client Interface, with a special one being found in the RootFilter
(yes, maybe that needs a name change now :-). So we can chain client
interfaces, and move other bits and bobs around in the server - for
example, alerting no longer needs to be connected to the Client
Interface, it can connect straight to the RootFilter (or, wherever
the config tells it ;).

Hopefully this sanitizes the underlying layout of the server a bit.

As a final note, I dropped the DBInterface. This used to insert
data in to a MySQL database. We've long since stopped using that,
and it's fallen behind and is way out of date. For now, it's gone
in to the attic.

File Contents

# Content
1 /*
2 * i-scream central monitoring system
3 * http://www.i-scream.org.uk
4 * Copyright (C) 2000-2002 i-scream
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 //---PACKAGE DECLARATION---
22 package uk.org.iscream.cms.server.rootfilter;
23
24 //---IMPORTS---
25 import uk.org.iscream.cms.server.core.*;
26 import uk.org.iscream.cms.util.*;
27 import uk.org.iscream.cms.server.componentmanager.*;
28 import uk.org.iscream.cms.server.clientinterface.*;
29
30 /**
31 * This class, a servant, listens for incoming connections from CORBA based
32 * clients. Once it receives a connection it creates and assigns a CorbaControlHandler
33 * object to it. The CorbaControlHandler will then handle all requests on behalf of the
34 * client, and will send the client data.
35 *
36 * @author $Author$
37 * @version $Id$
38 */
39 class CorbaClientListenerServant extends CorbaClientListenerPOA {
40
41 //---FINAL ATTRIBUTES---
42
43 /**
44 * The current CVS revision of this class
45 */
46 public final String REVISION = "$Revision: 1.1 $";
47
48 //---STATIC METHODS---
49
50 //---CONSTRUCTORS---
51
52 /**
53 * Creates a new CorbaClientListenerServant.
54 *
55 * @param queue a reference to the Queue being used
56 */
57 public CorbaClientListenerServant(Queue queue) {
58 _queue = queue;
59 _logger.write(toString(), Logger.SYSINIT, "created");
60 }
61
62 //---PUBLIC METHODS---
63
64 /**
65 * Allows a CORBA client to connect to the server.
66 *
67 * @param client a reference to the "servant" part of the connecting client.
68 * @param name a name to identify the client.
69 * @return a CorbaControlHandler reference.
70 */
71 public CorbaControlHandler connect(Client client, String name) {
72 CorbaControlHandlerServant cchServant = new CorbaControlHandlerServant(_queue, client, name);
73 org.omg.CORBA.Object objRef;
74 try {
75 objRef = _refman.getRootPOA().servant_to_reference(cchServant);
76 } catch (Exception e) {
77 objRef = null;
78 _logger.write(toString(), Logger.ERROR, "Error creating CorbaControlHandler: "+e);
79 }
80 CorbaControlHandler corbaHandler = CorbaControlHandlerHelper.narrow(objRef);
81 return corbaHandler;
82 }
83
84 /**
85 * Overrides the {@link java.lang.Object#toString() Object.toString()}
86 * method to provide clean logging (every class should have this).
87 *
88 * This uses the uk.org.iscream.cms.util.NameFormat class
89 * to format the toString()
90 *
91 * @return the name of this class and its CVS revision
92 */
93 public String toString() {
94 return FormatName.getName(
95 _name,
96 getClass().getName(),
97 REVISION);
98 }
99
100 //---PRIVATE METHODS---
101
102 //---ACCESSOR/MUTATOR METHODS---
103
104 //---ATTRIBUTES---
105
106 /**
107 * This is the friendly identifier of the
108 * component this class is running in.
109 * eg, a Filter may be called "filter1",
110 * If this class does not have an owning
111 * component, a name from the configuration
112 * can be placed here. This name could also
113 * be changed to null for utility classes.
114 */
115 private String _name = RootFilter.NAME;
116
117 /**
118 * This holds a reference to the
119 * system logger that is being used.
120 */
121 private Logger _logger = ReferenceManager.getInstance().getLogger();
122
123 /**
124 * A reference to the reference manager in use
125 */
126 private ReferenceManager _refman = ReferenceManager.getInstance();
127
128 /**
129 * A reference to our Queue.
130 */
131 private Queue _queue;
132
133 //---STATIC ATTRIBUTES---
134
135 }