@Override
  protected CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
      final NormalizedNode<?, ?> input) {
    final Optional<NormalizedNode<?, ?>> maybeKey = NormalizedNodes.findNode(input, keyId);

    // Routing key is present, attempt to deliver as a routed RPC
    if (maybeKey.isPresent()) {
      final NormalizedNode<?, ?> key = maybeKey.get();
      final Object value = key.getValue();
      if (value instanceof YangInstanceIdentifier) {
        final YangInstanceIdentifier iid = (YangInstanceIdentifier) value;

        // Find a DOMRpcImplementation for a specific iid
        final List<DOMRpcImplementation> specificImpls = getImplementations(iid);
        if (specificImpls != null) {
          return specificImpls
              .get(0)
              .invokeRpc(DOMRpcIdentifier.create(getSchemaPath(), iid), input);
        }

        LOG.debug("No implementation for context {} found will now look for wildcard id", iid);

        // Find a DOMRpcImplementation for a wild card. Usually remote-rpc-connector would register
        // an
        // implementation this way
        final List<DOMRpcImplementation> mayBeRemoteImpls =
            getImplementations(YangInstanceIdentifier.EMPTY);

        if (mayBeRemoteImpls != null) {
          return mayBeRemoteImpls
              .get(0)
              .invokeRpc(DOMRpcIdentifier.create(getSchemaPath(), iid), input);
        }

      } else {
        LOG.warn("Ignoring wrong context value {}", value);
      }
    }

    final List<DOMRpcImplementation> impls = getImplementations(null);
    if (impls != null) {
      return impls.get(0).invokeRpc(globalRpcId, input);
    } else {
      return Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(
          new DOMRpcImplementationNotAvailableException(
              "No implementation of RPC %s available", getSchemaPath()));
    }
  }
 RoutedDOMRpcRoutingTableEntry(
     final RpcDefinition def,
     final YangInstanceIdentifier keyId,
     final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
   super(def.getPath(), impls);
   this.keyId = Preconditions.checkNotNull(keyId);
   this.globalRpcId = DOMRpcIdentifier.create(def.getPath());
 }
 private RoutedDOMRpcRoutingTableEntry(
     final DOMRpcIdentifier globalRpcId,
     final YangInstanceIdentifier keyId,
     final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) {
   super(globalRpcId.getType(), impls);
   this.keyId = Preconditions.checkNotNull(keyId);
   this.globalRpcId = Preconditions.checkNotNull(globalRpcId);
 }