[DEV] think it work

This commit is contained in:
Edouard DUPIN 2020-10-21 23:51:53 +02:00
parent 213184187f
commit 1449038d02
3 changed files with 29 additions and 5 deletions

Binary file not shown.

View File

@ -15,10 +15,14 @@ public class ConfigVariable {
} }
public static String getDBPassword() { 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() { public static String getDBName() {
return System.getProperty("io.scenarium.web.oauth.db.name", "oauth"); 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/");
}
} }

View File

@ -9,20 +9,40 @@ import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import javax.ws.rs.core.UriBuilder; 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.lang.System.Logger.Level;
import java.net.URI; import java.net.URI;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties;
public class WebLauncher { public class WebLauncher {
private WebLauncher() {} private WebLauncher() {}
public static final URI BASE_URI = getBaseURI();
public static DBConfig dbConfig; public static DBConfig dbConfig;
private static URI getBaseURI() { 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) { 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(); ResourceConfig rc = new ResourceConfig();
// remove cors ==> all time called by an other system... // remove cors ==> all time called by an other system...
rc.register(new CORSFilter()); rc.register(new CORSFilter());
@ -51,12 +71,12 @@ public class WebLauncher {
entry = null; entry = null;
*/ */
try { try {
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, rc); HttpServer server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
server.start(); server.start();
System.out.println(String.format( System.out.println(String.format(
"Jersey app started at " + "%s\nHit enter to stop it...", "Jersey app started at " + "%s\nHit enter to stop it...",
BASE_URI, BASE_URI)); getBaseURI(), getBaseURI()));
System.in.read(); System.in.read();
server.shutdownNow(); server.shutdownNow();