diff options
Diffstat (limited to '')
-rw-r--r-- | sca-java-2.x/contrib/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/javascript/JavascriptResource.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sca-java-2.x/contrib/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/javascript/JavascriptResource.java b/sca-java-2.x/contrib/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/javascript/JavascriptResource.java index d6ad8a018f..6df45e4ca8 100644 --- a/sca-java-2.x/contrib/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/javascript/JavascriptResource.java +++ b/sca-java-2.x/contrib/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/javascript/JavascriptResource.java @@ -1,20 +1,28 @@ package org.apache.tuscany.sca.binding.comet.runtime.javascript; +import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.SequenceInputStream; +import javax.servlet.ServletContext; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; import javax.ws.rs.core.PathSegment; +import org.apache.tuscany.sca.binding.comet.runtime.ServletFactory; + @Path("/") @Produces("text/javascript") public class JavascriptResource { private static final String[] DEPENDENCIES = {"/jquery-1.4.2.min.js", "/jquery.atmosphere.js", - "/org.apache.tuscany.sca.cometComponentContext.js"}; + "/jquery.json-2.2.min.js", "/cometComponentContext.js"}; + + @Context + private ServletContext sc; @GET public InputStream getJavascript(@PathParam("file") PathSegment fileName) { @@ -26,6 +34,7 @@ public class JavascriptResource { stream = new SequenceInputStream(stream, getClass().getResourceAsStream(dependency)); } } - return stream; + String generatedJs = ((StringBuffer)sc.getAttribute(ServletFactory.JS_KEY)).toString(); + return new SequenceInputStream(stream, new ByteArrayInputStream(generatedJs.getBytes())); } } |