Skip to content

Commit

Permalink
closed issues: #25, #26, #27
Browse files Browse the repository at this point in the history
  • Loading branch information
greg committed Dec 28, 2015
1 parent 022efcb commit 5e5d280
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
12 changes: 6 additions & 6 deletions build/web/WEB-INF/classes/HelloService.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@

# host and port required for standalone mode
#protocol=http
http-host=127.0.0.1
http-host=0.0.0.0
http-port=8080

# storage adapter
SimpleStorageIface=com.gskorupa.cricket.example.SimpleStorageStandard
SimpleStorageIface-param1=123
HelloStorageIface=com.gskorupa.cricket.example.HelloStorageStandard
HelloStorageIface-param1=123

# logger adapter
SimpleLoggerIface=com.gskorupa.cricket.example.SimpleLoggerStandard
HelloLoggerIface=com.gskorupa.cricket.example.HelloLoggerStandard

# http adapter (listening on ${protocol}://${host}:${port}${context}
SimpleHttpAdapterIface=com.gskorupa.cricket.example.SimpleHttpAdapter
SimpleHttpAdapterIface-context=/
HelloHttpAdapterIface=com.gskorupa.cricket.example.HelloHttpAdapter
HelloHttpAdapterIface-context=/

2 changes: 1 addition & 1 deletion src/java/HelloService.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# host and port required for standalone mode
#protocol=http
http-host=127.0.0.1
http-host=0.0.0.0
http-port=8080

# storage adapter
Expand Down
16 changes: 13 additions & 3 deletions src/java/com/gskorupa/cricket/Httpd.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,22 @@
public class Httpd {

private Kernel service;
public HttpServer server=null;
public HttpServer server = null;

public Httpd(Kernel service) {
this.service = service;
String host = service.getHost();
if (null != host) {
if (host.isEmpty() || "0.0.0.0".equals(host) || "*".equals(host)) {
host = null;
}
}
try {
server = HttpServer.create(new InetSocketAddress(service.getPort()), 0);
if (host == null) {
server = HttpServer.create(new InetSocketAddress(service.getPort()), 0);
} else {
server = HttpServer.create(new InetSocketAddress(host, service.getPort()), 0);
}
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -43,7 +53,7 @@ public Httpd(Kernel service) {
if (service.fields[i] instanceof com.gskorupa.cricket.in.HttpAdapter) {
System.out.print("creating context: ");
System.out.println(((HttpAdapter) service.fields[i]).getContext());
context=server.createContext(((HttpAdapter) service.fields[i]).getContext(), (com.sun.net.httpserver.HttpHandler) service.fields[i]);
context = server.createContext(((HttpAdapter) service.fields[i]).getContext(), (com.sun.net.httpserver.HttpHandler) service.fields[i]);
context.getFilters().add(new ParameterFilter());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class HelloHttpAdapter extends HttpAdapter implements HelloHttpAdapterIface, Adapter {

public void loadProperties(Properties properties) {
setContext(properties.getProperty("SimpleHttpAdapterIface-context"));
setContext(properties.getProperty("HelloHttpAdapterIface-context"));
System.out.println("context=" + getContext());
getServiceHooks();
}
Expand Down
8 changes: 4 additions & 4 deletions src/java/com/gskorupa/cricket/example/HelloService.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ public HelloResult getData() {
return r;
}

@AdapterHook(handlerClassName = "SimpleHttpAdapterIface", requestMethod = "GET")
@AdapterHook(handlerClassName = "HelloHttpAdapterIface", requestMethod = "GET")
public Object doGet(RequestObject request) {
return sendEcho(request);
}

@AdapterHook(handlerClassName = "SimpleHttpAdapterIface", requestMethod = "POST")
@AdapterHook(handlerClassName = "HelloHttpAdapterIface", requestMethod = "POST")
public Object doPost(RequestObject request) {
return sendEcho(request);
}

@AdapterHook(handlerClassName = "SimpleHttpAdapterIface", requestMethod = "PUT")
@AdapterHook(handlerClassName = "HelloHttpAdapterIface", requestMethod = "PUT")
public Object doPut(RequestObject request) {
return sendEcho(request);
}

@AdapterHook(handlerClassName = "SimpleHttpAdapterIface", requestMethod = "DELETE")
@AdapterHook(handlerClassName = "HelloHttpAdapterIface", requestMethod = "DELETE")
public Object doDelete(RequestObject request) {
return sendEcho(request);
}
Expand Down
Binary file modified templates/standalone/lib/cricket-1.0.0.jar
Binary file not shown.

0 comments on commit 5e5d280

Please sign in to comment.