removed calls to deprecated Props constructor in java code

This commit is contained in:
drexin 2013-05-02 17:00:44 +02:00
parent bdfc1e4bf9
commit 308428e7bc
14 changed files with 28 additions and 68 deletions

View file

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

View file

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

View file

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

View file

@ -14,7 +14,7 @@ public class CustomRouteTest {
// only to test compilability // only to test compilability
public void testRoute() { 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>, final scala.Function1<scala.Tuple2<ActorRef, Object>,
scala.collection.immutable.Iterable<Destination>> route = ExtractRoute.apply(ref); scala.collection.immutable.Iterable<Destination>> route = ExtractRoute.apply(ref);
route.apply(null); route.apply(null);

View file

@ -41,7 +41,7 @@ public class ConsumerJavaTestBase {
ExecutionContext executionContext = system.dispatcher(); ExecutionContext executionContext = system.dispatcher();
try { try {
Await.result( 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); duration);
return camel.template().requestBody("direct:error-handler-test-java", "hello", String.class); return camel.template().requestBody("direct:error-handler-test-java", "hello", String.class);
} }

View file

@ -38,7 +38,7 @@ public class CustomRouteTestBase {
@Test @Test
public void testCustomProducerRoute() throws Exception { public void testCustomProducerRoute() throws Exception {
MockEndpoint mockEndpoint = camel.context().getEndpoint("mock:mockProducer", MockEndpoint.class); 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.context().addRoutes(new CustomRouteBuilder("direct:test",producer));
camel.template().sendBody("direct:test", "test"); camel.template().sendBody("direct:test", "test");
assertMockEndpoint(mockEndpoint); assertMockEndpoint(mockEndpoint);
@ -48,11 +48,7 @@ public class CustomRouteTestBase {
@Test @Test
public void testCustomProducerUriRoute() throws Exception { public void testCustomProducerUriRoute() throws Exception {
MockEndpoint mockEndpoint = camel.context().getEndpoint("mock:mockProducerUri", MockEndpoint.class); MockEndpoint mockEndpoint = camel.context().getEndpoint("mock:mockProducerUri", MockEndpoint.class);
ActorRef producer = system.actorOf(new Props(new UntypedActorFactory(){ ActorRef producer = system.actorOf(Props.create(EndpointProducer.class, "mock:mockProducerUri"), "mockEndpointUri");
public Actor create() {
return new EndpointProducer("mock:mockProducerUri");
}
}), "mockEndpointUri");
camel.context().addRoutes(new CustomRouteBuilder("direct:test",producer)); camel.context().addRoutes(new CustomRouteBuilder("direct:test",producer));
camel.template().sendBody("direct:test", "test"); camel.template().sendBody("direct:test", "test");
assertMockEndpoint(mockEndpoint); assertMockEndpoint(mockEndpoint);
@ -66,7 +62,7 @@ public class CustomRouteTestBase {
Timeout timeout = new Timeout(duration); Timeout timeout = new Timeout(duration);
ExecutionContext executionContext = system.dispatcher(); ExecutionContext executionContext = system.dispatcher();
ActorRef consumer = Await.result( 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); duration);
camel.context().addRoutes(new CustomRouteBuilder("direct:testRouteConsumer",consumer)); camel.context().addRoutes(new CustomRouteBuilder("direct:testRouteConsumer",consumer));
camel.template().sendBody("direct:testRouteConsumer", "test"); camel.template().sendBody("direct:testRouteConsumer", "test");
@ -83,7 +79,7 @@ public class CustomRouteTestBase {
ActorRef consumer = Await.result( ActorRef consumer = Await.result(
camel.activationFutureFor( camel.activationFutureFor(
system.actorOf( 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), timeout, executionContext),
duration); duration);
camel.context().addRoutes(new CustomRouteBuilder("direct:testAck", consumer, false, 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); FiniteDuration duration = Duration.create(10, TimeUnit.SECONDS);
Timeout timeout = new Timeout(duration); Timeout timeout = new Timeout(duration);
ActorRef consumer = Await.result( 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), timeout, executionContext),
duration); duration);
camel.context().addRoutes(new CustomRouteBuilder("direct:testAckFromUri","akka://test/user/testConsumerAckUri?autoAck=false")); 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); Timeout timeout = new Timeout(duration);
ExecutionContext executionContext = system.dispatcher(); ExecutionContext executionContext = system.dispatcher();
ActorRef consumer = Await.result( 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), timeout, executionContext),
duration); duration);
camel.context().addRoutes(new CustomRouteBuilder("direct:testException", consumer, false, Duration.create(0, TimeUnit.SECONDS))); 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 //#demo-proxy
final ActorRef proxy = getContext().actorOf( final ActorRef proxy = getContext().actorOf(
new Props(new UntypedActorFactory() { Props.create(ReliableProxy.class, target, Duration.create(100, "millis")));
public Actor create() {
final FiniteDuration retry = Duration.create(100, "millis");
return new ReliableProxy(target, retry);
}
}));
public void onReceive(Object msg) { public void onReceive(Object msg) {
if ("hello".equals(msg)) { if ("hello".equals(msg)) {
@ -79,15 +74,8 @@ public class ReliableProxyTest {
return new UntypedActor() { return new UntypedActor() {
//#demo-transition //#demo-transition
final ActorRef proxy = getContext().actorOf( final ActorRef proxy = getContext().actorOf(Props.create(ReliableProxy.class, target, Duration.create(100, "millis")));
new Props(new UntypedActorFactory() {
public Actor create() {
final FiniteDuration retry = Duration.create(100, "millis");
return new ReliableProxy(target, retry);
}
}));
ActorRef client = null; ActorRef client = null;
{ {
proxy.tell(new FSM.SubscribeTransitionCallBack(getSelf()), getSelf()); proxy.tell(new FSM.SubscribeTransitionCallBack(getSelf()), getSelf());
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@ public class TestActorRefJavaCompile {
public void shouldBeAbleToCompileWhenUsingApply() { public void shouldBeAbleToCompileWhenUsingApply() {
//Just a dummy call to make sure it compiles //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(); ref.toString();
} }
} }

View file

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

View file

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