Skip to content

Commit

Permalink
#2746 - document provider.getDefaultAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuhn committed Dec 4, 2012
1 parent 370eeb0 commit cda2c2b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 40 deletions.
Expand Up @@ -138,12 +138,7 @@ public DefaultAddressExt(ExtendedActorSystem system) {
}

public Address getAddress() {
final ActorRefProvider provider = system.provider();
if (provider instanceof RemoteActorRefProvider) {
return ((RemoteActorRefProvider) provider).transport().address();
} else {
throw new UnsupportedOperationException("need RemoteActorRefProvider");
}
return system.provider().getDefaultAddress();
}
}

Expand Down
8 changes: 2 additions & 6 deletions akka-docs/rst/java/serialization.rst
Expand Up @@ -149,16 +149,12 @@ concrete address handy you can create a dummy one for the right protocol using
``new Address(protocol, "", "", 0)`` (assuming that the actual transport used is as
lenient as Akka’s RemoteActorRefProvider).

There is a possible simplification available if you are just using the default
:class:`NettyRemoteTransport` with the :meth:`RemoteActorRefProvider`, which is
enabled by the fact that this combination has just a single remote address:
There is also a default remote address which is the one used by cluster support
(and typical systems have just this one); you can get it like this:

.. includecode:: code/docs/serialization/SerializationDocTestBase.java
:include: external-address-default

This solution has to be adapted once other providers are used (like the planned
extensions for clustering).

Deep serialization of Actors
----------------------------

Expand Down
Expand Up @@ -2,19 +2,6 @@
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/

//#extract-transport
package object akka {
// needs to be inside the akka package because accessing unsupported API !
def transportOf(system: actor.ExtendedActorSystem): remote.RemoteTransport =
system.provider match {
case r: remote.RemoteActorRefProvider r.transport
case _
throw new UnsupportedOperationException(
"this method requires the RemoteActorRefProvider to be configured")
}
}
//#extract-transport

package docs.serialization {

import org.scalatest.matchers.MustMatchers
Expand Down Expand Up @@ -216,7 +203,7 @@ package docs.serialization {
object ExternalAddress extends ExtensionKey[ExternalAddressExt]

class ExternalAddressExt(system: ExtendedActorSystem) extends Extension {
def addressForAkka: Address = akka.transportOf(system).address
def addressForAkka: Address = system.provider.getDefaultAddress
}

def serializeAkkaDefault(ref: ActorRef): String =
Expand Down
16 changes: 2 additions & 14 deletions akka-docs/rst/scala/serialization.rst
Expand Up @@ -138,24 +138,12 @@ concrete address handy you can create a dummy one for the right protocol using
``Address(protocol, "", "", 0)`` (assuming that the actual transport used is as
lenient as Akka’s RemoteActorRefProvider).

There is a possible simplification available if you are just using the default
:class:`NettyRemoteTransport` with the :meth:`RemoteActorRefProvider`, which is
enabled by the fact that this combination has just a single remote address.
This approach relies on internal API, which means that it is not guaranteed to
be supported in future versions. To make this caveat more obvious, some bridge
code in the ``akka`` package is required to make it work:

.. includecode:: code/docs/serialization/SerializationDocSpec.scala
:include: extract-transport

And with this, the address extraction goes like this:
There is also a default remote address which is the one used by cluster support
(and typical systems have just this one); you can get it like this:

.. includecode:: code/docs/serialization/SerializationDocSpec.scala
:include: external-address-default

This solution has to be adapted once other providers are used (like the planned
extensions for clustering).

Deep serialization of Actors
----------------------------

Expand Down

0 comments on commit cda2c2b

Please sign in to comment.