diff --git a/.travis.yml b/.travis.yml index 6b064c66..431e0f42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ branches: env: global: - secure: "I8awdba2QYgO+vKmbsIa10L7dGPpcvt/l0sfE+NH2On4ZtBFuX7X4tFncmWizHhrqa0xvoAEl8hZFZ6+RjbAOzd9kDLfdHevLVv6z8VQusvY58GbAHPP0h4yd4PA0YsSeiLv1F7X7bCH6weZo16t42lVh4NrAS2XHqSOOvMyAWo=" - - DOCS_BRANCH="0.1.0" + - DOCS_BRANCH="0.1.1" - GEN_APIDOCS="gradle javadoc" after_success: diff --git a/README.md b/README.md index 5a33a6e6..df9c9824 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ In Maven: co.paralleluniverse ARTIFACT - 0.1.0 + 0.1.1 ``` diff --git a/build.gradle b/build.gradle index ee59dcf9..a18d75cc 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ subprojects { [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' group = "co.paralleluniverse" - version = "0.2.0-SNAPSHOT" + version = "0.1.1" status = "integration" description = "Fibers services for web" ext.url = "http://puniverse.github.com/comsat" @@ -35,12 +35,18 @@ subprojects { maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } maven { url 'https://maven.java.net/content/repositories/snapshots' } } - + + configurations { + provided + srcFiles + markdownDoclet + } + configurations.all { resolutionStrategy { failOnVersionConflict() force "com.google.guava:guava:16.0.1" - force "org.ow2.asm:asm:5.0_BETA" + force "org.ow2.asm:asm:5.0.1" force "org.slf4j:slf4j-api:1.7.6" force "log4j:log4j:1.2.17" force "junit:junit:4.11" @@ -49,15 +55,17 @@ subprojects { } } - configurations { - srcFiles - markdownDoclet - } - dependencies { - compile 'co.paralleluniverse:quasar-core:0.5.0-SNAPSHOT' + provided 'co.paralleluniverse:quasar-core:0.5.0' markdownDoclet "ch.raffael.pegdown-doclet:pegdown-doclet:1.1.1" } + + sourceSets { + main.compileClasspath = main.compileClasspath + configurations.provided + main.runtimeClasspath = main.runtimeClasspath + configurations.provided + test.compileClasspath = test.compileClasspath + configurations.provided + test.runtimeClasspath = test.runtimeClasspath + configurations.provided + } defaultTasks 'install' @@ -72,7 +80,7 @@ subprojects { doLast { ant.taskdef(name:'scanSuspendables', classname:'co.paralleluniverse.fibers.instrument.SuspendablesScanner', - classpath: "build/classes/main:" + configurations.compile.asPath) + classpath: "build/classes/main:${configurations.provided.asPath}:${configurations.compile.asPath}") ant.scanSuspendables(outputFile:"$sourceSets.main.output.resourcesDir/META-INF/suspendable-supers") { fileset(dir: sourceSets.main.output.classesDir) } @@ -213,7 +221,7 @@ project (':comsat-jdbc') { println("Instrumenting classes...") ant.taskdef(name:'instrumentation', classname:'co.paralleluniverse.fibers.instrument.InstrumentationTask', - classpath: "build/resources/main:"+"build/classes/main:" + configurations.compile.asPath) + classpath: "build/classes/main:${configurations.provided.asPath}:${configurations.compile.asPath}") ant.instrumentation(verbose:'true', check:'true', debug:'true') { fileset(dir: sourceSets.main.output.classesDir) { exclude(name: 'co/paralleluniverse/fibers/instrument/*.class') @@ -226,18 +234,17 @@ project (':comsat-jdbc') { project (':comsat-jax-rs-client') { dependencies { compile 'javax.ws.rs:javax.ws.rs-api:2.0' - compile 'org.glassfish.jersey.core:jersey-client:2.5.1' - compile 'org.glassfish.jersey.connectors:jersey-jetty-connector:2.5.1' + compile 'org.glassfish.jersey.core:jersey-client:2.7' + compile 'org.glassfish.jersey.connectors:jersey-jetty-connector:2.7' srcFiles 'javax.ws.rs:javax.ws.rs-api:2.0:sources' } - } //project (':comsat-httpclient') { // dependencies { -// compile 'org.apache.httpcomponents:httpcore:4.3.2' -// compile 'org.apache.httpcomponents:httpclient:4.3.2' -// compile 'org.apache.httpcomponents:httpasyncclient:4.0' +// compile 'org.apache.httpcomponents:httpcore:4.3.3' +// compile 'org.apache.httpcomponents:httpclient:4.3.3' +// compile 'org.apache.httpcomponents:httpasyncclient:4.1' // } //} @@ -251,12 +258,10 @@ project (':comsat-jersey-server') { dependencies { compile project(':comsat-servlet') compile 'org.sonatype.sisu.inject:cglib:3.1.1' // instead of old cglib in jersey - compile ('org.glassfish.jersey.containers:jersey-container-servlet:2.5.1' ) { - exclude group: 'org.glassfish.hk2.external', module: 'asm-all-repackaged' + compile ('org.glassfish.jersey.containers:jersey-container-servlet:2.7' ) { exclude group: 'org.glassfish.hk2.external', module: 'cglib' } - compile ('org.glassfish.jersey.core:jersey-client:2.5.1') { - exclude group: 'org.glassfish.hk2.external', module: 'asm-all-repackaged' + compile ('org.glassfish.jersey.core:jersey-client:2.7') { exclude group: 'org.glassfish.hk2.external', module: 'cglib' } } @@ -264,7 +269,7 @@ project (':comsat-jersey-server') { project (':comsat-actors-api') { dependencies { - compile 'co.paralleluniverse:quasar-actors:0.5.0-SNAPSHOT' + compile 'co.paralleluniverse:quasar-actors:0.5.0' compile 'com.google.guava:guava:16.0.1' } } @@ -272,8 +277,8 @@ project (':comsat-actors-api') { project (':comsat-actors-servlet') { dependencies { compile project (':comsat-actors-api') - compile 'javax.websocket:javax.websocket-api:1.0' - compile 'javax.servlet:javax.servlet-api:3.1.0' + provided 'javax.websocket:javax.websocket-api:1.0' + provided 'javax.servlet:javax.servlet-api:3.1.0' srcFiles 'javax.servlet:javax.servlet-api:3.1.0:sources' } } @@ -287,13 +292,14 @@ project(':comsat-actors-netty') { project(':comsat-actors-undertow') { dependencies { - compile 'io.undertow:undertow-core:1.0.0.Final' + compile 'io.undertow:undertow-core:1.0.2.Final' compile project (':comsat-actors-api') } } project(':comsat-tomcat-loader') { dependencies { + compile 'co.paralleluniverse:quasar-core:0.5.0' compile 'org.apache.tomcat.embed:tomcat-embed-core:8.0.3' } jar { @@ -348,5 +354,5 @@ task clean(dependsOn: subprojects.clean) << { } task wrapper(type: Wrapper) { - gradleVersion = '1.10' + gradleVersion = '1.11' } diff --git a/comsat-actors-api/src/main/java/co/paralleluniverse/comsat/webactors/HttpResponse.java b/comsat-actors-api/src/main/java/co/paralleluniverse/comsat/webactors/HttpResponse.java index e17d8b5b..69b12ef9 100644 --- a/comsat-actors-api/src/main/java/co/paralleluniverse/comsat/webactors/HttpResponse.java +++ b/comsat-actors-api/src/main/java/co/paralleluniverse/comsat/webactors/HttpResponse.java @@ -81,8 +81,8 @@ protected String contentString() { * @param body the response body * @return A response {@link Builder} that can be used to add headers and other metadata to the response. */ - public static Builder ok(HttpRequest request, String body) { - return new Builder(request, body); + public static Builder ok(ActorRef from, HttpRequest request, String body) { + return new Builder(from, request, body); } /** @@ -92,8 +92,8 @@ public static Builder ok(HttpRequest request, String body) { * @param body the response body * @return A response {@link Builder} that can be used to add headers and other metadata to the response. */ - public static Builder ok(HttpRequest request, ByteBuffer body) { - return new Builder(request, body); + public static Builder ok(ActorRef from, HttpRequest request, ByteBuffer body) { + return new Builder(from, request, body); } /** @@ -105,8 +105,8 @@ public static Builder ok(HttpRequest request, ByteBuffer body) { * @param cause the exception that caused the error * @return A response {@link Builder} that can be used to add headers and other metadata to the response. */ - public static Builder error(HttpRequest request, int status, Throwable cause) { - return new Builder(request).status(status).error(cause); + public static Builder error(ActorRef from, HttpRequest request, int status, Throwable cause) { + return new Builder(from, request).status(status).error(cause); } /** @@ -117,8 +117,8 @@ public static Builder error(HttpRequest request, int status, Throwable cause) { * @param body the response body * @return A response {@link Builder} that can be used to add headers and other metadata to the response. */ - public static Builder error(HttpRequest request, int status, String body) { - return new Builder(request, body).status(status); + public static Builder error(ActorRef from, HttpRequest request, int status, String body) { + return new Builder(from, request, body).status(status); } /** diff --git a/comsat-actors-api/src/main/java/co/paralleluniverse/comsat/webactors/SSE.java b/comsat-actors-api/src/main/java/co/paralleluniverse/comsat/webactors/SSE.java index f3687b9d..02200a79 100644 --- a/comsat-actors-api/src/main/java/co/paralleluniverse/comsat/webactors/SSE.java +++ b/comsat-actors-api/src/main/java/co/paralleluniverse/comsat/webactors/SSE.java @@ -13,6 +13,7 @@ */ package co.paralleluniverse.comsat.webactors; +import co.paralleluniverse.actors.ActorRef; import java.nio.charset.Charset; /** @@ -51,8 +52,8 @@ public final class SSE { * @param request the {@link HttpRequest} in response to which we wish to start an SSE stream. * @return an {@link HttpResponse.Builder HttpResponse.Builder} (which can have other metadata, such as headers or cookies added to). */ - public static HttpResponse.Builder startSSE(HttpRequest request) { - return new HttpResponse.Builder(request) + public static HttpResponse.Builder startSSE(ActorRef from, HttpRequest request) { + return new HttpResponse.Builder(from, request) .setContentType("text/event-stream") .setCharacterEncoding(Charset.forName("UTF-8")) .startActor(); @@ -69,8 +70,8 @@ public static HttpResponse.Builder startSSE(HttpRequest request) { * after the connection has closed (will be encoded in the message body as {@code retry: ...}) * @return an {@link HttpResponse.Builder HttpResponse.Builder} (which can have other metadata, such as headers or cookies added to). */ - public static HttpResponse.Builder startSSE(HttpRequest request, long reconnectTimeout) { - return new HttpResponse.Builder(request, retryString(reconnectTimeout) + '\n') + public static HttpResponse.Builder startSSE(ActorRef from, HttpRequest request, long reconnectTimeout) { + return new HttpResponse.Builder(from, request, retryString(reconnectTimeout) + '\n') .setContentType("text/event-stream") .setCharacterEncoding(Charset.forName("UTF-8")) .startActor(); diff --git a/comsat-actors-servlet/src/main/java/co/paralleluniverse/comsat/webactors/servlet/WebActorServlet.java b/comsat-actors-servlet/src/main/java/co/paralleluniverse/comsat/webactors/servlet/WebActorServlet.java index 9b355f47..3d5b55bc 100644 --- a/comsat-actors-servlet/src/main/java/co/paralleluniverse/comsat/webactors/servlet/WebActorServlet.java +++ b/comsat-actors-servlet/src/main/java/co/paralleluniverse/comsat/webactors/servlet/WebActorServlet.java @@ -129,7 +129,8 @@ public void sessionCreated(HttpSessionEvent se) { @Override public void sessionDestroyed(HttpSessionEvent se) { HttpActorRef ha = getHttpActorRef(se.getSession()); - ha.die(null); + if (ha != null) + ha.die(null); } @Override diff --git a/comsat-jersey-server/src/main/java/co/paralleluniverse/fibers/jersey/ServletContainer.java b/comsat-jersey-server/src/main/java/co/paralleluniverse/fibers/jersey/ServletContainer.java index c90dbc68..a08ab512 100644 --- a/comsat-jersey-server/src/main/java/co/paralleluniverse/fibers/jersey/ServletContainer.java +++ b/comsat-jersey-server/src/main/java/co/paralleluniverse/fibers/jersey/ServletContainer.java @@ -39,6 +39,7 @@ * @author eitan */ public class ServletContainer extends FiberHttpServlet implements Filter, Container { + private static final int DEFAULT_STACK_SIZE = 120; private final org.glassfish.jersey.servlet.ServletContainer jerseySC; /** @@ -69,6 +70,8 @@ public ServletContainer(org.glassfish.jersey.servlet.ServletContainer sc) { @Override public void init(ServletConfig config) throws ServletException { super.init(config); + if (getStackSize() <= 0) + setStackSize(DEFAULT_STACK_SIZE); } /** diff --git a/comsat-jersey-server/src/main/resources/META-INF/suspendables b/comsat-jersey-server/src/main/resources/META-INF/suspendables index c189c6ac..ebfce992 100644 --- a/comsat-jersey-server/src/main/resources/META-INF/suspendables +++ b/comsat-jersey-server/src/main/resources/META-INF/suspendables @@ -1,7 +1,3 @@ -sun.reflect.NativeMethodAccessorImpl.invoke0 -sun.reflect.NativeMethodAccessorImpl.invoke -sun.reflect.DelegatingMethodAccessorImpl.invoke -java.lang.reflect.Method.invoke org.glassfish.jersey.process.Inflector.apply org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke diff --git a/comsat-servlet/src/main/java/co/paralleluniverse/fibers/servlet/FiberGenericServlet.java b/comsat-servlet/src/main/java/co/paralleluniverse/fibers/servlet/FiberGenericServlet.java index 680e44f0..51061458 100644 --- a/comsat-servlet/src/main/java/co/paralleluniverse/fibers/servlet/FiberGenericServlet.java +++ b/comsat-servlet/src/main/java/co/paralleluniverse/fibers/servlet/FiberGenericServlet.java @@ -13,6 +13,7 @@ */ package co.paralleluniverse.fibers.servlet; +import co.paralleluniverse.common.util.Debug; import co.paralleluniverse.fibers.Fiber; import co.paralleluniverse.fibers.SuspendExecution; import co.paralleluniverse.strands.SuspendableRunnable; @@ -33,6 +34,7 @@ public abstract class FiberGenericServlet extends GenericServlet { private transient FiberServletConfig configAD; private transient FiberServletContext contextAD; private final ThreadLocal currentAsyncContext = new ThreadLocal(); + private int stackSize = -1; /** * @@ -57,9 +59,22 @@ public ServletContext getServletContext() { public void init(ServletConfig config) throws ServletException { this.contextAD = new FiberServletContext(config.getServletContext(), currentAsyncContext); this.configAD = new FiberServletConfig(config, contextAD); + + String sss = config.getInitParameter("stack-size"); + if(sss != null) + stackSize = Integer.parseInt(sss); + this.init(); } + protected void setStackSize(int stackSize) { + this.stackSize = stackSize; + } + + protected int getStackSize() { + return stackSize; + } + /** * @inheritDoc * @@ -72,7 +87,7 @@ public final void service(final ServletRequest req, final ServletResponse res) { req.setAttribute("org.apache.catalina.ASYNC_SUPPORTED", true); final AsyncContext ac = req.startAsync(); final FiberServletRequest srad = wrapRequest(req); - new Fiber(new SuspendableRunnable() { + new Fiber(null, stackSize, new SuspendableRunnable() { @Override public void run() throws SuspendExecution, InterruptedException { try { diff --git a/comsat-tomcat-loader-jdk8/build.gradle b/comsat-tomcat-loader-jdk8/build.gradle new file mode 100644 index 00000000..1ff2c161 --- /dev/null +++ b/comsat-tomcat-loader-jdk8/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'java' + +sourceCompatibility = '1.8' +targetCompatibility = '1.8' + +dependencies { + dependencies { + compile 'co.paralleluniverse:quasar-core:0.5.0:jdk8' + compile 'org.apache.tomcat.embed:tomcat-embed-core:8.0.3' + } +} + +sourceSets { + main { + java { + srcDirs = ["../comsat-tomcat-loader/src/main/java"] + } + } +} + +jar { + baseName = 'comsat-tomcat-loader' + classifier = 'jdk8' + + from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } +} + diff --git a/comsat-tomcat-loader/src/main/java/co/paralleluniverse/comsat/tomcat/QuasarWebAppClassLoader.java b/comsat-tomcat-loader/src/main/java/co/paralleluniverse/comsat/tomcat/QuasarWebAppClassLoader.java index 560d3c6f..b67ffc3c 100644 --- a/comsat-tomcat-loader/src/main/java/co/paralleluniverse/comsat/tomcat/QuasarWebAppClassLoader.java +++ b/comsat-tomcat-loader/src/main/java/co/paralleluniverse/comsat/tomcat/QuasarWebAppClassLoader.java @@ -51,8 +51,8 @@ public void error(String msg, Exception exc) { exc.printStackTrace(System.out); } }); -// inst.setVerbose(true); -// inst.setDebug(true); + inst.setVerbose(false); + inst.setDebug(false); return inst; } @@ -65,7 +65,7 @@ private synchronized void initInstrumentor() { protected ResourceEntry findResourceInternal(String name, String path) { initInstrumentor(); ResourceEntry entry = super.findResourceInternal(name, path); - if (entry != null && path.endsWith(".class")) { + if (entry != null && path.endsWith(".class") && entry.binaryContent != null) { String className = name.substring(0, name.length() - ".class".length()); try { entry.binaryContent = instrumentor.instrumentClass(className, entry.binaryContent); diff --git a/docs/_config.yml b/docs/_config.yml index addfd1b9..cfc9a46f 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -14,7 +14,7 @@ kramdown: # Site globals used throughout docs. project: Comsat -version: 0.1.0 +version: 0.1.1 github: puniverse/comsat google_group: "https://groups.google.com/forum/#!forum/comsat-user" tagline: "Scalable web application libraries" diff --git a/docs/index.md b/docs/index.md index 0287dc43..8310421b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -63,7 +63,7 @@ To use the Java agent, the following must be added to the java command line (or #### In Tomcat -If you're using Tomcat as your Servlet container, you have the option to use a custom class-loader instead of the Java agent. You'll need to put `comsat-tomcat-loader-{{site.version}}.jar` into Tomcat's `lib` directory. +If you're using Tomcat as your Servlet container, you have the option to use a custom class-loader instead of the Java agent. You'll need to put `comsat-tomcat-loader-{{site.version}}.jar` (or, for JDK8, `comsat-tomcat-loader-{{site.version}}-jdk8.jar`) into Tomcat's `lib` directory. Then, include the following in your webapp's `context.xml` (in the `META-INF` directory): diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d5c591c9..3c7abdf1 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 69bceb77..94753a70 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jan 10 10:53:42 EET 2014 +#Sun Mar 23 22:21:50 IST 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-bin.zip +distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip diff --git a/settings.gradle b/settings.gradle index bf0f0306..fd8fbefe 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,7 @@ rootProject.name = 'comsat' -include 'comsat-jdbc','comsat-jersey-server','comsat-servlet','comsat-jax-rs-client','comsat-actors-api','comsat-actors-servlet','comsat-actors-netty','comsat-actors-undertow','comsat-tomcat-loader','comsat-jetty-loader'//,'comsat-httpclient' \ No newline at end of file +include 'comsat-jdbc','comsat-jersey-server','comsat-servlet','comsat-jax-rs-client','comsat-actors-api',\ +'comsat-actors-servlet','comsat-actors-netty','comsat-actors-undertow',\ +'comsat-tomcat-loader','comsat-jetty-loader'//,'comsat-httpclient' +if (System.properties['java.version'].startsWith('1.8') ) { + include 'comsat-tomcat-loader-jdk8' +} \ No newline at end of file