/* * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.blueprint.ext; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableSet; import java.util.Objects; import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; import org.opendaylight.mdsal.dom.api.DOMRpcProviderService; import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.RpcService; import org.osgi.framework.Bundle; import org.osgi.service.blueprint.container.ComponentDefinitionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Blueprint bean corresponding to the "action-provider" element that registers the promise to instantiate action * instances with RpcProviderRegistry. * *
* This bean has two distinct facets:
* - if a reference bean is provided, it registers it with {@link RpcProviderService}
* - if a reference bean is not provided, it registers the corresponding no-op implementation with
* {@link DOMRpcProviderService} for all action (Routed RPC) elements in the provided interface
*/
public class ActionProviderBean {
static final String ACTION_PROVIDER = "action-provider";
private static final Logger LOG = LoggerFactory.getLogger(ActionProviderBean.class);
private DOMRpcProviderService domRpcProvider = null;
private RpcProviderService bindingRpcProvider = null;
private DOMSchemaService schemaService = null;
private RpcService implementation = null;
private String interfaceName = null;
private Registration reg;
private Bundle bundle = null;
public void setBundle(final Bundle bundle) {
this.bundle = bundle;
}
public void setInterfaceName(final String interfaceName) {
this.interfaceName = interfaceName;
}
public void setImplementation(final RpcService implementation) {
this.implementation = implementation;
}
public void setDomRpcProvider(final DOMRpcProviderService rpcProviderService) {
domRpcProvider = rpcProviderService;
}
public void setBindingRpcProvider(final RpcProviderService rpcProvider) {
bindingRpcProvider = rpcProvider;
}
public void setSchemaService(final DOMSchemaService schemaService) {
this.schemaService = schemaService;
}
public void init() {
// First resolve the interface class
final Class