Search in sources :

Example 6 with RpcDefinition

use of org.opendaylight.yangtools.yang.model.api.RpcDefinition in project controller by opendaylight.

the class BindingToNormalizedNodeCodec method getRpcMethodToSchemaPath.

// FIXME: This should be probably part of Binding Runtime context
public ImmutableBiMap<Method, SchemaPath> getRpcMethodToSchemaPath(final Class<? extends RpcService> key) {
    final Module module = getModuleBlocking(key);
    final ImmutableBiMap.Builder<Method, SchemaPath> ret = ImmutableBiMap.<Method, SchemaPath>builder();
    try {
        for (final RpcDefinition rpcDef : module.getRpcs()) {
            final Method method = findRpcMethod(key, rpcDef);
            ret.put(method, rpcDef.getPath());
        }
    } catch (final NoSuchMethodException e) {
        throw new IllegalStateException("Rpc defined in model does not have representation in generated class.", e);
    }
    return ret.build();
}
Also used : ImmutableBiMap(com.google.common.collect.ImmutableBiMap) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) Method(java.lang.reflect.Method) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Module(org.opendaylight.yangtools.yang.model.api.Module)

Example 7 with RpcDefinition

use of org.opendaylight.yangtools.yang.model.api.RpcDefinition in project controller by opendaylight.

the class DOMRpcRoutingTable method findRpcDefinition.

private static RpcDefinition findRpcDefinition(final SchemaContext context, final SchemaPath schemaPath) {
    if (context != null) {
        final QName qname = schemaPath.getPathFromRoot().iterator().next();
        final Module module = context.findModule(qname.getModule()).orElse(null);
        if (module != null && module.getRpcs() != null) {
            for (RpcDefinition rpc : module.getRpcs()) {
                if (qname.equals(rpc.getQName())) {
                    return rpc;
                }
            }
        }
    }
    return null;
}
Also used : RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) QName(org.opendaylight.yangtools.yang.common.QName) Module(org.opendaylight.yangtools.yang.model.api.Module)

Aggregations

RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)7 Module (org.opendaylight.yangtools.yang.model.api.Module)5 QName (org.opendaylight.yangtools.yang.common.QName)3 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)3 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 RpcRoutingStrategy (org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy)2 ContainerSchemaNode (org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode)2 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)2 LeafListSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode)2 LeafSchemaNode (org.opendaylight.yangtools.yang.model.api.LeafSchemaNode)2 ListSchemaNode (org.opendaylight.yangtools.yang.model.api.ListSchemaNode)2 SchemaNode (org.opendaylight.yangtools.yang.model.api.SchemaNode)2 SchemaPath (org.opendaylight.yangtools.yang.model.api.SchemaPath)2 UnknownSchemaNode (org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode)2 HashSet (java.util.HashSet)1 AttributeIfc (org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc)1 JavaAttribute (org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute)1 ListAttribute (org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute)1