From 4973f88c34f496bff8ed03efc15d5be42efdf31c Mon Sep 17 00:00:00 2001 From: Yasara Dissanayake Date: Tue, 1 Aug 2017 17:15:15 +0530 Subject: [PATCH 1/4] Upgrade transport version --- .../carbon-home/conf/transports/netty-transports.yml | 1 + pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/distribution/carbon-home/conf/transports/netty-transports.yml b/modules/distribution/carbon-home/conf/transports/netty-transports.yml index a12f27614..c453a5d84 100644 --- a/modules/distribution/carbon-home/conf/transports/netty-transports.yml +++ b/modules/distribution/carbon-home/conf/transports/netty-transports.yml @@ -89,6 +89,7 @@ listenerConfigurations: id: "default" host: "0.0.0.0" port: 9090 + messageProcessorId: "MSF4J-CM-PROCESSOR" - id: "https" diff --git a/pom.xml b/pom.xml index 5a7e3f142..9be8afa3e 100644 --- a/pom.xml +++ b/pom.xml @@ -676,9 +676,9 @@ [5.0.0, 6.0.0) 5.2.0-m3 - 4.3.0-m2 + 4.4.26 [4.0.0, 5.0.0) - 4.3.0-m2 + 4.4.26 2.3.2 [0.0.0, 3.0.0) From 95630b68b9e86ec75039faa71d9fe47ab5357c29 Mon Sep 17 00:00:00 2001 From: Yasara Dissanayake Date: Tue, 1 Aug 2017 22:32:55 +0530 Subject: [PATCH 2/4] Update Sample 10 for proper display --- .../java/org/wso2/sp/http/server/HttpServerListener.java | 1 - .../wso2/sp/http/server/HttpServerListenerHandler.java | 2 +- .../java/org/wso2/sp/http/server/HttpServerMain.java | 9 ++++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListener.java b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListener.java index 6cf826f43..903a1bfa3 100644 --- a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListener.java +++ b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListener.java @@ -51,7 +51,6 @@ public void handle(HttpExchange t) throws IOException { strBld = new StringBuilder(); while ((line = in.readLine()) != null) { strBld = strBld.append(line).append("\n"); - System.out.print(line + "\n"); } logger.info("Event Arrived: " + strBld.toString()); diff --git a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListenerHandler.java b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListenerHandler.java index cb7ecd907..b7a2d89fd 100644 --- a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListenerHandler.java +++ b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListenerHandler.java @@ -58,7 +58,7 @@ public void run() { } - public void shutdown() { + void shutdown() { if (server != null) { server.stop(1); } diff --git a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java index c89d7ca94..28957f6a5 100644 --- a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java +++ b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java @@ -1,5 +1,11 @@ package org.wso2.sp.http.server; +import com.sun.net.httpserver.Headers; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + /** * This is a sample HTTP server to receive events through HTTP/HTTPS protocol */ @@ -13,7 +19,8 @@ public static void main(String[] args) throws InterruptedException { Thread.sleep(100); } logger.info("Received Event :" + lst.getServerListner().getData()); - logger.info("Received Event Headers :" + lst.getServerListner().getHeaders().toString()); + logger.info("Received Event Headers key set:" + lst.getServerListner().getHeaders().keySet().toString()); + logger.info("Received Event Headers value set:" + lst.getServerListner().getHeaders().values().toString()); lst.shutdown(); } } From 1ec8a9fb610216adde0b82d076d2ea1cb5754124 Mon Sep 17 00:00:00 2001 From: Yasara Dissanayake Date: Tue, 1 Aug 2017 22:48:45 +0530 Subject: [PATCH 3/4] Sample Refactoring --- .../main/java/org/wso2/sp/http/server/HttpServerMain.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java index 28957f6a5..240ce9a3d 100644 --- a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java +++ b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java @@ -1,13 +1,7 @@ package org.wso2.sp.http.server; -import com.sun.net.httpserver.Headers; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - /** - * This is a sample HTTP server to receive events through HTTP/HTTPS protocol + * This is a sample HTTP server to receive events through HTTP/HTTPS protocol. */ public class HttpServerMain { private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(HttpServerMain.class); From 36897a5c2eb194b3b4232a85f992ce3cafc0e900 Mon Sep 17 00:00:00 2001 From: Yasara Dissanayake Date: Tue, 1 Aug 2017 23:21:56 +0530 Subject: [PATCH 4/4] Refactoring for sample --- .../org/wso2/sp/http/server/HttpServerListener.java | 12 ++++++------ .../java/org/wso2/sp/http/server/HttpServerMain.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListener.java b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListener.java index 903a1bfa3..795c643c0 100644 --- a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListener.java +++ b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerListener.java @@ -35,7 +35,7 @@ public class HttpServerListener implements HttpHandler { private static final Logger logger = Logger.getLogger(HttpServerListener.class); private AtomicBoolean isEventArraved = new AtomicBoolean(false); - private StringBuilder strBld; + private StringBuilder strBld = new StringBuilder(); private Headers headers; HttpServerListener() { @@ -48,17 +48,17 @@ public void handle(HttpExchange t) throws IOException { headers = t.getRequestHeaders(); InputStream is = t.getRequestBody(); BufferedReader in = new BufferedReader(new InputStreamReader(is)); // initiating - strBld = new StringBuilder(); + String name = null; while ((line = in.readLine()) != null) { - strBld = strBld.append(line).append("\n"); + strBld = strBld.append(line).append(" , "); + name = line; } - logger.info("Event Arrived: " + strBld.toString()); + logger.info("Event Name Arrived: " + name); isEventArraved.set(true); } String getData() { - isEventArraved = new AtomicBoolean(false); return strBld.toString(); } @@ -66,7 +66,7 @@ Headers getHeaders() { return headers; } - boolean iaMessageArrive() { + boolean isMessageArrive() { return isEventArraved.get(); } diff --git a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java index 240ce9a3d..1dadb3ecb 100644 --- a/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java +++ b/modules/samples/sample-clients/http-server/src/main/java/org/wso2/sp/http/server/HttpServerMain.java @@ -9,10 +9,10 @@ public class HttpServerMain { public static void main(String[] args) throws InterruptedException { while (true) { HttpServerListenerHandler lst = new HttpServerListenerHandler(8080); - while (!lst.getServerListner().iaMessageArrive()) { + while (!lst.getServerListner().isMessageArrive()) { Thread.sleep(100); } - logger.info("Received Event :" + lst.getServerListner().getData()); + logger.info("Received Event Names:" + lst.getServerListner().getData()); logger.info("Received Event Headers key set:" + lst.getServerListner().getHeaders().keySet().toString()); logger.info("Received Event Headers value set:" + lst.getServerListner().getHeaders().values().toString()); lst.shutdown();