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.4 by tdb, Thu Nov 23 01:44:41 2000 UTC vs.
Revision 1.18 by tdb, Tue May 29 17:02:35 2001 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines