scalacount should work now.
This commit is contained in:
parent
352d4b6c2a
commit
b8fe12c215
21 changed files with 155 additions and 91 deletions
|
|
@ -39,34 +39,25 @@ CLASSPATH=$CLASSPATH:$LIB_DIR/commons-logging-1.0.4.jar
|
|||
CLASSPATH=$CLASSPATH:$LIB_DIR/commons-math-1.1.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/configgy-1.3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/google-collect-snapshot-20090211.jar
|
||||
#CLASSPATH=$CLASSPATH:$LIB_DIR/grizzly-framework-1.8.6.3.jar
|
||||
#CLASSPATH=$CLASSPATH:$LIB_DIR/grizzly-http-1.8.6.3.jar
|
||||
#CLASSPATH=$CLASSPATH:$LIB_DIR/grizzly-http-servlet-1.8.6.3.jar
|
||||
#CLASSPATH=$CLASSPATH:$LIB_DIR/grizzly-http-utils-1.9.1.jar
|
||||
#CLASSPATH=$CLASSPATH:$LIB_DIR/grizzly-servlet-webserver-1.8.6.3.jar
|
||||
#CLASSPATH=$CLASSPATH:$LIB_DIR/grizzly-comet-1.8.6.3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/grizzly-comet-webserver-1.8.6.3.jar
|
||||
#CLASSPATH=$CLASSPATH:$LIB_DIR/grizzly-comet-webserver-1.9.17-RC2.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/guice-core-2.0-SNAPSHOT.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/guice-jsr250-2.0-SNAPSHOT.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/high-scale-lib.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jackson-core-asl-1.1.0.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jackson-mapper-asl-1.1.0.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-client-1.1.0-ea.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-core-1.0.3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-json-1.0.3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-server-1.0.3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-client-1.1.1-ea.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-core-1.1.1-ea.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-json-1.1.1-ea.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-server-1.1.1-ea.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-scala-1.1.2-ea-SNAPSHOT.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-core-0.3-SNAPSHOT.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-portable-runtime-0.3-SNAPSHOT.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-compat-0.3-SNAPSHOT.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-core-0.3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-portable-runtime-0.3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-compat-0.3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/JSAP-2.1.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jsr250-api-1.0.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/jsr311-api-1.0.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/libfb303.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/libthrift.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/lift-webkit-1.1-M3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/lift-util-1.1-M3.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/log4j-1.2.15.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/lucene-core-2.2.0.jar
|
||||
CLASSPATH=$CLASSPATH:$LIB_DIR/netty-3.1.0.CR1.jar
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
9
deploy/root/META-INF/atmosphere.xml
Executable file
9
deploy/root/META-INF/atmosphere.xml
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
<atmosphere-handlers>
|
||||
<!-- Associate a context-root (servlet-mapping) to an AtmosphereHandler.
|
||||
Request sent using that context-root will be mapped to its associated AtmosphereHandler
|
||||
-->
|
||||
<atmosphere-handler context-root="" class-name="se.scalablesolutions.akka.kernel.jersey.AkkaServlet" broadcaster="org.atmosphere.core.JerseyBroadcaster">
|
||||
<!-- Define some AtmosphereHandler properties -->
|
||||
<property name="com.sun.jersey.spi.container.ResourceFilters" value="org.atmosphere.core.AtmosphereFilter"/>
|
||||
</atmosphere-handler>
|
||||
</atmosphere-handlers>
|
||||
5
deploy/root/META-INF/context.xml
Executable file
5
deploy/root/META-INF/context.xml
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Context>
|
||||
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
|
||||
<Loader delegate="true"/>
|
||||
</Context>
|
||||
19
deploy/root/jquery-1.3.2.min.js
vendored
Normal file
19
deploy/root/jquery-1.3.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,10 +1,64 @@
|
|||
<html>
|
||||
<head><title>blah</title></head>
|
||||
<body>
|
||||
<form method="post" enctype="application/x-www-form-urlencoded" action="chat">
|
||||
<input name="action"/>
|
||||
<input name="name"/>
|
||||
<input name="message"/>
|
||||
<input type="submit" value="submit" name="submit"/>
|
||||
</form>
|
||||
</body>
|
||||
<head>
|
||||
<title>Push Services Demo</title>
|
||||
<script language="javascript" src="jquery-1.3.2.min.js">
|
||||
</script>
|
||||
<style>
|
||||
.hide {
|
||||
visibility : hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body id="body">
|
||||
<div id="container">
|
||||
<div id="chat">
|
||||
<div id="chatwindow">
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" name="name" id="name"/>
|
||||
<input type="button" name="login" value="Login" id="login" />
|
||||
<textarea id="msg" class="hide" name="message" rows="10" cols="150"></textarea>
|
||||
<input type="button" name="Send" id="send" value="Send" class="hide"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script language="javascript">
|
||||
$(function(){
|
||||
window.app = {
|
||||
update : function(data) {
|
||||
if(data && data.name)
|
||||
$('#chatwindow').append('<p>' + data.name + (data.message ? (': ' + data.message) : '') + '</p>');
|
||||
else
|
||||
alert(data);
|
||||
}
|
||||
}
|
||||
|
||||
$('#send').click( function(e){
|
||||
var message = $('#msg').val();
|
||||
$('#msg').val('');
|
||||
|
||||
$.post('/chat',
|
||||
{
|
||||
'action' : 'post',
|
||||
'name' : $('#name').val(),
|
||||
'message' : message
|
||||
});
|
||||
});
|
||||
|
||||
$('#login').click( function(e) {
|
||||
$.post('/chat',
|
||||
{
|
||||
'action' : 'login',
|
||||
'name' : $('#name').val()
|
||||
},
|
||||
function(data) { $('#login').hide();
|
||||
$('#name').attr('disabled','disabled');
|
||||
$('#msg').removeClass('hide');
|
||||
$('#send').removeClass('hide');
|
||||
$('<iframe style="display:hidden;" id="comet" src="/chat"></iframe>').appendTo('#body');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -119,12 +119,12 @@
|
|||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.1.1-ea</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-json</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.1.1-ea</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
|
|
@ -145,17 +145,17 @@
|
|||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-core</artifactId>
|
||||
<version>0.3-SNAPSHOT</version>
|
||||
<version>0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-portable-runtime</artifactId>
|
||||
<version>0.3-SNAPSHOT</version>
|
||||
<version>0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-compat</artifactId>
|
||||
<version>0.3-SNAPSHOT</version>
|
||||
<version>0.3</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class AkkaServlet extends ServletContainer with AtmosphereServletProcessor with
|
|||
val configurators = ConfiguratorRepository.getConfiguratorsFor(getServletContext)
|
||||
|
||||
rc.getClasses.addAll(configurators.flatMap(_.getComponentInterfaces))
|
||||
log.info("ResourceFilters: " + rc.getProperty("com.sun.jersey.spi.container.ResourceFilters"));
|
||||
rc.getProperties.put("com.sun.jersey.spi.container.ResourceFilters","org.atmosphere.core.AtmosphereFilter")
|
||||
//rc.getFeatures.put("com.sun.jersey.config.feature.Redirect", true)
|
||||
//rc.getFeatures.put("com.sun.jersey.config.feature.ImplicitViewables",true)
|
||||
|
|
@ -48,30 +49,23 @@ class AkkaServlet extends ServletContainer with AtmosphereServletProcessor with
|
|||
//Borrowed from AbstractReflectorAtmosphereHandler
|
||||
override def onMessage(event : AtmosphereEvent[HttpServletRequest,HttpServletResponse]) : AtmosphereEvent[_,_] =
|
||||
{
|
||||
//log.info("onMessage: " + event.getMessage.toString)
|
||||
|
||||
if(event.getMessage ne null)
|
||||
{
|
||||
var isUsingStream = false
|
||||
try {
|
||||
event.getResponse.getWriter
|
||||
} catch {
|
||||
case e: IllegalStateException => isUsingStream = true
|
||||
}
|
||||
|
||||
val data = event.getMessage.toString
|
||||
|
||||
if (isUsingStream){
|
||||
if(data != null)
|
||||
event.getResponse.getOutputStream.write(data.getBytes)
|
||||
event.getResponse.getOutputStream.flush
|
||||
} else {
|
||||
event.getResponse.getWriter.write(data)
|
||||
event.getResponse.getWriter.flush
|
||||
}
|
||||
var isUsingStream = false
|
||||
try {
|
||||
event.getResponse.getWriter
|
||||
} catch {
|
||||
case e: IllegalStateException => isUsingStream = true
|
||||
}
|
||||
|
||||
val data = if(event.getMessage ne null) event.getMessage.toString else null
|
||||
|
||||
if (isUsingStream){
|
||||
if(data != null)
|
||||
event.getResponse.getOutputStream.write(data.getBytes)
|
||||
event.getResponse.getOutputStream.flush
|
||||
} else {
|
||||
event.getResponse.getWriter.write(data)
|
||||
event.getResponse.getWriter.flush
|
||||
}
|
||||
else
|
||||
log.info("Null event message :/ req[ " + event.getRequest + "] res[" +event.getResponse + "]")
|
||||
|
||||
event
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/atmosphere-compat-0.3.jar
Executable file
BIN
lib/atmosphere-compat-0.3.jar
Executable file
Binary file not shown.
BIN
lib/atmosphere-core-0.3-SNAPSHOT.jar → lib/atmosphere-core-0.3.jar
Normal file → Executable file
BIN
lib/atmosphere-core-0.3-SNAPSHOT.jar → lib/atmosphere-core-0.3.jar
Normal file → Executable file
Binary file not shown.
BIN
lib/atmosphere-portable-runtime-0.3-SNAPSHOT.jar → lib/atmosphere-portable-runtime-0.3.jar
Normal file → Executable file
BIN
lib/atmosphere-portable-runtime-0.3-SNAPSHOT.jar → lib/atmosphere-portable-runtime-0.3.jar
Normal file → Executable file
Binary file not shown.
BIN
lib/jersey-client-1.1.0-ea.jar → lib/jersey-client-1.1.1-ea.jar
Normal file → Executable file
BIN
lib/jersey-client-1.1.0-ea.jar → lib/jersey-client-1.1.1-ea.jar
Normal file → Executable file
Binary file not shown.
BIN
lib/jersey-core-1.0.3.jar → lib/jersey-core-1.1.1-ea.jar
Normal file → Executable file
BIN
lib/jersey-core-1.0.3.jar → lib/jersey-core-1.1.1-ea.jar
Normal file → Executable file
Binary file not shown.
Binary file not shown.
BIN
lib/jersey-json-1.1.1-ea.jar
Executable file
BIN
lib/jersey-json-1.1.1-ea.jar
Executable file
Binary file not shown.
BIN
lib/jersey-server-1.0.3.jar → lib/jersey-server-1.1.1-ea.jar
Normal file → Executable file
BIN
lib/jersey-server-1.0.3.jar → lib/jersey-server-1.1.1-ea.jar
Normal file → Executable file
Binary file not shown.
|
|
@ -20,6 +20,9 @@ class Boot {
|
|||
override def getSupervisorConfig: SupervisorConfig = {
|
||||
SupervisorConfig(
|
||||
RestartStrategy(OneForOne, 3, 100),
|
||||
Supervise(
|
||||
new SimpleService,
|
||||
LifeCycle(Permanent, 100)) ::
|
||||
Supervise(
|
||||
new Chat,
|
||||
LifeCycle(Permanent, 100))
|
||||
|
|
@ -84,51 +87,40 @@ class Chat extends Actor with Logging{
|
|||
@Suspend
|
||||
@GET
|
||||
@Produces(Array("text/html"))
|
||||
def suspend() = "<!-- Comet is a programming technique that enables web " +
|
||||
"servers to send data to the client without having any need " +
|
||||
"for the client to request it. -->\n"
|
||||
@FilterBroadcast(Array(classOf[XSSHtmlFilter],classOf[JsonpFilter]))
|
||||
def suspend() = <!-- Comet is a programming technique that enables web servers to send data to the client without having any need for the client to request it. -->
|
||||
|
||||
override def receive: PartialFunction[Any, Unit] = {
|
||||
case Chat(who,what,msg) => {
|
||||
|
||||
//log.info("Chat(" + who + ", " + what + ", " + msg + ")")
|
||||
|
||||
what match {
|
||||
case "login" => reply("System Message__"+who+" has joined.")
|
||||
case "post" => reply("" + who + "__" + msg)
|
||||
case _ => throw new WebApplicationException(422)
|
||||
}
|
||||
}
|
||||
what match {
|
||||
case "login" => reply("System Message__"+who+" has joined.")
|
||||
case "post" => reply("" + who + "__" + msg)
|
||||
case _ => throw new WebApplicationException(422)
|
||||
}
|
||||
}
|
||||
case x => log.info("recieve unknown: " + x)
|
||||
}
|
||||
|
||||
@Broadcast
|
||||
@Consumes(Array("application/x-www-form-urlencoded"))
|
||||
@POST
|
||||
@Produces(Array("text/html"))
|
||||
@FilterBroadcast(Array(classOf[XSSHtmlFilter],classOf[JsonpFilter]))
|
||||
def publishMessage(form: MultivaluedMap[String, String]) = (this !! Chat(form.getFirst("name"),form.getFirst("action"),form.getFirst("message"))).getOrElse("System__error")
|
||||
}
|
||||
|
||||
@Broadcast
|
||||
@Consumes(Array("application/x-www-form-urlencoded"))
|
||||
@POST
|
||||
@Produces(Array("text/html"))
|
||||
@FilterBroadcast(Array(classOf[XSSHtmlFilter],classOf[JsonpFilter]))
|
||||
def publishMessage(form: MultivaluedMap[String, String]) = (this !! Chat(form.getFirst("name"),form.getFirst("action"),form.getFirst("message"))).getOrElse("System__error")
|
||||
}
|
||||
|
||||
class JsonpFilter extends BroadcastFilter[String] with Logging
|
||||
{
|
||||
|
||||
val BEGIN_SCRIPT_TAG = "<script type='text/javascript'>\n"
|
||||
val END_SCRIPT_TAG = "</script>\n"
|
||||
class JsonpFilter extends BroadcastFilter[String] with Logging
|
||||
{
|
||||
def filter(m : String) = {
|
||||
var name = m
|
||||
var message = ""
|
||||
|
||||
def filter(m : String) = {
|
||||
var name = m
|
||||
var message = ""
|
||||
if (m.indexOf("__") > 0) {
|
||||
name = m.substring(0, m.indexOf("__"))
|
||||
message = m.substring(m.indexOf("__") + 2)
|
||||
}
|
||||
|
||||
if (m.indexOf("__") > 0) {
|
||||
name = m.substring(0, m.indexOf("__"))
|
||||
message = m.substring(m.indexOf("__") + 2)
|
||||
}
|
||||
|
||||
(BEGIN_SCRIPT_TAG + "window.parent.app.update({ name: \""
|
||||
+ name + "\", message: \""
|
||||
+ message + "\" });\n"
|
||||
+ END_SCRIPT_TAG)
|
||||
}
|
||||
}
|
||||
("<script type='text/javascript'>\n (window.app || window.parent.app).update({ name: \"" + name + "\", message: \""+ message + "\" }); \n</script>\n")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue