Added server.properties

This commit is contained in:
derharry333 2019-10-05 14:37:24 +02:00
parent 4a7bfd35f2
commit 87738d0117
2 changed files with 24 additions and 5 deletions

View File

@ -1,6 +1,8 @@
package envoy.client;
import java.io.IOException;
import java.time.Instant;
import java.util.Properties;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@ -27,6 +29,19 @@ public class EnvoyClient {
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();
@ -58,9 +73,11 @@ public class EnvoyClient {
}
// Send message
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(message, "application/xml"));
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(url);
Response response = target.request().post(Entity.entity(message, "application/xml"));
System.out.println("Response code: " + response.getStatus());
response.close();
client.close();
@ -76,8 +93,8 @@ public class EnvoyClient {
* @return Prepared {@link Message} object
*/
public Message createMessage(String senderID, String recipientID, String textContent) {
ObjectFactory factory = new ObjectFactory();
Message.MetaData metaData = factory.createMessageMetaData();
ObjectFactory factory = new ObjectFactory();
Message.MetaData metaData = factory.createMessageMetaData();
metaData.setSender(senderID);
metaData.setRecipient(recipientID);
metaData.setState(false);

View File

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