fixed bugs in typed actors doc

This commit is contained in:
Patrik Nordwall 2011-04-11 16:50:22 +02:00
parent f878ee4c5d
commit 9c08ca7b3d
2 changed files with 19 additions and 10 deletions

View file

@ -23,13 +23,15 @@ If you have a POJO with an interface implementation separation like this:
.. code-block:: java .. code-block:: java
interface RegistrationService { interface RegistrationService {
void register(User user, Credentials cred) void register(User user, Credentials cred);
User getUserFor(String username) User getUserFor(String username);
} }
.. code-block:: java .. 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) { public void register(User user, Credentials cred) {
... // register user ... // register user
} }
@ -69,9 +71,12 @@ Using a configuration object:
.. code-block:: java .. code-block:: java
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import akka.actor.TypedActorConfiguration;
import akka.util.FiniteDuration;
TypedActorConfiguration config = new TypedActorConfiguration() TypedActorConfiguration config = new TypedActorConfiguration()
.timeout(3000) .timeout(new FiniteDuration(3000, MILLISECONDS));
.makeTransactionRequired();
RegistrationService service = (RegistrationService) TypedActor.newInstance(RegistrationService.class, config); 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 { class PingImpl implements Ping extends TypedActor {
public void hit(int count) { public void hit(int count) {
Pong pong = (Pong) context.getSender(); Pong pong = (Pong) getContext().getSender();
pong.hit(count++); pong.hit(count++);
} }
} }

View file

@ -10,7 +10,7 @@ If you are using the `Spring Framework <http://springsource.org>`_ then take a l
Creating Typed Actors 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 `AspectWerkzs 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. Akka turns POJOs with interface and implementation into asynchronous (Typed) Actors. Akka is using `AspectWerkzs 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 .. code-block:: scala
import akka.actor.TypedActor
trait RegistrationService { trait RegistrationService {
def register(user: User, cred: Credentials): Unit def register(user: User, cred: Credentials): Unit
def getUserFor(username: String): User def getUserFor(username: String): User
@ -64,10 +66,12 @@ Configuration factory class
Using a configuration object: Using a configuration object:
.. code-block:: scala .. code-block:: scala
import akka.actor.TypedActorConfiguration
import akka.util.Duration
import akka.util.duration._
val config = new TypedActorConfiguration val config = TypedActorConfiguration()
.timeout(3000) .timeout(3000 millis)
.makeTransactionRequired
val service = TypedActor.newInstance(classOf[RegistrationService], classOf[RegistrationServiceImpl], config) val service = TypedActor.newInstance(classOf[RegistrationService], classOf[RegistrationServiceImpl], config)