X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fcodegen%2Fimpl%2FRpcRouterCodegenInstance.java;h=783e5c0cd4f459e94a2009c5a6783c6e8a54cb42;hb=da7b79cbf4b48a928910796150da4cb128848783;hp=052fd2169a523b955a427f036e2a0ab6b7a03bc4;hpb=35000765cff05e4f59541bc497dfe253a3188644;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java index 052fd2169a..783e5c0cd4 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/RpcRouterCodegenInstance.java @@ -22,7 +22,7 @@ import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable; import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper; import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.concepts.util.ListenerRegistry; +import org.opendaylight.yangtools.util.ListenerRegistry; import org.opendaylight.yangtools.yang.binding.BaseIdentity; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; @@ -37,8 +37,6 @@ RpcRouter, RouteChangeListener, InstanceIdentif private static final Logger LOG = LoggerFactory.getLogger(RpcRouterCodegenInstance.class); - private T defaultService; - private final Class serviceType; private final T invocationProxy; @@ -49,11 +47,8 @@ RpcRouter, RouteChangeListener, InstanceIdentif private final Map, RpcRoutingTableImpl> routingTables; - private final String name; - @SuppressWarnings("unchecked") public RpcRouterCodegenInstance(final String name,final Class type, final T routerImpl, final Iterable> contexts) { - this.name = name; this.listeners = ListenerRegistry.create(); this.serviceType = type; this.invocationProxy = routerImpl; @@ -90,7 +85,7 @@ RpcRouter, RouteChangeListener, InstanceIdentif @Override public T getDefaultService() { - return defaultService; + return RuntimeCodeHelper.getDelegate(invocationProxy); } @Override @@ -125,11 +120,17 @@ RpcRouter, RouteChangeListener, InstanceIdentif return new RoutedRpcRegistrationImpl(service); } + public void removeDefaultImplementation(final T instance) { + RpcService current = RuntimeCodeHelper.getDelegate(invocationProxy); + if(instance == current) { + RuntimeCodeHelper.setDelegate(invocationProxy, null); + } + } + @Override public RpcRegistration registerDefaultService(final T service) { - // TODO Auto-generated method stub RuntimeCodeHelper.setDelegate(invocationProxy, service); - return null; + return new DefaultRpcImplementationRegistration(service); } private class RoutedRpcRegistrationImpl extends AbstractObjectRegistration implements RoutedRpcRegistration { @@ -168,4 +169,24 @@ RpcRouter, RouteChangeListener, InstanceIdentif } } + + private class DefaultRpcImplementationRegistration extends AbstractObjectRegistration implements RpcRegistration { + + + protected DefaultRpcImplementationRegistration(final T instance) { + super(instance); + } + + @Override + protected void removeRegistration() { + removeDefaultImplementation(this.getInstance()); + } + + @Override + public Class getServiceType() { + return serviceType; + } + } + + }