From 4a0f6fae447f6c33fb51b95339639fc667b1cd4d Mon Sep 17 00:00:00 2001 From: joshua bauer Date: Thu, 29 Nov 2018 14:01:53 -0800 Subject: [PATCH] Reworked session attachment handler injection. --- .../sinistral/proteus/ProteusApplication.java | 16 ++++++-- .../proteus/server/ServerRequest.java | 40 +++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/sinistral/proteus/ProteusApplication.java b/src/main/java/io/sinistral/proteus/ProteusApplication.java index 52f9bce..d6d5cfa 100644 --- a/src/main/java/io/sinistral/proteus/ProteusApplication.java +++ b/src/main/java/io/sinistral/proteus/ProteusApplication.java @@ -87,9 +87,7 @@ public class ProteusApplication @Inject public Config config; - - @Inject(optional=true) - public SessionAttachmentHandler sessionAttachmentHandler; + public List> registeredModules = new ArrayList<>(); @@ -280,6 +278,16 @@ public void buildServer() handler = rootHandler; } + SessionAttachmentHandler sessionAttachmentHandler = null; + + try + { + sessionAttachmentHandler = injector.getInstance(SessionAttachmentHandler.class); + } catch (Exception e) + { + log.info("No session attachment handler found."); + } + if(sessionAttachmentHandler != null) { log.info("Using session attachment handler."); @@ -586,6 +594,6 @@ public List getPorts() return ports; } - + } diff --git a/src/main/java/io/sinistral/proteus/server/ServerRequest.java b/src/main/java/io/sinistral/proteus/server/ServerRequest.java index bad7763..bd7bbd0 100644 --- a/src/main/java/io/sinistral/proteus/server/ServerRequest.java +++ b/src/main/java/io/sinistral/proteus/server/ServerRequest.java @@ -245,6 +245,46 @@ public SecurityContext getSecurityContext() { return exchange.getSecurityContext(); } + + /** + * @return the exchange + */ + public HttpServerExchange getExchange() + { + return exchange; + } + + /** + * @return the path + */ + public String getPath() + { + return path; + } + + /** + * @return the contentType + */ + public String getContentType() + { + return contentType; + } + + /** + * @return the method + */ + public String getMethod() + { + return method; + } + + /** + * @return the accept + */ + public String getAccept() + { + return accept; + } }