- @SuppressWarnings("unchecked")
- T potentialProxy = (T) publicProxies.get(type);
- if (potentialProxy != null) {
- return potentialProxy;
+ @Override
+ public org.opendaylight.controller.sal.binding.api.rpc.RpcRouter<?> call() {
+ RpcRouter<?> router = rpcFactory.getRouterFor(type, name);
+ router.registerRouteChangeListener(new RouteChangeForwarder<T>(type));
+ LOG.debug("Registering router {} as global implementation of {} in {}", router, type.getSimpleName(), this);
+ RuntimeCodeHelper.setDelegate(getRpcService(type), router.getInvocationProxy());
+ created.set(true);
+ return router;
+ }
+ });
+ if(created.get()) {
+ notifyListenersRoutedCreated(router);
+ }
+ return router;
+ } catch (ExecutionException | UncheckedExecutionException e) {
+ // We rethrow Runtime Exceptions which were wrapped by
+ // Execution Exceptions
+ // otherwise we throw IllegalStateException with original
+ Throwables.propagateIfPossible(e.getCause());
+ throw new IllegalStateException("Could not load RPC Router for "+type.getName(),e);