1 |
+ |
/* |
2 |
+ |
* i-scream central monitoring system |
3 |
+ |
* Copyright (C) 2000-2002 i-scream |
4 |
+ |
* |
5 |
+ |
* This program is free software; you can redistribute it and/or |
6 |
+ |
* modify it under the terms of the GNU General Public License |
7 |
+ |
* as published by the Free Software Foundation; either version 2 |
8 |
+ |
* of the License, or (at your option) any later version. |
9 |
+ |
* |
10 |
+ |
* This program is distributed in the hope that it will be useful, |
11 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
+ |
* GNU General Public License for more details. |
14 |
+ |
* |
15 |
+ |
* You should have received a copy of the GNU General Public License |
16 |
+ |
* along with this program; if not, write to the Free Software |
17 |
+ |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
+ |
*/ |
19 |
+ |
|
20 |
|
//---PACKAGE DECLARATION--- |
21 |
< |
package uk.ac.ukc.iscream.clientinterface; |
21 |
> |
package uk.org.iscream.cms.server.clientinterface; |
22 |
|
|
23 |
|
//---IMPORTS--- |
24 |
< |
import uk.ac.ukc.iscream.core.*; |
25 |
< |
import uk.ac.ukc.iscream.util.*; |
26 |
< |
import uk.ac.ukc.iscream.componentmanager.*; |
8 |
< |
import java.util.LinkedList; |
9 |
< |
import java.util.Iterator; |
24 |
> |
import uk.org.iscream.cms.server.core.*; |
25 |
> |
import uk.org.iscream.cms.server.util.*; |
26 |
> |
import uk.org.iscream.cms.server.componentmanager.*; |
27 |
|
|
28 |
|
/** |
29 |
< |
* A client interface servant |
30 |
< |
* This keeps a track of all connected clients to |
31 |
< |
* the system and passes data to their handlers. |
29 |
> |
* This class, a servant, listens for incoming data sent to it |
30 |
> |
* using CORBA. This data is then queued in the PacketSorter. |
31 |
> |
* It does no processing of the data, and is only a seperate |
32 |
> |
* class to keep the CORBA stuff out of the PacketSorter. |
33 |
|
* |
16 |
– |
* Currently it has limited client management facilities. |
17 |
– |
* |
34 |
|
* @author $Author$ |
35 |
|
* @version $Id$ |
36 |
|
*/ |
49 |
|
|
50 |
|
/** |
51 |
|
* Creates a new ClientInterfaceServant. |
52 |
+ |
* |
53 |
+ |
* @param packetSorter a reference to the PacketSorter object being used |
54 |
|
*/ |
55 |
< |
public ClientInterfaceServant() { |
56 |
< |
// here would be a nice place to pass in local clients |
39 |
< |
_clients = new LinkedList(); |
55 |
> |
public ClientInterfaceServant(PacketSorter packetSorter) { |
56 |
> |
_queue = packetSorter.getQueue(); |
57 |
|
_logger.write(toString(), Logger.SYSINIT, "created"); |
58 |
|
} |
59 |
|
|
60 |
|
//---PUBLIC METHODS--- |
61 |
|
|
62 |
|
/** |
63 |
< |
* Method to receive a string over corba. |
63 |
> |
* Method to receive a string over CORBA. |
64 |
|
* |
65 |
< |
* @param xml the String of XML to print out |
65 |
> |
* @param xml the XML string to be queued for processing. |
66 |
|
*/ |
67 |
|
public void receiveXML(String xml) { |
68 |
< |
Iterator i = _clients.iterator(); |
52 |
< |
while(i.hasNext()) { |
53 |
< |
((ClientHandler) i.next()).receiveXML(xml); |
54 |
< |
} |
68 |
> |
_queue.add(xml); |
69 |
|
} |
70 |
|
|
71 |
|
/** |
58 |
– |
* Simply adds clients to a linked list |
59 |
– |
* |
60 |
– |
* @param newClient a reference to the client to add |
61 |
– |
*/ |
62 |
– |
public void register(ClientHandler newClient) { |
63 |
– |
_logger.write(toString(), Logger.SYSMSG, "registered client - " + newClient.toString()); |
64 |
– |
_clients.add(newClient); |
65 |
– |
} |
66 |
– |
|
67 |
– |
/** |
72 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
73 |
|
* method to provide clean logging (every class should have this). |
74 |
|
* |
75 |
< |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
75 |
> |
* This uses the uk.org.iscream.cms.server.util.NameFormat class |
76 |
|
* to format the toString() |
77 |
|
* |
78 |
|
* @return the name of this class and its CVS revision |
107 |
|
*/ |
108 |
|
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
109 |
|
|
110 |
< |
private LinkedList _clients; |
110 |
> |
/** |
111 |
> |
* A reference to the Queue we'll add data to. This is |
112 |
> |
* actually located in the PacketSorter. |
113 |
> |
*/ |
114 |
> |
private Queue _queue; |
115 |
|
|
116 |
|
//---STATIC ATTRIBUTES--- |
117 |
|
|