-public class RpcListener implements RpcRegistrationListener{
-
- private static final Logger LOG = LoggerFactory.getLogger(RpcListener.class);
- private final ActorRef rpcRegistry;
- private final String actorPath;
-
- public RpcListener(ActorRef rpcRegistry, String actorPath) {
- this.rpcRegistry = rpcRegistry;
- this.actorPath = actorPath;
- }
-
- @Override
- public void onRpcImplementationAdded(QName rpc) {
- LOG.debug("Adding registration for [{}]", rpc);
- RouteIdentifierImpl routeId = new RouteIdentifierImpl(null, rpc, null);
- AddRpc addRpcMsg = new AddRpc(routeId, actorPath);
- try {
- ActorUtil.executeLocalOperation(rpcRegistry, addRpcMsg, ActorUtil.LOCAL_ASK_DURATION, ActorUtil.LOCAL_AWAIT_DURATION);
- LOG.debug("Route added [{}-{}]", routeId, this.actorPath);
- } catch (Exception e) {
- // Just logging it because Akka API throws this exception
- LOG.error(e.toString());
+/**
+ * A {@link DOMRpcAvailabilityListener} reacting to RPC implementations different than {@link RemoteRpcImplementation}.
+ * The knowledge of such implementations is forwarded to {@link RpcRegistry}, which is responsible for advertising
+ * their presence to other nodes.
+ */
+final class RpcListener implements DOMRpcAvailabilityListener {
+ private static final Logger LOG = LoggerFactory.getLogger(RpcListener.class);
+
+ private final ActorRef rpcRegistry;
+
+ RpcListener(final ActorRef rpcRegistry) {
+ this.rpcRegistry = requireNonNull(rpcRegistry);
+ }
+
+ @Override
+ public void onRpcAvailable(final Collection<DOMRpcIdentifier> rpcs) {
+ checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null.");
+ LOG.debug("Adding registration for [{}]", rpcs);
+
+ rpcRegistry.tell(new AddOrUpdateRoutes(rpcs), ActorRef.noSender());
+ }
+
+ @Override
+ public void onRpcUnavailable(final Collection<DOMRpcIdentifier> rpcs) {
+ checkArgument(rpcs != null, "Input Collection of DOMRpcIdentifier can not be null.");
+
+ LOG.debug("Removing registration for [{}]", rpcs);
+ rpcRegistry.tell(new RemoveRoutes(rpcs), ActorRef.noSender());