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
Revision: 1.17
Committed: Thu Mar 15 17:02:29 2001 UTC (23 years, 2 months ago) by tdb
Branch: MAIN
CVS Tags: PROJECT_COMPLETION
Changes since 1.16: +4 -3 lines
Log Message:
Fixed a long standing problem with the Filter not returning it's own host
address (fqdn) on windows machines. It's a bit of a workaround, but at least it
works :)

File Contents

# User Rev Content
1 tdb 1.1 //---PACKAGE DECLARATION---
2 tdb 1.16 package uk.org.iscream.filter;
3 tdb 1.1
4     //---IMPORTS---
5 tdb 1.16 import uk.org.iscream.core.*;
6     import uk.org.iscream.componentmanager.*;
7     import uk.org.iscream.filter.*;
8     import uk.org.iscream.util.*;
9 tdb 1.4 import java.net.InetAddress;
10 tdb 1.1
11     /**
12 ajm 1.11 * Passes inbound data from other Filters to a FilterThread
13 tdb 1.1 *
14 tdb 1.13 * @author $Author: tdb1 $
15 tdb 1.17 * @version $Id: FilterServant.java,v 1.16 2001/03/14 23:25:29 tdb1 Exp $
16 tdb 1.1 */
17     class FilterServant extends FilterPOA {
18    
19     //---FINAL ATTRIBUTES---
20    
21     /**
22     * The current CVS revision of this class
23     */
24 tdb 1.17 public final String REVISION = "$Revision: 1.16 $";
25 tdb 1.1
26     //---STATIC METHODS---
27    
28     //---CONSTRUCTORS---
29    
30     /**
31 tdb 1.14 * Creates a new FilterServant.
32 tdb 1.1 *
33 tdb 1.14 * @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 tdb 1.1 */
37 tdb 1.15 public FilterServant(int TCPListenPort, int UDPListenPort, Queue queue) {
38 tdb 1.9 _TCPListenPort = TCPListenPort;
39     _UDPListenPort = UDPListenPort;
40 tdb 1.12 _queue = queue;
41 tdb 1.15 _logger.write(toString(), Logger.SYSINIT, "started");
42 tdb 1.1 }
43 tdb 1.9
44 tdb 1.1 //---PUBLIC METHODS---
45    
46     /**
47     * Method to receive a string over corba.
48     *
49 tdb 1.14 * @param xml the String of XML to queue
50 tdb 1.1 */
51     public void receiveXML(String xml) {
52 tdb 1.12 _queue.add(xml);
53 tdb 1.1 }
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 tdb 1.16 * This uses the uk.org.iscream.util.NameFormat class
60 ajm 1.11 * to format the toString()
61     *
62 tdb 1.1 * @return the name of this class and its CVS revision
63     */
64     public String toString() {
65 ajm 1.11 return FormatName.getName(
66     _name,
67     getClass().getName(),
68     REVISION);
69 tdb 1.1 }
70    
71     //---PRIVATE METHODS---
72    
73     //---ACCESSOR/MUTATOR METHODS---
74    
75 ajm 1.11 /**
76     * Provides information to the FilterManager
77     */
78 tdb 1.4 public String getUDPPort() {
79 tdb 1.9 return new Integer(_UDPListenPort).toString();
80 tdb 1.4 }
81    
82 ajm 1.11 /**
83     * Provides information to the FilterManager
84     */
85 tdb 1.4 public String getTCPPort() {
86 tdb 1.9 return new Integer(_TCPListenPort).toString();
87 tdb 1.4 }
88    
89 ajm 1.11 /**
90     * Provides information to the FilterManager
91     */
92 tdb 1.4 public String getHostName() {
93     try {
94 tdb 1.17 // hacky fix for windows boxes, where getHostName() returns the NetBIOS name !
95     return InetAddress.getByName(InetAddress.getLocalHost().getHostAddress()).getHostName();
96 tdb 1.4 } catch (java.net.UnknownHostException e) {
97 tdb 1.9 _logger.write(toString(), Logger.ERROR, e.getMessage());
98 tdb 1.4 }
99     return null;
100     }
101    
102    
103 tdb 1.1 //---ATTRIBUTES---
104    
105     /**
106 ajm 1.11 * 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 tdb 1.1 */
114 ajm 1.11 private String _name = FilterMain.NAME;
115    
116 tdb 1.1 /**
117 ajm 1.11 * This holds a reference to the
118     * system logger that is being used.
119 tdb 1.1 */
120 ajm 1.11 private Logger _logger = ReferenceManager.getInstance().getLogger();
121 tdb 1.3
122     /**
123 tdb 1.12 * Our Queue object
124 tdb 1.3 */
125 tdb 1.12 private Queue _queue;
126 tdb 1.4
127 ajm 1.11 /**
128     * The UDP port we're listening on
129     */
130 tdb 1.9 private int _UDPListenPort;
131 ajm 1.11
132     /**
133     * The TCP port we're listening on
134     */
135 tdb 1.9 private int _TCPListenPort;
136 tdb 1.1
137     //---STATIC ATTRIBUTES---
138    
139     }