Formatting java codes with sbt-java-formatter.

This commit is contained in:
hepin1989 2019-01-12 04:00:53 +08:00
parent 27500001ea
commit 998c5a9285
401 changed files with 19750 additions and 17450 deletions

View file

@ -15,31 +15,33 @@ import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
//#import
// #import
import akka.actor.Actor;
import akka.actor.IndirectActorProducer;
//#import
// #import
public class DependencyInjectionDocTest extends AbstractJavaTest {
public static class TheActor extends AbstractActor {
final String s;
public TheActor(String s) {
this.s = s;
}
@Override
public Receive createReceive() {
return receiveBuilder()
.match(String.class, msg -> {
getSender().tell(s, getSelf());
})
.build();
.match(
String.class,
msg -> {
getSender().tell(s, getSelf());
})
.build();
}
}
static ActorSystem system = null;
@BeforeClass
@ -52,47 +54,48 @@ public class DependencyInjectionDocTest extends AbstractJavaTest {
TestKit.shutdownActorSystem(system);
}
//this is just to make the test below a tiny fraction nicer
// this is just to make the test below a tiny fraction nicer
private ActorSystem getContext() {
return system;
}
static
//#creating-indirectly
// #creating-indirectly
class DependencyInjector implements IndirectActorProducer {
final Object applicationContext;
final String beanName;
public DependencyInjector(Object applicationContext, String beanName) {
this.applicationContext = applicationContext;
this.beanName = beanName;
}
@Override
public Class<? extends Actor> actorClass() {
return TheActor.class;
}
@Override
public TheActor produce() {
TheActor result;
//#obtain-fresh-Actor-instance-from-DI-framework
// #obtain-fresh-Actor-instance-from-DI-framework
result = new TheActor((String) applicationContext);
//#obtain-fresh-Actor-instance-from-DI-framework
// #obtain-fresh-Actor-instance-from-DI-framework
return result;
}
}
//#creating-indirectly
// #creating-indirectly
@Test
public void indirectActorOf() {
final String applicationContext = "...";
//#creating-indirectly
final ActorRef myActor = getContext().actorOf(
Props.create(DependencyInjector.class, applicationContext, "TheActor"),
"TheActor");
//#creating-indirectly
// #creating-indirectly
final ActorRef myActor =
getContext()
.actorOf(
Props.create(DependencyInjector.class, applicationContext, "TheActor"), "TheActor");
// #creating-indirectly
new TestKit(system) {
{
myActor.tell("hello", getRef());
@ -100,5 +103,4 @@ public class DependencyInjectionDocTest extends AbstractJavaTest {
}
};
}
}