Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java @ 30:88972c6daa4f
Added a cleanup thread which periodically removes
outdated artifacts from database and calls there
endOfLife() method.
artifacts/trunk@70 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 10 Sep 2009 23:16:18 +0000 |
parents | d5dc2900392f |
children | 86d2a843e588 |
line wrap: on
line source
package de.intevation.artifactdatabase.rest; import org.restlet.Component; import org.restlet.data.Protocol; import de.intevation.artifacts.ArtifactDatabase; import de.intevation.artifactdatabase.Config; import de.intevation.artifactdatabase.rest.RestApp; import org.apache.log4j.Logger; /** * @author Sascha L. Teichmann (sascha.teichmann@intevation) */ public class Standalone { private static Logger logger = Logger.getLogger(Standalone.class); public static final String REST_PORT = "/artifact-database/rest-server/port/text()"; public static final int DEFAULT_PORT = 8181; public static void startAsServer(ArtifactDatabase db) { String portString = Config.getStringXPath(REST_PORT); int port = DEFAULT_PORT; if (portString != null) { try { port = Integer.parseInt(portString); if (port < 0) { throw new NumberFormatException(); } } catch (NumberFormatException nfe) { logger.error("rest port is not a positive integer value.", nfe); return; } } RestApp app = new RestApp(db); Component component = new Component(); component.getServers().add(Protocol.HTTP, port); component.getDefaultHost().attach(app); logger.info("Starting rest HTTP server on port " + port); try { component.start(); } catch (Exception e) { logger.error(e.getLocalizedMessage(), e); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: