added scala and java sample modules + jackson jars
This commit is contained in:
parent
95d598fb66
commit
27355ec510
16 changed files with 523 additions and 0 deletions
67
config/akka-reference.conf
Normal file
67
config/akka-reference.conf
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
#################################
|
||||||
|
# Akka Actor Kernel Config File #
|
||||||
|
#################################
|
||||||
|
|
||||||
|
# This file has all the default settings, so all these could be remove with no visible effect.
|
||||||
|
# Modify as needed.
|
||||||
|
|
||||||
|
<log>
|
||||||
|
filename = "./logs/akka.log"
|
||||||
|
roll = "daily" # Options: never, hourly, daily, sunday/monday/...
|
||||||
|
level = "debug" # Options: fatal, critical, error, warning, info, debug, trace
|
||||||
|
console = on
|
||||||
|
# syslog_host = ""
|
||||||
|
# syslog_server_name = ""
|
||||||
|
</log>
|
||||||
|
|
||||||
|
<akka>
|
||||||
|
version = "v0.5"
|
||||||
|
|
||||||
|
boot = ["sample.java.Boot", "sample.scala.Boot"] # FQN to the class doing initial active object/actor
|
||||||
|
# supervisor bootstrap, should be defined in default constructor
|
||||||
|
<actor>
|
||||||
|
timeout = 5000 # default timeout for future based invocations
|
||||||
|
concurrent-mode = off # if turned on, then the same actor instance is allowed to execute concurrently -
|
||||||
|
# e.g. departing from the actor model for better performance
|
||||||
|
serialize-messages = on # does a deep clone of (non-primitive) messages to ensure immutability
|
||||||
|
</actor>
|
||||||
|
|
||||||
|
<stm>
|
||||||
|
service = on
|
||||||
|
restart-on-collision = off # (not implemented yet) if 'on' then it reschedules the transaction,
|
||||||
|
# if 'off' then throws an exception or rollback for user to handle
|
||||||
|
wait-for-completion = 100 # how long time in millis a transaction should be given time to complete when a collision is detected
|
||||||
|
wait-nr-of-times = 3 # the number of times it should check for completion of a pending transaction upon collision
|
||||||
|
distributed = off # not implemented yet
|
||||||
|
</stm>
|
||||||
|
|
||||||
|
<remote>
|
||||||
|
service = on
|
||||||
|
protocol = "serialization" # Options: serialization (coming: json, avro, thrift, protobuf)
|
||||||
|
hostname = "localhost"
|
||||||
|
port = 9999
|
||||||
|
connection-timeout = 1000 # in millis
|
||||||
|
</remote>
|
||||||
|
|
||||||
|
<rest>
|
||||||
|
service = on
|
||||||
|
hostname = "localhost"
|
||||||
|
port = 9998
|
||||||
|
</rest>
|
||||||
|
|
||||||
|
<storage>
|
||||||
|
system = "cassandra" # Options: cassandra (coming: terracotta, redis, tokyo-cabinet, tokyo-tyrant, voldemort, memcached, hazelcast)
|
||||||
|
|
||||||
|
<cassandra>
|
||||||
|
service = on
|
||||||
|
storage-format = "serialization" # Options: serialization (coming: json, avro, thrift, protobuf)
|
||||||
|
blocking = false # inserts and queries should be blocking or not
|
||||||
|
|
||||||
|
<thrift-server>
|
||||||
|
service = on
|
||||||
|
pidfile = "akka.pid"
|
||||||
|
</thrift-server>
|
||||||
|
</cassandra>
|
||||||
|
</rest>
|
||||||
|
</akka>
|
||||||
|
|
||||||
5
config/akka.conf
Normal file
5
config/akka.conf
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
include "akka-reference.conf"
|
||||||
|
|
||||||
|
# This config import the Akka reference configuration.
|
||||||
|
# In this file you can override any option defined in the 'akka-reference.conf' file.
|
||||||
|
|
||||||
10
config/web.xml
Normal file
10
config/web.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>Akka Servlet</servlet-name>
|
||||||
|
<servlet-class>se.scalablesolutions.akka.kernel.jersey.AkkaServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>Akka Servlet</servlet-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</servlet-mapping-->
|
||||||
|
</web-app>
|
||||||
BIN
lib/akka-kernel-0.5.jar
Normal file
BIN
lib/akka-kernel-0.5.jar
Normal file
Binary file not shown.
BIN
lib/akka-util-java-0.5.jar
Normal file
BIN
lib/akka-util-java-0.5.jar
Normal file
Binary file not shown.
BIN
lib/jackson-core-asl-1.1.0.jar
Normal file
BIN
lib/jackson-core-asl-1.1.0.jar
Normal file
Binary file not shown.
BIN
lib/jackson-mapper-asl-1.1.0.jar
Normal file
BIN
lib/jackson-mapper-asl-1.1.0.jar
Normal file
Binary file not shown.
BIN
lib/jersey-core-1.0.3.jar
Normal file
BIN
lib/jersey-core-1.0.3.jar
Normal file
Binary file not shown.
BIN
lib/jersey-json-1.0.3.jar
Normal file
BIN
lib/jersey-json-1.0.3.jar
Normal file
Binary file not shown.
BIN
lib/jersey-server-1.0.3.jar
Normal file
BIN
lib/jersey-server-1.0.3.jar
Normal file
Binary file not shown.
71
samples-java/akka-samples-java.iml
Normal file
71
samples-java/akka-samples-java.iml
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module relativePaths="true" MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module" module-name="akka-kernel" exported="" />
|
||||||
|
<orderEntry type="module" module-name="akka-util-java" exported="" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-core:2.0-beta-4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-jsr250:2.0-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.annotation:jsr250-api:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.google.code:protobuf-java:2.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.scala-lang:scala-library:2.7.5" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.aspectwerkz:aspectwerkz-nodeps-jdk5:2.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: net.lag:configgy:1.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.scala-lang:scala-compiler:2.7.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.scala-tools:vscaladoc:1.1-md-3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: markdownj:markdownj:1.0.2b4-0.3.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: junit:junit:4.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.scala-tools.testing:specs:1.4.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guiceyfruit-core:2.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-all:2.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.annotation:com.springsource.javax.annotation:1.0.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.aopalliance:com.springsource.org.aopalliance:1.0.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.google.code.google-collections:google-collect:snapshot-20080530" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: cglib:cglib:2.2" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: asm:asm:3.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: aopalliance:aopalliance:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache.camel:camel-core:2.0-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: commons-logging:commons-logging-api:1.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.xml.bind:jaxb-api:2.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.xml.stream:stax-api:1.0-2" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.activation:activation:1.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.xml.bind:jaxb-impl:2.1.6" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.jboss.netty:netty:3.1.0.CR1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache:zookeeper:3.1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-core-asl:1.1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache.cassandra:cassandra:0.4.0-dev" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.facebook:thrift:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.facebook:fb303:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache.commons:commons-collections:3.2.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: high-scale-lib:high-scale-lib:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache.commons:commons-lang:2.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-servlet-webserver:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-http:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-framework:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-utils:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-rcm:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-portunif:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-http-servlet:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-server:1.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-core:1.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.ws.rs:jsr311-api:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-json:1.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.jettison:jettison:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: stax:stax-api:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-asl:0.9.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.slf4j:slf4j-log4j12:1.4.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.slf4j:slf4j-api:1.4.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: log4j:log4j:1.2.13" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-client:1.1.0-ea" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
|
|
||||||
67
samples-java/pom.xml
Normal file
67
samples-java/pom.xml
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>akka-samples-java</artifactId>
|
||||||
|
<name>Akka Java Samples Module</name>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>akka</artifactId>
|
||||||
|
<groupId>${akka.groupId}</groupId>
|
||||||
|
<version>${akka.version}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${akka.groupId}</groupId>
|
||||||
|
<artifactId>akka-kernel</artifactId>
|
||||||
|
<version>${akka.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${akka.groupId}</groupId>
|
||||||
|
<artifactId>akka-util-java</artifactId>
|
||||||
|
<version>${akka.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>jsr311-api</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.5</source>
|
||||||
|
<target>1.5</target>
|
||||||
|
<includes>
|
||||||
|
<include>**/*</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>install</phase>
|
||||||
|
<configuration>
|
||||||
|
<tasks>
|
||||||
|
<copy file="target/akka-samples-java-${akka.version}.jar"
|
||||||
|
tofile="../deploy/akka-samples-java-${akka.version}.jar"/>
|
||||||
|
</tasks>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
53
samples-java/src/main/java/sample/java/SimpleService.java
Normal file
53
samples-java/src/main/java/sample/java/SimpleService.java
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
package sample.java;
|
||||||
|
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
import se.scalablesolutions.akka.annotation.transactionrequired;
|
||||||
|
import se.scalablesolutions.akka.annotation.prerestart;
|
||||||
|
import se.scalablesolutions.akka.annotation.postrestart;
|
||||||
|
import se.scalablesolutions.akka.kernel.state.TransactionalState;
|
||||||
|
import se.scalablesolutions.akka.kernel.state.TransactionalMap;
|
||||||
|
import se.scalablesolutions.akka.kernel.state.CassandraStorageConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try service out by invoking (multiple times):
|
||||||
|
* <pre>
|
||||||
|
* curl http://localhost:9998/javacount
|
||||||
|
* </pre>
|
||||||
|
* Or browse to the URL from a web browser.
|
||||||
|
*/
|
||||||
|
@Path("/javacount")
|
||||||
|
@transactionrequired
|
||||||
|
public class SimpleService {
|
||||||
|
private String KEY = "COUNTER";
|
||||||
|
|
||||||
|
private boolean hasStartedTicking = false;
|
||||||
|
private TransactionalState factory = new TransactionalState();
|
||||||
|
private TransactionalMap<String, Object> storage = factory.newPersistentMap(new CassandraStorageConfig());
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces({"application/json"})
|
||||||
|
public String count() {
|
||||||
|
if (!hasStartedTicking) {
|
||||||
|
storage.put(KEY, 0);
|
||||||
|
hasStartedTicking = true;
|
||||||
|
return "Tick: 0\n";
|
||||||
|
} else {
|
||||||
|
int counter = (Integer)storage.get(KEY).get() + 1;
|
||||||
|
storage.put(KEY, counter);
|
||||||
|
return "Tick: " + counter + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@prerestart
|
||||||
|
public void preRestart() {
|
||||||
|
System.out.println("Prepare for restart by supervisor");
|
||||||
|
}
|
||||||
|
|
||||||
|
@postrestart
|
||||||
|
public void postRestart() {
|
||||||
|
System.out.println("Reinitialize after restart by supervisor");
|
||||||
|
}
|
||||||
|
}
|
||||||
71
samples-scala/akka-samples-scala.iml
Normal file
71
samples-scala/akka-samples-scala.iml
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module relativePaths="true" MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/scala" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module" module-name="akka-kernel" exported="" />
|
||||||
|
<orderEntry type="module" module-name="akka-util-java" exported="" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-core:2.0-beta-4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-jsr250:2.0-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.annotation:jsr250-api:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.google.code:protobuf-java:2.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.scala-lang:scala-library:2.7.5" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.aspectwerkz:aspectwerkz-nodeps-jdk5:2.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: net.lag:configgy:1.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.scala-lang:scala-compiler:2.7.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.scala-tools:vscaladoc:1.1-md-3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: markdownj:markdownj:1.0.2b4-0.3.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: junit:junit:4.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.scala-tools.testing:specs:1.4.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guiceyfruit-core:2.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.guiceyfruit:guice-all:2.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.annotation:com.springsource.javax.annotation:1.0.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.aopalliance:com.springsource.org.aopalliance:1.0.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.google.code.google-collections:google-collect:snapshot-20080530" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: cglib:cglib:2.2" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: asm:asm:3.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: aopalliance:aopalliance:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache.camel:camel-core:2.0-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: commons-logging:commons-logging-api:1.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.xml.bind:jaxb-api:2.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.xml.stream:stax-api:1.0-2" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.activation:activation:1.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.xml.bind:jaxb-impl:2.1.6" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.jboss.netty:netty:3.1.0.CR1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache:zookeeper:3.1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-core-asl:1.1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache.cassandra:cassandra:0.4.0-dev" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.facebook:thrift:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.facebook:fb303:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache.commons:commons-collections:3.2.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: high-scale-lib:high-scale-lib:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.apache.commons:commons-lang:2.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-servlet-webserver:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-http:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-framework:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-utils:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-rcm:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-portunif:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.grizzly:grizzly-http-servlet:1.9.9" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-server:1.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-core:1.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: javax.ws.rs:jsr311-api:1.0" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-json:1.0.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.jettison:jettison:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: stax:stax-api:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.codehaus.jackson:jackson-asl:0.9.4" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.slf4j:slf4j-log4j12:1.4.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: org.slf4j:slf4j-api:1.4.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: log4j:log4j:1.2.13" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="Maven: com.sun.jersey:jersey-client:1.1.0-ea" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
|
|
||||||
118
samples-scala/pom.xml
Normal file
118
samples-scala/pom.xml
Normal file
|
|
@ -0,0 +1,118 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>akka-samples-scala</artifactId>
|
||||||
|
<name>Akka Scala Samples Module</name>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>akka</artifactId>
|
||||||
|
<groupId>${akka.groupId}</groupId>
|
||||||
|
<version>${akka.version}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${akka.groupId}</groupId>
|
||||||
|
<artifactId>akka-kernel</artifactId>
|
||||||
|
<version>${akka.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${akka.groupId}</groupId>
|
||||||
|
<artifactId>akka-util-java</artifactId>
|
||||||
|
<version>${akka.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>jsr311-api</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/scala</sourceDirectory>
|
||||||
|
<testSourceDirectory>src/test/scala</testSourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.scala-tools</groupId>
|
||||||
|
<artifactId>maven-scala-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<args>
|
||||||
|
<arg>-target:jvm-1.5</arg>
|
||||||
|
<arg>-unchecked</arg>
|
||||||
|
</args>
|
||||||
|
<scalaVersion>${scala.version}</scalaVersion>
|
||||||
|
<vscaladocVersion>1.1</vscaladocVersion>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-eclipse-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<downloadSources>true</downloadSources>
|
||||||
|
<buildcommands>
|
||||||
|
<buildcommand>
|
||||||
|
ch.epfl.lamp.sdt.core.scalabuilder
|
||||||
|
</buildcommand>
|
||||||
|
</buildcommands>
|
||||||
|
<additionalProjectnatures>
|
||||||
|
<projectnature>
|
||||||
|
ch.epfl.lamp.sdt.core.scalanature
|
||||||
|
</projectnature>
|
||||||
|
</additionalProjectnatures>
|
||||||
|
<classpathContainers>
|
||||||
|
<classpathContainer>
|
||||||
|
org.eclipse.jdt.launching.JRE_CONTAINER
|
||||||
|
</classpathContainer>
|
||||||
|
<classpathContainer>
|
||||||
|
ch.epfl.lamp.sdt.launching.SCALA_CONTAINER
|
||||||
|
</classpathContainer>
|
||||||
|
</classpathContainers>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>install</phase>
|
||||||
|
<configuration>
|
||||||
|
<tasks>
|
||||||
|
<copy file="target/akka-samples-scala-${akka.version}.jar"
|
||||||
|
tofile="../deploy/akka-samples-scala-${akka.version}.jar"/>
|
||||||
|
</tasks>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<filtering>false</filtering>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<filtering>false</filtering>
|
||||||
|
<directory>src/main/scala</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**</include>
|
||||||
|
</includes>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*.scala</exclude>
|
||||||
|
</excludes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
61
samples-scala/src/main/scala/SimpleService.scala
Normal file
61
samples-scala/src/main/scala/SimpleService.scala
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
package sample.scala
|
||||||
|
|
||||||
|
import javax.ws.rs.{Path, GET, Produces}
|
||||||
|
import se.scalablesolutions.akka.kernel.state.{TransactionalState, TransactionalMap, CassandraStorageConfig}
|
||||||
|
import se.scalablesolutions.akka.kernel.actor.{Supervisor, SupervisorFactory, Actor, StartSupervisor}
|
||||||
|
import se.scalablesolutions.akka.kernel.config.ScalaConfig._
|
||||||
|
|
||||||
|
class Boot {
|
||||||
|
object factory extends SupervisorFactory {
|
||||||
|
override def getSupervisorConfig: SupervisorConfig = {
|
||||||
|
SupervisorConfig(
|
||||||
|
RestartStrategy(OneForOne, 3, 100),
|
||||||
|
Supervise(
|
||||||
|
new SimpleService,
|
||||||
|
LifeCycle(Permanent, 100))
|
||||||
|
:: Nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val supervisor = factory.newSupervisor
|
||||||
|
supervisor.startSupervisor
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try service out by invoking (multiple times):
|
||||||
|
* <pre>
|
||||||
|
* curl http://localhost:9998/scalacount
|
||||||
|
* </pre>
|
||||||
|
* Or browse to the URL from a web browser.
|
||||||
|
*/
|
||||||
|
@Path("/scalacount")
|
||||||
|
class SimpleService extends Actor {
|
||||||
|
uuid = "SimpleService"
|
||||||
|
makeTransactionRequired
|
||||||
|
|
||||||
|
case object Tick
|
||||||
|
private val KEY = "COUNTER";
|
||||||
|
private var hasStartedTicking = false;
|
||||||
|
private val storage = TransactionalState.newPersistentMap(CassandraStorageConfig())
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces(Array("application/json"))
|
||||||
|
def count = (this !! Tick).getOrElse("Error in counter")
|
||||||
|
|
||||||
|
override def receive: PartialFunction[Any, Unit] = {
|
||||||
|
case Tick => if (hasStartedTicking) {
|
||||||
|
val counter = storage.get(KEY).get.asInstanceOf[Integer].intValue
|
||||||
|
storage.put(KEY, new Integer(counter + 1))
|
||||||
|
//reply(<h1>Tick: { counter + 1 } </h1>)
|
||||||
|
reply("Tick: " + (counter + 1) + "\n")
|
||||||
|
} else {
|
||||||
|
storage.put(KEY, new Integer(0))
|
||||||
|
hasStartedTicking = true
|
||||||
|
//reply(<h1>Tick: 0</h1>)
|
||||||
|
reply("Tick: 0\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected def postRestart(reason: AnyRef, config: Option[AnyRef]) = {
|
||||||
|
println("Restarting due to: " + reason.asInstanceOf[Exception].getMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue