------------------------------------------------------------ revno: 1300 committer: Bob Jolliffe <b...@bobj-laptop> branch nick: trunk timestamp: Fri 2010-01-08 22:42:23 +0000 message: Workaround hack to configure jetty listen port on dhis2-live modified: dhis-live/readme.txt dhis-live/src/main/java/org/hisp/dhis/TrayApp.java dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java
-- lp:dhis2 https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk Your team DHIS 2 developers is subscribed to branch lp:dhis2. To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-live/readme.txt' --- dhis-live/readme.txt 2009-04-22 21:34:35 +0000 +++ dhis-live/readme.txt 2010-01-08 22:42:23 +0000 @@ -49,10 +49,13 @@ hibernate.hbm2ddl.auto = update -------------------------------------------------------------------- -TODO: -1. sort out proper logging! -2. make a nice "instrument panel" showing application status when you +The default port that the embedded jetty server listens on is 8080. If this +clashes with other services on your system it can be reconfigured by creating a +file conf/jetty.port which contains simply the desired server port, eg 8888. + + +TODO +1. make a nice "instrument panel" showing application status when you click on the tray icon -3. test with different databases. Currently should work with mysql, postgres and h2, though the latter (and JavaDB) is targeted. -4. Put some nicer icons (animated gifs) +2. make richer configuration of jetty through web.xml or similar === modified file 'dhis-live/src/main/java/org/hisp/dhis/TrayApp.java' --- dhis-live/src/main/java/org/hisp/dhis/TrayApp.java 2009-09-28 17:25:39 +0000 +++ dhis-live/src/main/java/org/hisp/dhis/TrayApp.java 2010-01-08 22:42:23 +0000 @@ -121,7 +121,7 @@ } appServer = new WebAppServer(); - appServer.init(installDir,this); + appServer.init(installDir, this); try { appServer.start(); } catch (Exception ex) { === modified file 'dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java' --- dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java 2009-09-28 18:11:45 +0000 +++ dhis-live/src/main/java/org/hisp/dhis/WebAppServer.java 2010-01-08 22:42:23 +0000 @@ -33,7 +33,12 @@ package org.hisp.dhis; +import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,7 +58,10 @@ public static final String DHIS_DIR = "/webapps/dhis"; public static final String BIRT_DIR = "/webapps/birt"; public static final String BIRT_CONTEXT_PATH = "/birt"; - + public static final String JETTY_PORT_CONF = "/conf/jetty.port"; + + public static final int DEFAULT_JETTY_PORT = 8080; + private static final Log log = LogFactory.getLog( WebAppServer.class ); protected Server server; @@ -67,7 +75,15 @@ public void init(String installDir, LifeCycle.Listener serverListener) throws Exception { - connector.setPort(Integer.getInteger("jetty.port",8080).intValue()); + + try { + connector.setPort(this.getPortFromConfig(installDir + JETTY_PORT_CONF)); + } catch (Exception ex) { + log.info("Couldn't load port number from " + installDir + JETTY_PORT_CONF); + log.info("Trying default of " + DEFAULT_JETTY_PORT); + connector.setPort(DEFAULT_JETTY_PORT); + } + server.setConnectors(new Connector[]{connector}); ContextHandlerCollection handlers = new ContextHandlerCollection(); @@ -106,4 +122,16 @@ { return connector.getPort(); } + + // read integer value from file + public int getPortFromConfig(String conf) throws FileNotFoundException, IOException + { + Reader r = new BufferedReader(new FileReader(conf)); + char[] cbuf = new char[10]; + r.read(cbuf); + String numstr = String.copyValueOf(cbuf); + Integer port = Integer.valueOf(numstr.trim()); + return port.intValue(); + } + }
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp