diff --git a/README.md b/README.md
index 463dce2..c8c9119 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,15 @@ Request and response content types are `application/json`.
### GET /status
-Returns default options with given optimizations and Closure Compiler version.
+Returns Closure Compiler versions.
+
+Response:
+
+- `compilerVersions` String - Closure Compiler version
+
+### GET /options
+
+Returns default options with given optimizations.
Query parameters:
@@ -56,7 +64,6 @@ Query parameters:
Response:
- `options` Object - is of type [CompilerOptions](https://github.com/google/closure-compiler/blob/v20160208/src/com/google/javascript/jscomp/CompilerOptions.java), compiler options
-- `compilerVersions` String - Closure Compiler version
### GET /externs
diff --git a/pom-jar.xml b/pom-jar.xml
index 67151a5..f94d29a 100644
--- a/pom-jar.xml
+++ b/pom-jar.xml
@@ -10,7 +10,7 @@
com.github.monai
cc-web-runner-parent
- 1.0.5
+ 1.0.6
pom.xml
diff --git a/pom-war.xml b/pom-war.xml
index 5aafafe..551288f 100644
--- a/pom-war.xml
+++ b/pom-war.xml
@@ -10,7 +10,7 @@
com.github.monai
cc-web-runner-parent
- 1.0.5
+ 1.0.6
pom.xml
diff --git a/pom.xml b/pom.xml
index 8edf4cc..1fe3152 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,14 +6,15 @@
com.github.monai
cc-web-runner-parent
pom
- 1.0.5
+ 1.0.6
1.8
- 9.3.7.v20160115
+ 9.3.8.v20160314
2.22.2
1.3
- v20160208
+ v20160315
+ 1.1
1.4.0
3.5.1
com.github.monai.Application
@@ -105,5 +106,10 @@
closure-compiler
${closure-compiler.version}
+
+ org.tinylog
+ slf4j-binding
+ ${tinylog.version}
+
diff --git a/src/main/java/com/github/monai/AccessLog.java b/src/main/java/com/github/monai/AccessLog.java
new file mode 100644
index 0000000..8ea18dc
--- /dev/null
+++ b/src/main/java/com/github/monai/AccessLog.java
@@ -0,0 +1,29 @@
+package com.github.monai;
+
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.RequestLog;
+import org.eclipse.jetty.server.Response;
+import org.pmw.tinylog.Level;
+import org.pmw.tinylog.Logger;
+
+public class AccessLog implements RequestLog {
+ @Override
+ public void log(Request request, Response response) {
+ Logger.info(request);
+
+ if (Logger.getLevel().compareTo(Level.DEBUG) == 1) {
+ Logger.info(formatResponse(response));
+ } else {
+ Logger.debug(response.toString());
+ }
+ }
+
+ private String formatResponse(Response response) {
+ return String.format("%s[%s %d %s]@%x",
+ response.getClass().getSimpleName(),
+ response.getHttpChannel().getRequest().getHttpVersion(),
+ response.getStatus(),
+ response.getReason(),
+ response.hashCode());
+ }
+}
diff --git a/src/main/java/com/github/monai/Application.java b/src/main/java/com/github/monai/Application.java
index a75e497..9633b56 100644
--- a/src/main/java/com/github/monai/Application.java
+++ b/src/main/java/com/github/monai/Application.java
@@ -11,6 +11,7 @@
import org.eclipse.jetty.servlet.ServletHolder;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
+import org.pmw.tinylog.Logger;
import javax.ws.rs.ApplicationPath;
import java.io.IOException;
@@ -48,10 +49,12 @@ public static void main(String[] args) throws Exception {
Server server = new Server(port);
Application app = new Application();
+ AccessLog accessLog = new AccessLog();
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
+ server.setRequestLog(accessLog);
ServletContainer servletContainer = new ServletContainer(app);
ServletHolder servlet = new ServletHolder(servletContainer);
@@ -65,7 +68,12 @@ public static void main(String[] args) throws Exception {
server.start();
server.join();
} finally {
- server.destroy();
+ try {
+ server.destroy();
+ } catch (Throwable error) {
+ Logger.error(error);
+ System.exit(1);
+ }
}
}
}
diff --git a/src/main/java/com/github/monai/DefaultExterns.java b/src/main/java/com/github/monai/DefaultExterns.java
index 1194075..d2c5a8e 100644
--- a/src/main/java/com/github/monai/DefaultExterns.java
+++ b/src/main/java/com/github/monai/DefaultExterns.java
@@ -11,15 +11,11 @@
public final class DefaultExterns {
public final HashMap> externs;
-
- public DefaultExterns() throws IOException {
+ DefaultExterns() throws IOException {
this.externs = new HashMap<>();
for (CompilerOptions.Environment env : CompilerOptions.Environment.values()) {
- CompilerOptions options = new CompilerOptions();
- options.setEnvironment(env);
-
- List externs = CommandLineRunner.getBuiltinExterns(options);
+ List externs = CommandLineRunner.getBuiltinExterns(env);
this.externs.put(env, externs);
}
}
diff --git a/src/main/java/com/github/monai/resource/WebRunner.java b/src/main/java/com/github/monai/resource/WebRunner.java
index cb3202d..76f4942 100644
--- a/src/main/java/com/github/monai/resource/WebRunner.java
+++ b/src/main/java/com/github/monai/resource/WebRunner.java
@@ -19,7 +19,17 @@
public class WebRunner {
@GET
@Path("/status")
- public HashMap status(@QueryParam("level") CompilationLevel level,
+ public HashMap status() {
+ HashMap out = new HashMap<>();
+
+ out.put("compilerVersion", Compiler.getReleaseVersion());
+
+ return out;
+ }
+
+ @GET
+ @Path("/options")
+ public HashMap options(@QueryParam("level") CompilationLevel level,
@QueryParam("debug") @DefaultValue("false") boolean debug,
@QueryParam("typeBased") @DefaultValue("false") boolean typeBased,
@QueryParam("wrappedOutput") @DefaultValue("false") boolean wrappedOutput) throws IOException {
@@ -32,7 +42,6 @@ public HashMap status(@QueryParam("level") CompilationLevel leve
}
out.put("options", options);
- out.put("compilerVersion", Compiler.getReleaseVersion());
return out;
}
@@ -42,7 +51,8 @@ public HashMap status(@QueryParam("level") CompilationLevel leve
public HashMap externs() throws IOException {
HashMap out = new HashMap<>();
- out.put("externs", CommandLineRunner.getBuiltinExterns(new CompilerOptions()));
+ CompilerOptions.Environment environment = new CompilerOptions().getEnvironment();
+ out.put("externs", CommandLineRunner.getBuiltinExterns(environment));
return out;
}
@@ -84,7 +94,7 @@ private void applyOptimizations(Optimizations optim, CompilerOptions options) {
}
}
- class VoidErrorManager extends BasicErrorManager {
+ private class VoidErrorManager extends BasicErrorManager {
@Override
public void println(CheckLevel level, JSError error) {}
diff --git a/src/main/resources/tinylog.properties b/src/main/resources/tinylog.properties
new file mode 100644
index 0000000..ae78fe2
--- /dev/null
+++ b/src/main/resources/tinylog.properties
@@ -0,0 +1,2 @@
+tinylog.level=info
+tinylog.format={level}: {date:yyyy-MM-dd HH:mm:ss} [{thread}] {message}