splitted kernel up in core + many sub modules
This commit is contained in:
parent
deeaa923d1
commit
ab6637044f
154 changed files with 1510 additions and 2651 deletions
23
akka-samples-java/src/main/java/sample/java/Boot.java
Normal file
23
akka-samples-java/src/main/java/sample/java/Boot.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package sample.java;
|
||||
|
||||
import se.scalablesolutions.akka.kernel.config.ActiveObjectManager;
|
||||
import static se.scalablesolutions.akka.kernel.config.JavaConfig.*;
|
||||
|
||||
public class Boot {
|
||||
final private ActiveObjectManager manager = new ActiveObjectManager();
|
||||
|
||||
public Boot() throws Exception {
|
||||
manager.configure(
|
||||
new RestartStrategy(new OneForOne(), 3, 5000),
|
||||
new Component[] {
|
||||
new Component(
|
||||
sample.java.SimpleService.class,
|
||||
new LifeCycle(new Permanent(), 1000),
|
||||
1000),
|
||||
new Component(
|
||||
sample.java.PersistentSimpleService.class,
|
||||
new LifeCycle(new Permanent(), 1000),
|
||||
1000)
|
||||
}).supervise();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Copyright (C) 2009 Scalable Solutions.
|
||||
*/
|
||||
|
||||
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/persistentjavacount
|
||||
* </pre>
|
||||
* Or browse to the URL from a web browser.
|
||||
*/
|
||||
@Path("/persistentjavacount")
|
||||
@transactionrequired
|
||||
public class PersistentSimpleService {
|
||||
private String KEY = "COUNTER";
|
||||
|
||||
private boolean hasStartedTicking = false;
|
||||
private TransactionalState factory = new TransactionalState();
|
||||
private TransactionalMap<Object, Object> storage = factory.newPersistentMap(new CassandraStorageConfig());
|
||||
|
||||
@GET
|
||||
@Produces({"application/html"})
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Copyright (C) 2009 Scalable Solutions.
|
||||
*/
|
||||
|
||||
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 storage = factory.newInMemoryMap();
|
||||
|
||||
@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");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue