diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..7103be7
--- /dev/null
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.text.custom_code_templates=
diff --git a/pom.xml b/pom.xml
index 3d1e16d..b85a456 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
informatik-ag-ngl
envoy-server-standalone
- 0.0.1-SNAPSHOT
+ 0.1-alpha
Envoy Server
https://github.com/informatik-ag-ngl/envoy-server-standalone
@@ -17,6 +17,19 @@
1.8
+
+
+ informatik-ag-ngl
+ envoy-common
+ 0.2-alpha
+
+
+ informatik-ag-ngl
+ java-nio-server
+ 0.0.1-SNAPSHOT
+
+
+
envoy-server-standalone
diff --git a/src/main/java/envoy/server/ObjectMessageProcessor.java b/src/main/java/envoy/server/ObjectMessageProcessor.java
new file mode 100644
index 0000000..77a086b
--- /dev/null
+++ b/src/main/java/envoy/server/ObjectMessageProcessor.java
@@ -0,0 +1,31 @@
+package envoy.server;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+import com.jenkov.nioserver.IMessageProcessor;
+import com.jenkov.nioserver.Message;
+import com.jenkov.nioserver.WriteProxy;
+
+/**
+ * Project: envoy-server-standalone
+ * File: ObjectMessageProcessor.java
+ * Created: 28.12.2019
+ *
+ * @author Kai S. K. Engelbart
+ * @since Envoy Server Standalone v0.1-alpha
+ */
+public class ObjectMessageProcessor implements IMessageProcessor {
+
+ @Override
+ public void process(Message message, WriteProxy writeProxy) {
+ try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(message.sharedArray, message.offset + 4, message.length - 4))) {
+ Object obj = in.readObject();
+ // TODO: Process pipeline
+ System.out.println("Read object: " + obj.toString());
+ } catch (IOException | ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/envoy/server/ObjectMessageReader.java b/src/main/java/envoy/server/ObjectMessageReader.java
new file mode 100644
index 0000000..9a20c7f
--- /dev/null
+++ b/src/main/java/envoy/server/ObjectMessageReader.java
@@ -0,0 +1,66 @@
+package envoy.server;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.jenkov.nioserver.IMessageReader;
+import com.jenkov.nioserver.Message;
+import com.jenkov.nioserver.MessageBuffer;
+import com.jenkov.nioserver.Socket;
+
+/**
+ * Project: envoy-server-standalone
+ * File: ObjectMessageReader.java
+ * Created: 28.12.2019
+ *
+ * @author Kai S. K. Engelbart
+ * @since Envoy Server Standalone v0.1-alpha
+ */
+public class ObjectMessageReader implements IMessageReader {
+
+ private List completeMessages = new ArrayList<>();
+ private Message nextMessage;
+ private MessageBuffer messageBuffer;
+
+ @Override
+ public void init(MessageBuffer messageBuffer) {
+ this.messageBuffer = messageBuffer;
+ nextMessage = messageBuffer.getMessage();
+ }
+
+ @Override
+ public void read(Socket socket, ByteBuffer buffer) throws IOException {
+ socket.read(buffer);
+ buffer.flip();
+
+ if (!buffer.hasRemaining()) {
+ buffer.clear();
+ return;
+ }
+
+ nextMessage.writeToMessage(buffer);
+
+ // Get message length
+ if (nextMessage.length - nextMessage.offset < 4) return;
+ int length = fromByteArray(nextMessage.sharedArray, nextMessage.offset) + 4;
+
+ if (nextMessage.length - nextMessage.offset >= length) {
+ Message message = messageBuffer.getMessage();
+ message.writePartialMessageToMessage(nextMessage, nextMessage.offset + length);
+ completeMessages.add(nextMessage);
+ nextMessage = message;
+ }
+
+ buffer.clear();
+ }
+
+ private int fromByteArray(byte[] bytes, int offset) {
+ return ((bytes[offset] & 0xFF) << 24) | ((bytes[offset + 1] & 0xFF) << 16) | ((bytes[offset + 2] & 0xFF) << 8)
+ | ((bytes[offset + 3] & 0xFF) << 0);
+ }
+
+ @Override
+ public List getMessages() { return completeMessages; }
+}
\ No newline at end of file
diff --git a/src/main/java/envoy/server/Startup.java b/src/main/java/envoy/server/Startup.java
new file mode 100644
index 0000000..1c0932b
--- /dev/null
+++ b/src/main/java/envoy/server/Startup.java
@@ -0,0 +1,21 @@
+package envoy.server;
+
+import java.io.IOException;
+
+import com.jenkov.nioserver.Server;
+
+/**
+ * Project: envoy-server-standalone
+ * File: Startup.java
+ * Created: 24.12.2019
+ *
+ * @author Kai S. K. Engelbart
+ * @since Envoy Server Standalone v0.1-alpha
+ */
+public class Startup {
+
+ public static void main(String[] args) throws IOException {
+ Server server = new Server(8080, () -> new ObjectMessageReader(), new ObjectMessageProcessor());
+ server.start();
+ }
+}
\ No newline at end of file