ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filter/FilterServant.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filter/FilterServant.java (file contents):
Revision 1.5 by tdb, Fri Nov 24 13:04:14 2000 UTC vs.
Revision 1.13 by tdb, Thu Jan 18 23:15:50 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 + package uk.ac.ukc.iscream.filter;
3  
4   //---IMPORTS---
5   import uk.ac.ukc.iscream.core.*;
6 + import uk.ac.ukc.iscream.componentmanager.*;
7   import uk.ac.ukc.iscream.filter.*;
8 + import uk.ac.ukc.iscream.util.*;
9   import java.net.InetAddress;
10  
11   /**
12 < * A test FilterServant, just prints it out.
12 > * Passes inbound data from other Filters to a FilterThread
13   *
14   * @author  $Author$
15   * @version $Id$
# Line 29 | Line 32 | class FilterServant extends FilterPOA {
32       *
33       * @param logger a Logger to use
34       */
35 <    public FilterServant(Logger logger, Filter parent, String name, String TCPPort, String UDPPort) {
36 <        _logRef = logger;
37 <        _name = name;
38 <        _parent = parent;
36 <        _TCPPort = TCPPort;
37 <        _UDPPort = UDPPort;
38 <        _logRef.write(this.toString(), Logger.SYSINIT, "created");
35 >    public FilterServant(int TCPListenPort, int UDPListenPort, Queue queue) {    
36 >        _TCPListenPort = TCPListenPort;
37 >        _UDPListenPort = UDPListenPort;
38 >        _queue = queue;
39      }
40 <
40 >    
41   //---PUBLIC METHODS---
42  
43      /**
# Line 46 | Line 46 | class FilterServant extends FilterPOA {
46       * @param xml the String of XML to print out
47       */
48      public void receiveXML(String xml) {
49 <        _logRef.write(this.toString(), Logger.SYSMSG, "received XML: "+xml);
50 <        FilterThread t = new FilterThread(xml, _parent, _logRef);
51 <        t.start();
49 >        _queue.add(xml);
50      }
51      
52      /**
53       * Overrides the {@link java.lang.Object#toString() Object.toString()}
54       * method to provide clean logging (every class should have this).
55       *
56 +     * This uses the uk.ac.ukc.iscream.util.NameFormat class
57 +     * to format the toString()
58 +     *
59       * @return the name of this class and its CVS revision
60       */
61      public String toString() {
62 <        return this.getClass().getName() + "{" + _name + "}(" + REVISION.substring(11, REVISION.length() - 2) + ")";
62 >        return FormatName.getName(
63 >            _name,
64 >            getClass().getName(),
65 >            REVISION);
66      }
67  
68   //---PRIVATE METHODS---
69  
70   //---ACCESSOR/MUTATOR METHODS---
71  
72 +    /**
73 +     * Provides information to the FilterManager
74 +     */
75      public String getUDPPort() {
76 <        return _UDPPort;
76 >        return new Integer(_UDPListenPort).toString();
77      }
78      
79 +    /**
80 +     * Provides information to the FilterManager
81 +     */
82      public String getTCPPort() {
83 <        return _TCPPort;
83 >        return new Integer(_TCPListenPort).toString();
84      }
85      
86 +    /**
87 +     * Provides information to the FilterManager
88 +     */
89      public String getHostName() {
90          try {
91              return InetAddress.getLocalHost().getHostName();
92          } catch (java.net.UnknownHostException e) {
93 <            _logRef.write(toString(), Logger.ERROR, e.getMessage());
93 >            _logger.write(toString(), Logger.ERROR, e.getMessage());
94          }
95          return null;
96      }
# Line 86 | Line 99 | class FilterServant extends FilterPOA {
99   //---ATTRIBUTES---
100  
101      /**
102 <     * Reference to a Logger
102 >     * This is the friendly identifier of the
103 >     * component this class is running in.
104 >     * eg, a Filter may be called "filter1",
105 >     * If this class does not have an owning
106 >     * component,  a name from the configuration
107 >     * can be placed here.  This name could also
108 >     * be changed to null for utility classes.
109       */
110 <    private Logger _logRef;
111 <    
110 >    private String _name = FilterMain.NAME;
111 >
112      /**
113 <     * Our name
113 >     * This holds a reference to the
114 >     * system logger that is being used.
115       */
116 <    private String _name;
116 >    private Logger _logger = ReferenceManager.getInstance().getLogger();
117  
118      /**
119 <     * Our parent filter
119 >     * Our Queue object
120       */
121 <    private Filter _parent;
121 >    private Queue _queue;
122      
123 <    private String _UDPPort;
124 <    private String _TCPPort;
123 >    /**
124 >     * The UDP port we're listening on
125 >     */
126 >    private int _UDPListenPort;
127 >    
128 >    /**
129 >     * The TCP port we're listening on
130 >     */
131 >    private int _TCPListenPort;
132      
133   //---STATIC ATTRIBUTES---
134  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines