X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fblueprint%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2Fext%2FRpcServiceMetadata.java;h=28590c141b9b709308da40ce7d326d16e898cbb1;hb=dfc0c67fb640bb370eabb77953c9f625b5dc9adb;hp=b48d04245b68c2b00079cf66c1864568919e2662;hpb=d98d5bca742bfdff6c23e27aca21da04b15c33dd;p=controller.git diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcServiceMetadata.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcServiceMetadata.java index b48d04245b..28590c141b 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcServiceMetadata.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcServiceMetadata.java @@ -7,16 +7,9 @@ */ package org.opendaylight.controller.blueprint.ext; -import com.google.common.base.Preconditions; -import java.util.Collections; -import java.util.List; -import org.apache.aries.blueprint.ext.ComponentFactoryMetadata; -import org.apache.aries.blueprint.services.ExtendedBlueprintContainer; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yangtools.yang.binding.RpcService; -import org.osgi.service.blueprint.container.ComponentDefinitionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.Objects; +import java.util.function.Predicate; +import org.opendaylight.mdsal.dom.spi.ContentRoutedRpcContext; /** * Factory metadata corresponding to the "rpc-service" element that gets an RPC service implementation from @@ -24,77 +17,13 @@ import org.slf4j.LoggerFactory; * * @author Thomas Pantelis */ -class RpcServiceMetadata implements ComponentFactoryMetadata { - private static final Logger LOG = LoggerFactory.getLogger(RpcServiceMetadata.class); - - private final String id; - private final String interfaceName; - private ExtendedBlueprintContainer container; - - RpcServiceMetadata(String id, String interfaceName) { - this.id = id; - this.interfaceName = interfaceName; - } - - @Override - public String getId() { - return id; - } - - @Override - public int getActivation() { - return ACTIVATION_LAZY; - } - - @Override - public List getDependsOn() { - return Collections.singletonList(OpendaylightNamespaceHandler.RPC_REGISTRY_NAME); - } - - @Override - public void init(ExtendedBlueprintContainer container) { - this.container = container; - - LOG.debug("{}: In init", logName()); - } - - @SuppressWarnings("unchecked") - @Override - public Object create() throws ComponentDefinitionException { - LOG.debug("{}: In create: interfaceName: {}", logName(), interfaceName); - - RpcProviderRegistry rpcRegistry = (RpcProviderRegistry) container.getComponentInstance( - OpendaylightNamespaceHandler.RPC_REGISTRY_NAME); - - try { - Class rpcInterface = container.getBundleContext().getBundle().loadClass(interfaceName); - Preconditions.checkArgument(RpcService.class.isAssignableFrom(rpcInterface), - "Specified interface %s is not an RpcService", interfaceName); - - RpcService rpcService = rpcRegistry.getRpcService((Class)rpcInterface); - - LOG.debug("{}: create returning service {}", logName(), rpcService); - - return rpcService; - } catch(Exception e) { - throw new ComponentDefinitionException("Error getting RPC service for " + interfaceName, e); - } - } - - @Override - public void destroy(Object instance) { - } - - private String logName() { - return (container != null ? container.getBundleContext().getBundle().getSymbolicName() : "") + - " (" + id + ")"; +final class RpcServiceMetadata extends AbstractInvokableServiceMetadata { + RpcServiceMetadata(final String id, final String interfaceName) { + super(id, interfaceName); } @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("RpcServiceMetadata [id=").append(id).append(", interfaceName=").append(interfaceName) - .append("]"); - return builder.toString(); + Predicate rpcFilter() { + return Objects::isNull; } }