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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/filtermanager/HostListener.java (file contents):
Revision 1.2 by tdb, Wed Nov 29 19:19:12 2000 UTC vs.
Revision 1.4 by ajm, Tue Dec 12 19:17:02 2000 UTC

# Line 4 | Line 4 | package uk.ac.ukc.iscream.filtermanager;
4   //---IMPORTS---
5   import uk.ac.ukc.iscream.core.*;
6   import uk.ac.ukc.iscream.filter.*;
7 < import java.net.Socket;
8 < import java.net.ServerSocket;
9 < import java.io.OutputStream;
10 < import java.io.IOException;
11 < import java.net.InetAddress;
12 < import java.net.UnknownHostException;
13 < import org.omg.CORBA.*;
14 < import org.omg.CosNaming.*;
7 > import uk.ac.ukc.iscream.util.*;
8 > import java.net.*;
9 > import java.io.*;
10  
11   /**
12   * A socket listener to listen for new hosts registering with the system.
# Line 37 | Line 32 | class HostListener extends Thread {
32          /**
33       * Constructs a new listener
34       *
35 <     * @param logger a reference to the logger we are using
41 <     * @param configManager a reference to the ConfigurationManager we are using
42 <         * @param port The port that the server will listen on.
35 >         * @param listenPort The port that the server will listen on.
36           */
37 <    public HostListener(Logger logger, ConfigurationManager configManager, int port, NamingContextExt ncRef) {
38 <        _logger = logger;
46 <        _ncRef = ncRef;
47 <        _configManager = configManager;
48 <        _port = port;
37 >    public HostListener(int listenPort) {
38 >        _listenPort = listenPort;
39          _logger.write(toString(), Logger.SYSINIT, "started");
40      }
41  
# Line 61 | Line 51 | class HostListener extends Thread {
51           * and then passing them off to other processes to deal with.
52           */
53      public void run(){
54 <        ServerSocket listenPort=null;
54 >        ServerSocket listenSocket=null;
55                  // We use this boolean so we can break out of the while loop if we want
56          boolean run = true;
57          try{
58                          // Setup the ServerSocket so that clients can connect
59 <            listenPort = new ServerSocket(_port);
59 >            listenSocket = new ServerSocket(_listenPort);
60          }
61          catch(IOException e){
62          }
# Line 75 | Line 65 | class HostListener extends Thread {
65                          _logger.write(toString(), Logger.SYSMSG, "Server listening on "
66                                                                                  +InetAddress.getLocalHost().getHostName()
67                                                                                  +"/"+InetAddress.getLocalHost().getHostAddress()
68 <                                                                                +" port "+listenPort.getLocalPort());
68 >                                                                                +" port "+listenSocket.getLocalPort());
69                  }
70                  catch(UnknownHostException e){
71                          _logger.write(toString(), Logger.SYSMSG, "Server listening on UnknownHost "
72 <                                                                                +"port "+listenPort.getLocalPort());
72 >                                                                                +"port "+listenSocket.getLocalPort());
73                  }
74                  // Loop round constantly until we decide to stop
75          while(run){
# Line 87 | Line 77 | class HostListener extends Thread {
77              try{
78                  _logger.write(toString(), Logger.SYSMSG, "Waiting for Connection");
79                                  // This will block until a host connects - at which point we get a Socket
80 <                hostSocket = listenPort.accept();
80 >                hostSocket = listenSocket.accept();
81                  _logger.write(toString(), Logger.SYSMSG, "Connection accepted from: " + hostSocket.toString());
82              }
83              catch(IOException e){
# Line 98 | Line 88 | class HostListener extends Thread {
88              if(run){
89                                  try {
90                                      // Setup the HostInit so it can carry on communications with the host
91 <                    HostInit init = new HostInit(hostSocket, _configManager, _logger, _ncRef);
91 >                    HostInit init = new HostInit(hostSocket);
92                                      // and start it
93                      init.start();
94                  } catch (IOException e) {
# Line 114 | Line 104 | class HostListener extends Thread {
104       * Overrides the {@link java.lang.Object#toString() Object.toString()}
105       * method to provide clean logging (every class should have this).
106       *
107 +     * This uses the uk.ac.ukc.iscream.util.NameFormat class
108 +     * to format the toString()
109 +     *
110       * @return the name of this class and its CVS revision
111       */
112      public String toString() {
113 <        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
113 >        return FormatName.getName(
114 >            _name,
115 >            this.getClass().getName(),
116 >            REVISION);
117      }
118  
119   //---PRIVATE METHODS---
# Line 127 | Line 123 | class HostListener extends Thread {
123   //---ATTRIBUTES---
124      
125      /**
126 <     * A reference to the logger the system is using
126 >     * This holds a reference to the
127 >     * system logger that is being used.
128       */
129 <    Logger _logger;
129 >    private Logger _logger = ReferenceManager.getInstance().getLogger();
130      
131      /**
132 <     * A reference to the configurator the system is using
132 >     * This is the friendly identifier of the
133 >     * component this class is running in.
134 >     * eg, a Filter may be called "filter1",
135 >     * If this class does not have an owning
136 >     * component,  a name from the configuration
137 >     * can be placed here.  This name could also
138 >     * be changed to null for utility classes.
139       */
140 <    ConfigurationManager _configManager;
140 >    private String _name = FilterManager.NAME;
141      
142      /**
143           * The port on which the server should listen.
144           */
145 <    private int _port;
143 <    
144 <    private NamingContextExt _ncRef;
145 >    private int _listenPort;
146      
147   //---STATIC ATTRIBUTES---
148  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines