--- projects/cms/source/server/uk/org/iscream/cms/server/filtermanager/HostListener.java 2001/03/13 02:19:47 1.6 +++ projects/cms/source/server/uk/org/iscream/cms/server/filtermanager/HostListener.java 2001/03/13 13:40:26 1.7 @@ -15,7 +15,7 @@ import java.io.*; * of the HostInit class, which handles further communication. * * @author $Author: tdb $ - * @version $Id: HostListener.java,v 1.6 2001/03/13 02:19:47 tdb Exp $ + * @version $Id: HostListener.java,v 1.7 2001/03/13 13:40:26 tdb Exp $ */ class HostListener extends Thread { @@ -24,7 +24,7 @@ class HostListener extends Thread { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.6 $"; + public final String REVISION = "$Revision: 1.7 $"; //---STATIC METHODS--- @@ -35,16 +35,13 @@ class HostListener extends Thread { * * @param listenPort The port that the server will listen on. */ - public HostListener(int listenPort) { + public HostListener() { // set the Thread name setName("filtermanager.HostListener"); - _listenPort = listenPort; _logger.write(toString(), Logger.SYSINIT, "started"); } - - //---PUBLIC METHODS--- /** @@ -59,22 +56,33 @@ class HostListener extends Thread { // We use this boolean so we can break out of the while loop if we want boolean run = true; try{ + // Work out the port we want + int listenPort = Integer.parseInt(ConfigurationProxy.getInstance().getProperty("FilterManager", "FilterManager.listenPort")); // Setup the ServerSocket so that clients can connect - listenSocket = new ServerSocket(_listenPort); - } - catch(IOException e){ - } - // Log what machine/port we're listening on - try{ - _logger.write(toString(), Logger.SYSMSG, "Server listening on " + listenSocket = new ServerSocket(listenPort); + _logger.write(toString(), Logger.SYSMSG, "Server listening on " +InetAddress.getLocalHost().getHostName() +"/"+InetAddress.getLocalHost().getHostAddress() +" port "+listenSocket.getLocalPort()); - } - catch(UnknownHostException e){ + + } + catch(UnknownHostException e){ _logger.write(toString(), Logger.SYSMSG, "Server listening on UnknownHost " +"port "+listenSocket.getLocalPort()); } + catch(IOException e){ + _logger.write(toString(), Logger.FATAL, "IO Error, can't start FilterManager :"+e); + run = false; + } + catch(PropertyNotFoundException e){ + _logger.write(toString(), Logger.FATAL, "Fatal Error, can't find config :"+e); + run = false; + } + catch(NumberFormatException e){ + _logger.write(toString(), Logger.FATAL, "Invalid port configuration found :"+e); + run = false; + } + // Loop round constantly until we decide to stop while(run){ Socket hostSocket=null; @@ -142,11 +150,6 @@ class HostListener extends Thread { * be changed to null for utility classes. */ private String _name = FilterManager.NAME; - - /** - * The port on which the server should listen. - */ - private int _listenPort; //---STATIC ATTRIBUTES---