diff --git a/.gitignore b/.gitignore
index 14801fc3..5710157d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -221,3 +221,4 @@ target/
.gradle/
*.iml
*.bin
+tempgen/
\ No newline at end of file
diff --git a/minbin-generate/pom.xml b/minbin-generate/pom.xml
index c7c74909..df8c5bfd 100644
--- a/minbin-generate/pom.xml
+++ b/minbin-generate/pom.xml
@@ -29,6 +29,12 @@
2.00
+
+ de.ruedigermoeller
+ temp-late
+ 1.0
+
+
com.beust
jcommander
diff --git a/minbin-generate/src/main/java/minbin/gen/GenContext.java b/minbin-generate/src/main/java/minbin/gen/GenContext.java
new file mode 100644
index 00000000..d6cb20e7
--- /dev/null
+++ b/minbin-generate/src/main/java/minbin/gen/GenContext.java
@@ -0,0 +1,12 @@
+package minbin.gen;
+
+import de.ruedigermoeller.serialization.FSTClazzInfo;
+
+/**
+ * Created by ruedi on 27.05.2014.
+ */
+public class GenContext {
+
+ public FSTClazzInfo clazz;
+
+}
diff --git a/minbin-generate/src/main/java/minbin/gen/MBGen.java b/minbin-generate/src/main/java/minbin/gen/MBGen.java
index 52373ed3..8912905c 100644
--- a/minbin-generate/src/main/java/minbin/gen/MBGen.java
+++ b/minbin-generate/src/main/java/minbin/gen/MBGen.java
@@ -2,6 +2,10 @@
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
+import de.rm.testserver.protocol.BasicValues;
+import de.rm.testserver.protocol.Meta;
+import de.ruedigermoeller.serialization.FSTConfiguration;
+import de.ruedigermoeller.template.TemplateExecutor;
import java.util.List;
@@ -12,8 +16,11 @@ public class MBGen {
private void generate() {
+ FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
+ GenContext ctx = new GenContext();
+ ctx.clazz = conf.getClassInfo(BasicValues.class);
if ( lang == Lang.javascript ) {
-
+ TemplateExecutor.Run("./src/main/resources/js/js.jsp",ctx);
}
}
diff --git a/minbin-generate/src/main/resources/js/js.jsp b/minbin-generate/src/main/resources/js/js.jsp
new file mode 100644
index 00000000..fc867200
--- /dev/null
+++ b/minbin-generate/src/main/resources/js/js.jsp
@@ -0,0 +1,29 @@
+<%
+ import java.util.*;
+ import java.io.*;
+ import de.ruedigermoeller.template.*;
+
+// add imports you need during generation =>
+ import minbin.gen.*;
+ import de.ruedigermoeller.serialization.*;
+
+// this header is always required to make it work. Cut & Paste this as template
+ public class CLAZZNAME implements IContextReceiver
+ {
+ public void receiveContext(Object o, PrintStream out) throws Exception
+ {
+ // asign your context
+ GenContext CTX = (GenContext)o;
+ FSTClazzInfo CLZ = CTX.clazz;
+ FSTClazzInfo.FSTFieldInfo fi[] = CLZ.getFieldInfo();
+%>
+function J<%+CLZ.getClazz().getSimpleName()%>(map) {
+<% for (int i = 0; i < fi.length; i++ ) {
+%> this.__<%+fi[i].getField().getName()%> = ;
+<% } /*for*/
+%>}
+<%
+ // this footer is always required (to match opening braces in header
+ }
+ }
+%>
\ No newline at end of file
diff --git a/testshell/pom.xml b/testshell/pom.xml
index 653c6b4a..c1aae319 100644
--- a/testshell/pom.xml
+++ b/testshell/pom.xml
@@ -39,9 +39,9 @@
- io.netty
- netty-all
- 4.0.19.Final
+ de.ruedigermoeller
+ netty2go
+ 1.01
diff --git a/testshell/src/main/java/de/rm/testserver/TestServer.java b/testshell/src/main/java/de/rm/testserver/TestServer.java
new file mode 100644
index 00000000..ecb30c7d
--- /dev/null
+++ b/testshell/src/main/java/de/rm/testserver/TestServer.java
@@ -0,0 +1,64 @@
+package de.rm.testserver;
+
+import de.rm.testserver.protocol.BasicValues;
+import de.rm.testserver.protocol.MirrorRequest;
+import de.rm.testserver.protocol.Person;
+import de.rm.testserver.protocol.TestRequest;
+import de.ruedigermoeller.serialization.FSTConfiguration;
+import io.netty.channel.ChannelHandlerContext;
+import org.nustaq.netty2go.NettyWSHttpServer;
+import org.nustaq.webserver.WebSocketHttpServer;
+
+import java.io.File;
+import java.io.Serializable;
+
+/**
+ * Created by ruedi on 27.05.14.
+ */
+public class TestServer extends WebSocketHttpServer {
+
+ FSTConfiguration conf = FSTConfiguration.createCrossPlatformConfiguration();
+ static String ClassMap[][] = new String[][] {
+ { "person", Person.class.getName() },
+ { "basicVals", BasicValues.class.getName() },
+ { "mirror", MirrorRequest.class.getName() },
+ { "testReq", TestRequest.class.getName() },
+ };
+
+
+ public TestServer(File contentRoot) {
+ super(contentRoot);
+ conf.registerCrossPlatformClassMapping(ClassMap);
+ }
+
+ @Override
+ public void onOpen(ChannelHandlerContext ctx) {
+ sendWSBinaryMessage( ctx, conf.asByteArray(new BasicValues()) );
+ }
+
+ @Override
+ public void onBinaryMessage(ChannelHandlerContext ctx, byte[] buffer) {
+ Object msg = null;
+ try {
+ msg = conf.asObject(buffer);
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ }
+ if (msg instanceof MirrorRequest) {
+ sendWSBinaryMessage(ctx, conf.asByteArray((Serializable) msg));
+ } else {
+ byte error[] = conf.asByteArray("Error");
+ sendWSBinaryMessage(ctx,error);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ int port;
+ if (args.length > 0) {
+ port = Integer.parseInt(args[0]);
+ } else {
+ port = 8887;
+ }
+ new NettyWSHttpServer(port, new TestServer(new File(".") )).run();
+ }
+}
diff --git a/testshell/src/main/java/de/rm/testserver/TestWSServer.java b/testshell/src/main/java/de/rm/testserver/TestWSServer.java
deleted file mode 100644
index 71cedc67..00000000
--- a/testshell/src/main/java/de/rm/testserver/TestWSServer.java
+++ /dev/null
@@ -1,266 +0,0 @@
-package de.rm.testserver;
-
-import de.rm.testserver.protocol.BasicValues;
-import de.rm.testserver.protocol.MirrorRequest;
-import de.rm.testserver.protocol.Person;
-import de.rm.testserver.protocol.TestRequest;
-import de.ruedigermoeller.serialization.FSTConfiguration;
-import io.netty.bootstrap.ServerBootstrap;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.*;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
-import io.netty.handler.codec.http.*;
-import io.netty.handler.codec.http.websocketx.*;
-import io.netty.util.CharsetUtil;
-
-import java.io.Serializable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static io.netty.handler.codec.http.HttpHeaders.Names.*;
-import static io.netty.handler.codec.http.HttpHeaders.*;
-import static io.netty.handler.codec.http.HttpMethod.*;
-import static io.netty.handler.codec.http.HttpResponseStatus.*;
-import static io.netty.handler.codec.http.HttpVersion.*;
-
-
-public class TestWSServer {
-
- public static String ClassMap[][] = new String[][] {
- { "person", Person.class.getName() },
- { "basicVals", BasicValues.class.getName() },
- { "mirror", MirrorRequest.class.getName() },
- { "testReq", TestRequest.class.getName() },
- };
-
- private final int port;
- FSTConfiguration conf;
-
- public TestWSServer(int port) {
- this.port = port;
- conf = FSTConfiguration.createCrossPlatformConfiguration();
- conf.registerCrossPlatformClassMapping( ClassMap );
- }
-
- public void run() throws Exception {
- EventLoopGroup bossGroup = new NioEventLoopGroup(1);
- EventLoopGroup workerGroup = new NioEventLoopGroup();
- try {
- ServerBootstrap b = new ServerBootstrap();
- b.group(bossGroup, workerGroup)
- .channel(NioServerSocketChannel.class)
- .childHandler(new WebSocketServerInitializer());
-
- Channel ch = b.bind(port).sync().channel();
- System.out.println("Web socket server started at port " + port + '.');
- System.out.println("Open your browser and navigate to http://localhost:" + port + '/');
-
- ch.closeFuture().sync();
- } finally {
- bossGroup.shutdownGracefully();
- workerGroup.shutdownGracefully();
- }
- }
-
- public class WebSocketServerInitializer extends ChannelInitializer {
- @Override
- public void initChannel(SocketChannel ch) throws Exception {
- ChannelPipeline pipeline = ch.pipeline();
- pipeline.addLast("codec-http", new HttpServerCodec());
- pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
- WebSocketServerHandler handler = new WebSocketServerHandler();
- pipeline.addLast("handler", handler);
- }
- }
-
- private static final Logger logger = Logger.getLogger(WebSocketServerHandler.class.getName());
- private static final String WEBSOCKET_PATH = "/websocket";
-
- public class WebSocketServerHandler extends SimpleChannelInboundHandler