diff --git a/src/main/java/envoy/client/EnvoyClient.java b/src/main/java/envoy/client/EnvoyClient.java
index 41c32d0..38b7248 100644
--- a/src/main/java/envoy/client/EnvoyClient.java
+++ b/src/main/java/envoy/client/EnvoyClient.java
@@ -1,107 +1,123 @@
-package envoy.client;
-
-import java.time.Instant;
-import java.util.Arrays;
-
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
-
-import envoy.schema.Message;
-import envoy.schema.Messages;
-import envoy.schema.ObjectFactory;
-
-/**
- * Project: envoy-client
- * File: EnvoyClient.java
- * Created: 28 Sep 2019
- * Author: Kai S. K. Engelbart & Maximilian Käfer
- */
-
-public class EnvoyClient {
-
- private ObjectFactory objectFactory = new ObjectFactory();
- private DatatypeFactory datatypeFactory;
-
- public EnvoyClient() {
- try {
- datatypeFactory = DatatypeFactory.newInstance();
- } catch (DatatypeConfigurationException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Sends a message with text content to the server.
- * Because sending a request is a blocking operation, it is executed
- * asynchronously.
- *
- * @param sender Name of the sender
- * @param recipient Name of the recipient
- * @param textContent Content (text) of the message
- */
- public void sendMessage(Message message) {
- new Thread(() -> {
- // Wrap single message into messages list
- Messages messages = wrapMessage(message);
-
- // Print message XML to console
- JAXBContext jc;
- try {
- jc = JAXBContext.newInstance("envoy.schema");
- Marshaller m = jc.createMarshaller();
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
- m.marshal(messages, System.out);
- } catch (JAXBException e) {
- e.printStackTrace();
- }
-
- // 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(messages, "application/xml"));
- System.out.println("Response code: " + response.getStatus());
- response.close();
- client.close();
- }).start();
- }
-
- /**
- * Creates a {@link Message} object serializable to XML.
- *
- * @param senderID The ID of the sender
- * @param recipientID The ID of the recipient
- * @param textContent The content (text) of the message
- * @return Prepared {@link Message} object
- */
- public Message createMessage(String senderID, String recipientID, String textContent) {
- Message.MetaData metaData = objectFactory.createMessageMetaData();
- metaData.setSender(senderID);
- metaData.setRecipient(recipientID);
- metaData.setState(false);
- metaData.setDate(datatypeFactory.newXMLGregorianCalendar(Instant.now().toString()));
-
- Message.Content content = objectFactory.createMessageContent();
- content.setType("text");
- content.setText(textContent);
-
- Message message = objectFactory.createMessage();
- message.setMetaData(metaData);
- message.getContent().add(content);
-
- return message;
- }
-
- public Messages wrapMessage(Message... messages) {
- Messages wrapper = objectFactory.createMessages();
- wrapper.getMessage().addAll(Arrays.asList(messages));
- return wrapper;
- }
+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;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+
+import envoy.schema.Message;
+import envoy.schema.Messages;
+import envoy.schema.ObjectFactory;
+
+/**
+ * Project: envoy-client
+ * File: EnvoyClient.java
+ * Created: 28 Sep 2019
+ * Author: Kai S. K. Engelbart & Maximilian Käfer
+ */
+
+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();
+ } catch (DatatypeConfigurationException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Sends a message with text content to the server.
+ * Because sending a request is a blocking operation, it is executed
+ * asynchronously.
+ *
+ * @param sender Name of the sender
+ * @param recipient Name of the recipient
+ * @param textContent Content (text) of the message
+ */
+ public void sendMessage(Message message) {
+ new Thread(() -> {
+ // Wrap single message into messages list
+ Messages messages = wrapMessage(message);
+
+ // Print message XML to console
+ JAXBContext jc;
+ try {
+ jc = JAXBContext.newInstance("envoy.schema");
+ Marshaller m = jc.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ m.marshal(messages, System.out);
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+
+ // 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(url);
+ Response response = target.request().post(Entity.entity(message, "application/xml"));
+ System.out.println("Response code: " + response.getStatus());
+ response.close();
+ client.close();
+ }).start();
+ }
+
+ /**
+ * Creates a {@link Message} object serializable to XML.
+ *
+ * @param senderID The ID of the sender
+ * @param recipientID The ID of the recipient
+ * @param textContent The content (text) of the message
+ * @return Prepared {@link Message} object
+ */
+ public Message createMessage(String senderID, String recipientID, String textContent) {
+ Message.MetaData metaData = objectFactory.createMessageMetaData();
+ metaData.setSender(senderID);
+ metaData.setRecipient(recipientID);
+ metaData.setState(false);
+ metaData.setDate(datatypeFactory.newXMLGregorianCalendar(Instant.now().toString()));
+
+ Message.Content content = objectFactory.createMessageContent();
+ content.setType("text");
+ content.setText(textContent);
+
+ Message message = objectFactory.createMessage();
+ message.setMetaData(metaData);
+ message.getContent().add(content);
+
+ return message;
+ }
+
+ public Messages wrapMessage(Message... messages) {
+ Messages wrapper = objectFactory.createMessages();
+ wrapper.getMessage().addAll(Arrays.asList(messages));
+ return wrapper;
+ }
}
\ No newline at end of file
diff --git a/src/main/resources/server.properties b/src/main/resources/server.properties
new file mode 100644
index 0000000..6b0ae8f
--- /dev/null
+++ b/src/main/resources/server.properties
@@ -0,0 +1,2 @@
+server=http://kske.feste-ip.net
+port=43315
\ No newline at end of file