Merge pull request #1394 from drexin/wip-drexin-remove-deprecated-props-calls-java

removed calls to deprecated Props constructor in java code
This commit is contained in:
Roland Kuhn 2013-05-03 01:36:45 -07:00
commit d6ff7166d7
14 changed files with 27 additions and 67 deletions

View file

@ -52,13 +52,13 @@ public class JavaAPI {
@Test
public void mustBeAbleToCreateActorRefFromClass() {
ActorRef ref = system.actorOf(new Props(JavaAPITestActor.class));
ActorRef ref = system.actorOf(Props.create(JavaAPITestActor.class));
assertNotNull(ref);
}
@Test
public void mustBeAbleToCreateActorRefFromFactory() {
ActorRef ref = system.actorOf(new Props().withCreator(new Creator<Actor>() {
ActorRef ref = system.actorOf(Props.empty().withCreator(new Creator<Actor>() {
public Actor create() {
return new JavaAPITestActor();
}
@ -68,7 +68,7 @@ public class JavaAPI {
@Test
public void mustAcceptSingleArgTell() {
ActorRef ref = system.actorOf(new Props(JavaAPITestActor.class));
ActorRef ref = system.actorOf(Props.create(JavaAPITestActor.class));
ref.tell("hallo");
ref.tell("hallo", ref);
}

View file

@ -6,7 +6,7 @@ package akka.actor;
public class NonPublicClass {
public static Props createProps() {
return new Props(MyNonPublicActorClass.class);
return Props.create(MyNonPublicActorClass.class);
}
}

View file

@ -24,7 +24,7 @@ public class StashJavaAPI {
@Test
public void mustBeAbleToUseStash() {
ActorRef ref = system.actorOf(new Props(StashJavaAPITestActor.class)
ActorRef ref = system.actorOf(Props.create(StashJavaAPITestActor.class)
.withDispatcher("my-dispatcher"));
ref.tell("Hello", ref);
ref.tell("Hello", ref);

View file

@ -14,7 +14,7 @@ public class CustomRouteTest {
// only to test compilability
public void testRoute() {
final ActorRef ref = system.actorOf(new Props().withRouter(new RoundRobinRouter(1)));
final ActorRef ref = system.actorOf(Props.empty().withRouter(new RoundRobinRouter(1)));
final scala.Function1<scala.Tuple2<ActorRef, Object>,
scala.collection.immutable.Iterable<Destination>> route = ExtractRoute.apply(ref);
route.apply(null);

View file

@ -41,7 +41,7 @@ public class ConsumerJavaTestBase {
ExecutionContext executionContext = system.dispatcher();
try {
Await.result(
camel.activationFutureFor(system.actorOf(new Props(SampleErrorHandlingConsumer.class), "sample-error-handling-consumer"), timeout, executionContext),
camel.activationFutureFor(system.actorOf(Props.create(SampleErrorHandlingConsumer.class), "sample-error-handling-consumer"), timeout, executionContext),
duration);
return camel.template().requestBody("direct:error-handler-test-java", "hello", String.class);
}

View file

@ -38,7 +38,7 @@ public class CustomRouteTestBase {
@Test
public void testCustomProducerRoute() throws Exception {
MockEndpoint mockEndpoint = camel.context().getEndpoint("mock:mockProducer", MockEndpoint.class);
ActorRef producer = system.actorOf(new Props(MockEndpointProducer.class), "mockEndpoint");
ActorRef producer = system.actorOf(Props.create(MockEndpointProducer.class), "mockEndpoint");
camel.context().addRoutes(new CustomRouteBuilder("direct:test",producer));
camel.template().sendBody("direct:test", "test");
assertMockEndpoint(mockEndpoint);
@ -48,11 +48,7 @@ public class CustomRouteTestBase {
@Test
public void testCustomProducerUriRoute() throws Exception {
MockEndpoint mockEndpoint = camel.context().getEndpoint("mock:mockProducerUri", MockEndpoint.class);
ActorRef producer = system.actorOf(new Props(new UntypedActorFactory(){
public Actor create() {
return new EndpointProducer("mock:mockProducerUri");
}
}), "mockEndpointUri");
ActorRef producer = system.actorOf(Props.create(EndpointProducer.class, "mock:mockProducerUri"), "mockEndpointUri");
camel.context().addRoutes(new CustomRouteBuilder("direct:test",producer));
camel.template().sendBody("direct:test", "test");
assertMockEndpoint(mockEndpoint);
@ -66,7 +62,7 @@ public class CustomRouteTestBase {
Timeout timeout = new Timeout(duration);
ExecutionContext executionContext = system.dispatcher();
ActorRef consumer = Await.result(
camel.activationFutureFor(system.actorOf(new Props(TestConsumer.class), "testConsumer"), timeout, executionContext),
camel.activationFutureFor(system.actorOf(Props.create(TestConsumer.class), "testConsumer"), timeout, executionContext),
duration);
camel.context().addRoutes(new CustomRouteBuilder("direct:testRouteConsumer",consumer));
camel.template().sendBody("direct:testRouteConsumer", "test");
@ -83,7 +79,7 @@ public class CustomRouteTestBase {
ActorRef consumer = Await.result(
camel.activationFutureFor(
system.actorOf(
new Props( new UntypedActorFactory(){ public Actor create() { return new TestAckConsumer("direct:testConsumerAck","mock:mockAck"); } }), "testConsumerAck"),
Props.create(TestAckConsumer.class, "direct:testConsumerAck","mock:mockAck"), "testConsumerAck"),
timeout, executionContext),
duration);
camel.context().addRoutes(new CustomRouteBuilder("direct:testAck", consumer, false, duration));
@ -99,7 +95,7 @@ public class CustomRouteTestBase {
FiniteDuration duration = Duration.create(10, TimeUnit.SECONDS);
Timeout timeout = new Timeout(duration);
ActorRef consumer = Await.result(
camel.activationFutureFor(system.actorOf(new Props( new UntypedActorFactory(){ public Actor create() { return new TestAckConsumer("direct:testConsumerAckFromUri","mock:mockAckUri"); } }), "testConsumerAckUri"),
camel.activationFutureFor(system.actorOf(Props.create(TestAckConsumer.class, "direct:testConsumerAckFromUri","mock:mockAckUri"), "testConsumerAckUri"),
timeout, executionContext),
duration);
camel.context().addRoutes(new CustomRouteBuilder("direct:testAckFromUri","akka://test/user/testConsumerAckUri?autoAck=false"));
@ -114,7 +110,7 @@ public class CustomRouteTestBase {
Timeout timeout = new Timeout(duration);
ExecutionContext executionContext = system.dispatcher();
ActorRef consumer = Await.result(
camel.activationFutureFor(system.actorOf(new Props( new UntypedActorFactory(){ public Actor create() { return new TestAckConsumer("direct:testConsumerException","mock:mockException"); } }), "testConsumerException"),
camel.activationFutureFor(system.actorOf(Props.create(TestAckConsumer.class, "direct:testConsumerException","mock:mockException"), "testConsumerException"),
timeout, executionContext),
duration);
camel.context().addRoutes(new CustomRouteBuilder("direct:testException", consumer, false, Duration.create(0, TimeUnit.SECONDS)));

View file

@ -49,12 +49,7 @@ public class ReliableProxyTest {
//#demo-proxy
final ActorRef proxy = getContext().actorOf(
new Props(new UntypedActorFactory() {
public Actor create() {
final FiniteDuration retry = Duration.create(100, "millis");
return new ReliableProxy(target, retry);
}
}));
Props.create(ReliableProxy.class, target, Duration.create(100, "millis")));
public void onReceive(Object msg) {
if ("hello".equals(msg)) {
@ -68,7 +63,7 @@ public class ReliableProxyTest {
parent.tell("hello", null);
probe.expectMsg("world!");
}
@Test
public void demonstrateTransitions() {
final ActorRef target = system.deadLetters();
@ -79,15 +74,8 @@ public class ReliableProxyTest {
return new UntypedActor() {
//#demo-transition
final ActorRef proxy = getContext().actorOf(
new Props(new UntypedActorFactory() {
public Actor create() {
final FiniteDuration retry = Duration.create(100, "millis");
return new ReliableProxy(target, retry);
}
}));
final ActorRef proxy = getContext().actorOf(Props.create(ReliableProxy.class, target, Duration.create(100, "millis")));
ActorRef client = null;
{
proxy.tell(new FSM.SubscribeTransitionCallBack(getSelf()), getSelf());
}

View file

@ -14,7 +14,7 @@ public class HelloKernel implements Bootable {
public static class HelloActor extends UntypedActor {
final ActorRef worldActor = getContext().actorOf(
new Props(WorldActor.class));
Props.create(WorldActor.class));
public void onReceive(Object message) {
if (message == "start")
@ -37,7 +37,7 @@ public class HelloKernel implements Bootable {
}
public void startup() {
system.actorOf(new Props(HelloActor.class)).tell("start", null);
system.actorOf(Props.create(HelloActor.class)).tell("start", null);
}
public void shutdown() {

View file

@ -16,7 +16,7 @@ public class JCalculatorApplication implements Bootable {
public JCalculatorApplication() {
system = ActorSystem.create("CalculatorApplication", ConfigFactory.load()
.getConfig("calculator"));
ActorRef actor = system.actorOf(new Props(JSimpleCalculatorActor.class),
ActorRef actor = system.actorOf(Props.create(JSimpleCalculatorActor.class),
"simpleCalculator");
}

View file

@ -7,7 +7,6 @@ import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import akka.kernel.Bootable;
import com.typesafe.config.ConfigFactory;
@ -19,13 +18,9 @@ public class JCreationApplication implements Bootable {
public JCreationApplication() {
system = ActorSystem.create("CreationApplication", ConfigFactory.load()
.getConfig("remotecreation"));
final ActorRef remoteActor = system.actorOf(new Props(JAdvancedCalculatorActor.class),
final ActorRef remoteActor = system.actorOf(Props.create(JAdvancedCalculatorActor.class),
"advancedCalculator");
actor = system.actorOf(new Props().withCreator(new UntypedActorFactory() {
public UntypedActor create() {
return new JCreationActor(remoteActor);
}
}), "creationActor");
actor = system.actorOf(Props.create(JCreationActor.class, remoteActor), "creationActor");
}

View file

@ -8,7 +8,6 @@ import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import akka.kernel.Bootable;
import com.typesafe.config.ConfigFactory;
//#imports
@ -21,11 +20,7 @@ public class JLookupApplication implements Bootable {
public JLookupApplication() {
system = ActorSystem.create("LookupApplication", ConfigFactory.load().getConfig("remotelookup"));
final String path = "akka.tcp://CalculatorApplication@127.0.0.1:2552/user/simpleCalculator";
actor = system.actorOf(new Props().withCreator(new UntypedActorFactory() {
public UntypedActor create() {
return new JLookupActor(path);
}
}), "lookupActor");
actor = system.actorOf(Props.create(JLookupActor.class, path), "lookupActor");
}
public void doSomething(Op.MathOp mathOp) {

View file

@ -11,7 +11,7 @@ public class TestActorRefJavaCompile {
public void shouldBeAbleToCompileWhenUsingApply() {
//Just a dummy call to make sure it compiles
TestActorRef<Actor> ref = TestActorRef.apply(new Props(), null);
TestActorRef<Actor> ref = TestActorRef.apply(Props.empty(), null);
ref.toString();
}
}

View file

@ -14,8 +14,6 @@ import org.junit.Before;
import akka.actor.ActorSystem;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import scala.concurrent.Await;
import scala.concurrent.Future;
import static akka.pattern.Patterns.ask;
@ -61,14 +59,10 @@ public class UntypedCoordinatedIncrementTest {
counters = new ArrayList<ActorRef>();
for (int i = 1; i <= numCounters; i++) {
final String name = "counter" + i;
ActorRef counter = system.actorOf(new Props(new UntypedActorFactory() {
public UntypedActor create() {
return new UntypedCoordinatedCounter(name);
}
}));
ActorRef counter = system.actorOf(Props.create(UntypedCoordinatedCounter.class, name));
counters.add(counter);
}
failer = system.actorOf(new Props(UntypedFailer.class));
failer = system.actorOf(Props.create(UntypedFailer.class));
}
@Test

View file

@ -14,8 +14,6 @@ import org.junit.Before;
import akka.actor.ActorSystem;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.actor.UntypedActorFactory;
import scala.concurrent.Await;
import scala.concurrent.Future;
import static akka.pattern.Patterns.ask;
@ -62,16 +60,10 @@ public class UntypedTransactorTest {
counters = new ArrayList<ActorRef>();
for (int i = 1; i <= numCounters; i++) {
final String name = "counter" + i;
ActorRef counter = system.actorOf(new Props(new UntypedActorFactory() {
private static final long serialVersionUID = 1L;
public UntypedActor create() {
return new UntypedCounter(name);
}
}));
ActorRef counter = system.actorOf(Props.create(UntypedCounter.class, name));
counters.add(counter);
}
failer = system.actorOf(new Props(UntypedFailer.class));
failer = system.actorOf(Props.create(UntypedFailer.class));
}
@Test