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/ClientInterfaceServant.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/clientinterface/ClientInterfaceServant.java (file contents):
Revision 1.2 by ajm, Mon Dec 4 18:42:19 2000 UTC vs.
Revision 1.3 by ajm, Wed Dec 13 12:57:38 2000 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines