/* * 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.Collection; import java.util.Set; 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.mdsal.dom.spi.RpcRoutingStrategy; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.binding.RpcService; import org.opendaylight.yangtools.yang.common.QName; 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
*
* @author Robert Varga
*/
public class ActionProviderBean {
static final String ACTION_PROVIDER = "action-provider";
private static final Logger LOG = LoggerFactory.getLogger(ActionProviderBean.class);
private DOMRpcProviderService domRpcProvider;
private RpcProviderService bindingRpcProvider;
private DOMSchemaService schemaService;
private RpcService implementation;
private String interfaceName;
private Registration reg;
private Bundle bundle;
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) {
this.domRpcProvider = rpcProviderService;
}
public void setBindingRpcProvider(final RpcProviderService rpcProvider) {
this.bindingRpcProvider = rpcProvider;
}
public void setSchemaService(final DOMSchemaService schemaService) {
this.schemaService = schemaService;
}
public void init() {
// First resolve the interface class
final Class