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 java.util.LinkedList; |
8 |
< |
import java.util.Iterator; |
9 |
< |
|
10 |
< |
/** |
11 |
< |
* A client interface servant |
12 |
< |
* |
13 |
< |
* @author $Author$ |
14 |
< |
* @version $Id$ |
15 |
< |
*/ |
16 |
< |
class ClientInterfaceServant extends ClientInterfacePOA { |
17 |
< |
|
18 |
< |
//---FINAL ATTRIBUTES--- |
19 |
< |
|
20 |
< |
/** |
21 |
< |
* The current CVS revision of this class |
22 |
< |
*/ |
23 |
< |
public final String REVISION = "$Revision$"; |
24 |
< |
|
25 |
< |
//---STATIC METHODS--- |
26 |
< |
|
27 |
< |
//---CONSTRUCTORS--- |
28 |
< |
|
29 |
< |
/** |
30 |
< |
* Creates a new ClientInterfaceServant. |
31 |
< |
* |
32 |
< |
*/ |
33 |
< |
public ClientInterfaceServant() { |
34 |
< |
// here would be a nice place to pass in local clients |
35 |
< |
_clients = new LinkedList(); |
36 |
< |
_logger.write(this.toString(), Logger.SYSINIT, "created"); |
37 |
< |
} |
38 |
< |
|
39 |
< |
//---PUBLIC METHODS--- |
40 |
< |
|
41 |
< |
/** |
42 |
< |
* Method to receive a string over corba. |
43 |
< |
* |
44 |
< |
* @param xml the String of XML to print out |
45 |
< |
*/ |
46 |
< |
public void receiveXML(String xml) { |
47 |
< |
_logger.write(this.toString(), Logger.DEBUG, "got data - " + xml); |
48 |
< |
_logger.write(this.toString(), Logger.DEBUG, "passing to clients"); |
49 |
< |
Iterator i = _clients.iterator(); |
50 |
< |
while(i.hasNext()) { |
51 |
< |
((ClientHandler) i.next()).receiveXML(xml); |
52 |
< |
} |
53 |
< |
} |
54 |
< |
|
55 |
< |
public void register(ClientHandler newClient) { |
56 |
< |
_logger.write(this.toString(), Logger.SYSMSG, "registered client - " + newClient.toString()); |
57 |
< |
_clients.add(newClient); |
58 |
< |
} |
59 |
< |
|
60 |
< |
/** |
61 |
< |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
62 |
< |
* method to provide clean logging (every class should have this). |
63 |
< |
* |
64 |
< |
* @return the name of this class and its CVS revision |
65 |
< |
*/ |
66 |
< |
public String toString() { |
67 |
< |
return this.getClass().getName() + "{" + _name + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
68 |
< |
} |
69 |
< |
|
70 |
< |
//---PRIVATE METHODS--- |
71 |
< |
|
72 |
< |
//---ACCESSOR/MUTATOR METHODS--- |
73 |
< |
|
74 |
< |
//---ATTRIBUTES--- |
75 |
< |
|
76 |
< |
/** |
77 |
< |
* Reference to a Logger |
78 |
< |
*/ |
79 |
< |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
80 |
< |
|
81 |
< |
/** |
82 |
< |
* Our name |
83 |
< |
*/ |
84 |
< |
private String _name = ReferenceManager.getInstance().getName(); |
85 |
< |
|
86 |
< |
private LinkedList _clients; |
87 |
< |
|
88 |
< |
//---STATIC ATTRIBUTES--- |
89 |
< |
|
90 |
< |
} |
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.org.iscream.cms.server.clientinterface; |
22 |
> |
|
23 |
> |
//---IMPORTS--- |
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 |
> |
* 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 |
> |
* |
34 |
> |
* @author $Author$ |
35 |
> |
* @version $Id$ |
36 |
> |
*/ |
37 |
> |
class ClientInterfaceServant extends ClientInterfacePOA { |
38 |
> |
|
39 |
> |
//---FINAL ATTRIBUTES--- |
40 |
> |
|
41 |
> |
/** |
42 |
> |
* The current CVS revision of this class |
43 |
> |
*/ |
44 |
> |
public final String REVISION = "$Revision$"; |
45 |
> |
|
46 |
> |
//---STATIC METHODS--- |
47 |
> |
|
48 |
> |
//---CONSTRUCTORS--- |
49 |
> |
|
50 |
> |
/** |
51 |
> |
* Creates a new ClientInterfaceServant. |
52 |
> |
* |
53 |
> |
* @param packetSorter a reference to the PacketSorter object being used |
54 |
> |
*/ |
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. |
64 |
> |
* |
65 |
> |
* @param xml the XML string to be queued for processing. |
66 |
> |
*/ |
67 |
> |
public void receiveXML(String xml) { |
68 |
> |
_queue.add(xml); |
69 |
> |
} |
70 |
> |
|
71 |
> |
/** |
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.org.iscream.cms.server.util.NameFormat class |
76 |
> |
* to format the toString() |
77 |
> |
* |
78 |
> |
* @return the name of this class and its CVS revision |
79 |
> |
*/ |
80 |
> |
public String toString() { |
81 |
> |
return FormatName.getName( |
82 |
> |
_name, |
83 |
> |
getClass().getName(), |
84 |
> |
REVISION); |
85 |
> |
} |
86 |
> |
|
87 |
> |
//---PRIVATE METHODS--- |
88 |
> |
|
89 |
> |
//---ACCESSOR/MUTATOR METHODS--- |
90 |
> |
|
91 |
> |
//---ATTRIBUTES--- |
92 |
> |
|
93 |
> |
/** |
94 |
> |
* This is the friendly identifier of the |
95 |
> |
* component this class is running in. |
96 |
> |
* eg, a Filter may be called "filter1", |
97 |
> |
* If this class does not have an owning |
98 |
> |
* component, a name from the configuration |
99 |
> |
* can be placed here. This name could also |
100 |
> |
* be changed to null for utility classes. |
101 |
> |
*/ |
102 |
> |
private String _name = ClientInterfaceMain.NAME; |
103 |
> |
|
104 |
> |
/** |
105 |
> |
* This holds a reference to the |
106 |
> |
* system logger that is being used. |
107 |
> |
*/ |
108 |
> |
private Logger _logger = ReferenceManager.getInstance().getLogger(); |
109 |
> |
|
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 |
> |
|
118 |
> |
} |