fixed bugs in typed actors doc
This commit is contained in:
parent
f878ee4c5d
commit
9c08ca7b3d
2 changed files with 19 additions and 10 deletions
|
|
@ -23,13 +23,15 @@ If you have a POJO with an interface implementation separation like this:
|
|||
.. code-block:: java
|
||||
|
||||
interface RegistrationService {
|
||||
void register(User user, Credentials cred)
|
||||
User getUserFor(String username)
|
||||
void register(User user, Credentials cred);
|
||||
User getUserFor(String username);
|
||||
}
|
||||
|
||||
.. code-block:: java
|
||||
|
||||
public class RegistrationServiceImpl implements RegistrationService extends TypedActor {
|
||||
import akka.actor.TypedActor;
|
||||
|
||||
public class RegistrationServiceImpl extends TypedActor implements RegistrationService {
|
||||
public void register(User user, Credentials cred) {
|
||||
... // register user
|
||||
}
|
||||
|
|
@ -69,9 +71,12 @@ Using a configuration object:
|
|||
|
||||
.. code-block:: java
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import akka.actor.TypedActorConfiguration;
|
||||
import akka.util.FiniteDuration;
|
||||
|
||||
TypedActorConfiguration config = new TypedActorConfiguration()
|
||||
.timeout(3000)
|
||||
.makeTransactionRequired();
|
||||
.timeout(new FiniteDuration(3000, MILLISECONDS));
|
||||
|
||||
RegistrationService service = (RegistrationService) TypedActor.newInstance(RegistrationService.class, config);
|
||||
|
||||
|
|
@ -161,7 +166,7 @@ Here is an example how you can use it to in a 'void' (e.g. fire-forget) method t
|
|||
class PingImpl implements Ping extends TypedActor {
|
||||
|
||||
public void hit(int count) {
|
||||
Pong pong = (Pong) context.getSender();
|
||||
Pong pong = (Pong) getContext().getSender();
|
||||
pong.hit(count++);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ If you are using the `Spring Framework <http://springsource.org>`_ then take a l
|
|||
Creating Typed Actors
|
||||
---------------------
|
||||
|
||||
**IMPORTANT:** The Typed Actors class must have access modifier 'public' and can't be an inner class (unless it is an inner class in an 'object').
|
||||
**IMPORTANT:** The Typed Actors class must have access modifier 'public' (which is default) and can't be an inner class (unless it is an inner class in an 'object').
|
||||
|
||||
Akka turns POJOs with interface and implementation into asynchronous (Typed) Actors. Akka is using `AspectWerkz’s Proxy <http://blogs.codehaus.org/people/jboner/archives/000914_awproxy_proxy_on_steriods.html>`_ implementation, which is the `most performant <http://docs.codehaus.org/display/AW/AOP+Benchmark>`_ proxy implementation there exists.
|
||||
|
||||
|
|
@ -22,6 +22,8 @@ If you have a POJO with an interface implementation separation like this:
|
|||
|
||||
.. code-block:: scala
|
||||
|
||||
import akka.actor.TypedActor
|
||||
|
||||
trait RegistrationService {
|
||||
def register(user: User, cred: Credentials): Unit
|
||||
def getUserFor(username: String): User
|
||||
|
|
@ -64,10 +66,12 @@ Configuration factory class
|
|||
Using a configuration object:
|
||||
|
||||
.. code-block:: scala
|
||||
import akka.actor.TypedActorConfiguration
|
||||
import akka.util.Duration
|
||||
import akka.util.duration._
|
||||
|
||||
val config = new TypedActorConfiguration
|
||||
.timeout(3000)
|
||||
.makeTransactionRequired
|
||||
val config = TypedActorConfiguration()
|
||||
.timeout(3000 millis)
|
||||
|
||||
val service = TypedActor.newInstance(classOf[RegistrationService], classOf[RegistrationServiceImpl], config)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue