add extension mechanism
- type is encoded in key, allowing proper typing in Scala & Java - test cases for Scala & Java are included to ensure that the API makes sense and does not break
This commit is contained in:
parent
7999c4c195
commit
69ce6aa9d6
7 changed files with 166 additions and 8 deletions
33
akka-actor-tests/src/test/java/akka/actor/JavaExtension.java
Normal file
33
akka-actor-tests/src/test/java/akka/actor/JavaExtension.java
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
package akka.actor;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class JavaExtension {
|
||||
|
||||
static class TestExtension implements Extension<TestExtension> {
|
||||
private ActorSystemImpl system;
|
||||
public static ExtensionKey<TestExtension> key = new ExtensionKey<TestExtension>() {};
|
||||
|
||||
public ExtensionKey<TestExtension> init(ActorSystemImpl system) {
|
||||
this.system = system;
|
||||
return key;
|
||||
}
|
||||
|
||||
public ActorSystemImpl getSystem() {
|
||||
return system;
|
||||
}
|
||||
}
|
||||
|
||||
private ActorSystem system = ActorSystem.create("JavaExtension", ActorSystemSpec.javaconfig());
|
||||
|
||||
@Test
|
||||
public void mustBeAccessible() {
|
||||
final ActorSystemImpl s = system.extension(TestExtension.key).getSystem();
|
||||
assertSame(s, system);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue