Merge pull request #2 from informatik-ag-ngl/f/config

Added server.properties file
This commit is contained in:
delvh 2019-10-06 12:44:10 +02:00 committed by GitHub
commit bb4f8dffa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 124 additions and 106 deletions

View File

@ -1,7 +1,8 @@
package envoy.client;
import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
import java.util.Properties;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@ -30,6 +31,18 @@ public class EnvoyClient {
private ObjectFactory objectFactory = new ObjectFactory();
private DatatypeFactory datatypeFactory;
private static final Properties serverProps = new Properties();
static {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
serverProps.load(loader.getResourceAsStream("server.properties"));
} catch (IOException e) {
e.printStackTrace();
}
}
public EnvoyClient() {
try {
datatypeFactory = DatatypeFactory.newInstance();
@ -64,9 +77,12 @@ public class EnvoyClient {
}
// Send message
String url = String.format("%s:%s/envoy-server/rest/message/send",
serverProps.getProperty("server"),
serverProps.getProperty("port"));
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://kske.feste-ip.net:43315/envoy-server/rest/message/send");
Response response = target.request().post(Entity.entity(messages, "application/xml"));
WebTarget target = client.target(url);
Response response = target.request().post(Entity.entity(message, "application/xml"));
System.out.println("Response code: " + response.getStatus());
response.close();
client.close();

View File

@ -0,0 +1,2 @@
server=http://kske.feste-ip.net
port=43315