X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2FRpcProviderRegistryImpl.java;h=542dfa7e7bca61a0fc4ff33e31239c3c3872e73b;hp=f93457110181967063ec64c27a3f29c026320121;hb=b66923141fce710094cb8e61bf794f9f0e678f50;hpb=2705c12ece71bbf3961a2bb24bd809c2fff5886a diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java index f934571101..542dfa7e7b 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcProviderRegistryImpl.java @@ -7,29 +7,19 @@ */ package org.opendaylight.controller.sal.binding.impl; -import java.util.EventListener; -import java.util.Map; -import java.util.Map.Entry; -import java.util.HashMap; -import java.util.Set; -import java.util.WeakHashMap; - -import javax.swing.tree.ExpandVetoException; - import org.opendaylight.controller.md.sal.common.api.routing.RouteChange; import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher; import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter; import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator; import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper; import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder; -import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; -import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.BaseIdentity; @@ -38,7 +28,14 @@ import org.opendaylight.yangtools.yang.binding.RpcService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static com.google.common.base.Preconditions.*; +import java.util.EventListener; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.WeakHashMap; + +import static com.google.common.base.Preconditions.checkState; public class RpcProviderRegistryImpl implements // RpcProviderRegistry, // @@ -46,6 +43,7 @@ public class RpcProviderRegistryImpl implements // private RuntimeCodeGenerator rpcFactory = SingletonHolder.RPC_GENERATOR_IMPL; + // publicProxies is a cache of proxy objects where each value in the map corresponds to a specific RpcService private final Map, RpcService> publicProxies = new WeakHashMap<>(); private final Map, RpcRouter> rpcRouters = new WeakHashMap<>(); private final ListenerRegistry>> routeChangeListeners = ListenerRegistry @@ -56,7 +54,7 @@ public class RpcProviderRegistryImpl implements // private final String name; - private ListenerRegistry globalRpcListeners = ListenerRegistry.create(); + private final ListenerRegistry globalRpcListeners = ListenerRegistry.create(); public String getName() { return name; @@ -96,7 +94,6 @@ public class RpcProviderRegistryImpl implements // @Override public final T getRpcService(Class type) { - @SuppressWarnings("unchecked") T potentialProxy = (T) publicProxies.get(type); if (potentialProxy != null) { return potentialProxy; @@ -109,7 +106,7 @@ public class RpcProviderRegistryImpl implements // potentialProxy = (T) publicProxies.get(type); if (potentialProxy != null) { - return (T) potentialProxy; + return potentialProxy; } T proxy = rpcFactory.getDirectProxyFor(type); LOG.debug("Created {} as public proxy for {} in {}", proxy, type.getSimpleName(), this); @@ -151,10 +148,10 @@ public class RpcProviderRegistryImpl implements // LOG.error("Unhandled exception during invoking listener {}", e); } } - + } - private void notifyListenersRoutedCreated(RpcRouter router) { + private void notifyListenersRoutedCreated(RpcRouter router) { for (ListenerRegistration listener : routerInstantiationListener) { try { @@ -196,7 +193,7 @@ public class RpcProviderRegistryImpl implements // public interface RouterInstantiationListener extends EventListener { void onRpcRouterCreated(RpcRouter router); } - + public ListenerRegistration registerGlobalRpcRegistrationListener(GlobalRpcRegistrationListener listener) { return globalRpcListeners.register(listener); } @@ -204,7 +201,7 @@ public class RpcProviderRegistryImpl implements // public interface GlobalRpcRegistrationListener extends EventListener { void onGlobalRpcRegistered(Class cls); void onGlobalRpcUnregistered(Class cls); - + } private class RouteChangeForwarder implements @@ -250,7 +247,8 @@ public class RpcProviderRegistryImpl implements // public RpcProxyRegistration(Class type, T service, RpcProviderRegistryImpl registry) { super(service); - serviceType = type; + this.serviceType = type; + this.registry = registry; } @Override