Skip to content

Commit

Permalink
Merge pull request #26 from Yasara123/master
Browse files Browse the repository at this point in the history
Upgrade Transport version and Improve sample 10
  • Loading branch information
mohanvive authored Aug 2, 2017
2 parents 2c9bfc6 + 36897a5 commit 3107fef
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ listenerConfigurations:
id: "default"
host: "0.0.0.0"
port: 9090
messageProcessorId: "MSF4J-CM-PROCESSOR"

-
id: "https"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -48,26 +48,25 @@ 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");
System.out.print(line + "\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();
}

Headers getHeaders() {
return headers;
}

boolean iaMessageArrive() {
boolean isMessageArrive() {
return isEventArraved.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void run() {

}

public void shutdown() {
void shutdown() {
if (server != null) {
server.stop(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package org.wso2.sp.http.server;

/**
* 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);

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 Headers :" + lst.getServerListner().getHeaders().toString());
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();
}
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,9 @@
<carbon.kernel.package.import.version.range>[5.0.0, 6.0.0)</carbon.kernel.package.import.version.range>
<carbon.kernel.pax.version>5.2.0-m3</carbon.kernel.pax.version>

<org.wso2.carbon.transport.http.netty.version>4.3.0-m2</org.wso2.carbon.transport.http.netty.version>
<org.wso2.carbon.transport.http.netty.version>4.4.26</org.wso2.carbon.transport.http.netty.version>
<carbon.transport.package.import.version.range>[4.0.0, 5.0.0)</carbon.transport.package.import.version.range>
<org.wso2.carbon.transport.version>4.3.0-m2</org.wso2.carbon.transport.version>
<org.wso2.carbon.transport.version>4.4.26</org.wso2.carbon.transport.version>

<carbon.messaging.version>2.3.2</carbon.messaging.version>
<carbon.messaging.package.import.version.range>[0.0.0, 3.0.0)</carbon.messaging.package.import.version.range>
Expand Down

0 comments on commit 3107fef

Please sign in to comment.