added remote active objects configuration + remote tx semantics
This commit is contained in:
parent
47abc143a4
commit
10a0c16cb2
22 changed files with 1080 additions and 354 deletions
|
|
@ -1,9 +1,7 @@
|
|||
package se.scalablesolutions.akka.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class InMemFailer {
|
||||
public void fail() {
|
||||
public int fail() {
|
||||
throw new RuntimeException("expected");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package se.scalablesolutions.akka.api;
|
|||
|
||||
import se.scalablesolutions.akka.kernel.config.*;
|
||||
import static se.scalablesolutions.akka.kernel.config.JavaConfig.*;
|
||||
import se.scalablesolutions.akka.kernel.actor.*;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
|
@ -13,6 +14,7 @@ public class InMemoryStateTest extends TestCase {
|
|||
static String messageLog = "";
|
||||
|
||||
final private ActiveObjectGuiceConfiguratorForJava conf = new ActiveObjectGuiceConfiguratorForJava();
|
||||
final private ActiveObjectFactory factory = new ActiveObjectFactory();
|
||||
|
||||
protected void setUp() {
|
||||
conf.configureActiveObjects(
|
||||
|
|
@ -30,16 +32,16 @@ public class InMemoryStateTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess() {
|
||||
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
|
||||
InMemStateful stateful = factory.newRemoteInstance(InMemStateful.class); // conf.getActiveObject(InMemStateful.class);
|
||||
stateful.setMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init"); // set init state
|
||||
stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactional
|
||||
assertEquals("new state", stateful.getMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess"));
|
||||
}
|
||||
|
||||
public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() {
|
||||
InMemStateful stateful = conf.getActiveObject(InMemStateful.class);
|
||||
InMemStateful stateful = factory.newRemoteInstance(InMemStateful.class); // conf.getActiveObject(InMemStateful.class);
|
||||
stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state
|
||||
InMemFailer failer = conf.getActiveObject(InMemFailer.class);
|
||||
InMemFailer failer = factory.newRemoteInstance(InMemFailer.class); //conf.getActiveObject(InMemFailer.class);
|
||||
try {
|
||||
stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactional method
|
||||
fail("should have thrown an exception");
|
||||
|
|
|
|||
|
|
@ -2,6 +2,5 @@ package se.scalablesolutions.akka.api;
|
|||
|
||||
public class NettyClient {
|
||||
public static void main(String[] args) {
|
||||
new se.scalablesolutions.akka.kernel.nio.NettyClient();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package se.scalablesolutions.akka.api;
|
||||
|
||||
public class PersistentFailer {
|
||||
public void fail() {
|
||||
public int fail() {
|
||||
throw new RuntimeException("expected");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,11 +50,12 @@ public class PersistentStateful {
|
|||
}
|
||||
|
||||
@transactional
|
||||
public void failure(String key, String msg, PersistentFailer failer) {
|
||||
public String failure(String key, String msg, PersistentFailer failer) {
|
||||
mapState.put(key, msg);
|
||||
vectorState.add(msg);
|
||||
refState.swap(msg);
|
||||
failer.fail();
|
||||
return msg;
|
||||
}
|
||||
|
||||
@transactional
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue