private static List<Pair<String, String>> insert(Class<?> actorClass) {
   if (actorClass != null) {
     final WebActor wa = actorClass.getAnnotation(WebActor.class);
     final List<Pair<String, String>> ret = new ArrayList<>(4);
     for (String httpP : wa.httpUrlPatterns()) addPattern(ret, httpP, "websocket");
     for (String wsP : wa.webSocketUrlPatterns()) addPattern(ret, wsP, "ws");
     classToUrlPatterns.put(actorClass, ret);
     return ret;
   }
   return null;
 }
Beispiel #2
0
    public void messageReceived(ChannelHandlerContext ctx, Object o) throws Exception {

      if (o instanceof HttpRequest) { // DefaultHttpRequest ) {
        queue.add((HttpRequest) o);
      } else if (o instanceof LastHttpContent) {

        HttpRequest req = queue.remove();

        req.getMethod();
        req.getUri();
        req.headers();

        LastHttpContent content = (LastHttpContent) o;

        ByteBuf buf = content.content();

        if (buf.readableBytes() > 0) {
          Gson gson = GsonFactory.createBuilder().create();

          Reader in = new InputStreamReader(new ByteBufInputStream(buf), "utf-8");
          Object v =
              gson.fromJson(in, Class.forName("com.logbook.logbook.resources.logs.LogEntryDTO"));
          System.out.println("v = " + v);
        }

        System.out.println(
            req.getMethod() + " " + req.getUri() + "    -- " + buf.readableBytes() + " bytes");

        HttpResponse r = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        r.headers().add("Content-Length", "0");
        ctx.write(r);

      } else {
        System.out.println("o = " + o + " : " + o.getClass());
      }
    }