diff --git a/release/scenarium-oauth.jar b/release/scenarium-oauth.jar index b015fbb..9c43aa8 100644 Binary files a/release/scenarium-oauth.jar and b/release/scenarium-oauth.jar differ diff --git a/src/io/scenarium/oauth/ConfigVariable.java b/src/io/scenarium/oauth/ConfigVariable.java index 1834f9b..d7ff0b5 100644 --- a/src/io/scenarium/oauth/ConfigVariable.java +++ b/src/io/scenarium/oauth/ConfigVariable.java @@ -15,10 +15,14 @@ public class ConfigVariable { } public static String getDBPassword() { - return System.getProperty("io.scenarium.web.oauth.db.port", "klkhj456gkgtkhjgvkujfhjgkjhgsdfhb3467465fgdhdesfgh"); + return System.getProperty("io.scenarium.web.oauth.db.password", "klkhj456gkgtkhjgvkujfhjgkjhgsdfhb3467465fgdhdesfgh"); } public static String getDBName() { return System.getProperty("io.scenarium.web.oauth.db.name", "oauth"); } + + public static String getlocalAddress() { + return System.getProperty("io.scenarium.web.oauth.address", "http://localhost:17080/oauth/api/"); + } } diff --git a/src/io/scenarium/oauth/WebLauncher.java b/src/io/scenarium/oauth/WebLauncher.java index ad6f263..6097b3e 100755 --- a/src/io/scenarium/oauth/WebLauncher.java +++ b/src/io/scenarium/oauth/WebLauncher.java @@ -9,20 +9,40 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import javax.ws.rs.core.UriBuilder; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.lang.System.Logger.Level; import java.net.URI; import java.sql.SQLException; +import java.util.Properties; public class WebLauncher { private WebLauncher() {} - public static final URI BASE_URI = getBaseURI(); public static DBConfig dbConfig; private static URI getBaseURI() { - return UriBuilder.fromUri("http://localhost/oauth/api/").port(17080).build(); + return UriBuilder.fromUri(ConfigVariable.getlocalAddress()).build(); } public static void main(String[] args) { + try { + FileInputStream propFile = new FileInputStream( "properties.txt"); + Properties p = new Properties(System.getProperties()); + p.load(propFile); + for (String name : p.stringPropertyNames()) { + String value = p.getProperty(name); + // inject property if not define in cmdline: + if (System.getProperty(name) == null) { + System.setProperty(name, value); + } + } + } catch (FileNotFoundException e) { + System.out.println("File of environment variable not found: 'properties.txt'"); + } catch (IOException e) { + e.printStackTrace(); + } + ResourceConfig rc = new ResourceConfig(); // remove cors ==> all time called by an other system... rc.register(new CORSFilter()); @@ -51,12 +71,12 @@ public class WebLauncher { entry = null; */ try { - HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, rc); + HttpServer server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc); server.start(); System.out.println(String.format( "Jersey app started at " + "%s\nHit enter to stop it...", - BASE_URI, BASE_URI)); + getBaseURI(), getBaseURI())); System.in.read(); server.shutdownNow();