Search in sources :

Example 1 with ModuleRpcs

use of org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs in project controller by opendaylight.

the class RpcFacade method fromXml.

public OperationExecution fromXml(final XmlElement xml) throws DocumentedException {
    final String namespace;
    namespace = xml.getNamespace();
    final XmlElement contextInstanceElement = xml.getOnlyChildElement(CONTEXT_INSTANCE);
    final String operationName = xml.getName();
    final RuntimeRpcElementResolved id = RuntimeRpcElementResolved.fromXpath(contextInstanceElement.getTextContent(), operationName, namespace);
    final Rpcs rpcs = mapRpcs();
    final ModuleRpcs rpcMapping = rpcs.getRpcMapping(id);
    final InstanceRuntimeRpc instanceRuntimeRpc = rpcMapping.getRpc(id.getRuntimeBeanName(), operationName);
    // TODO move to Rpcs after xpath attribute is redesigned
    final ObjectName on = id.getObjectName(rpcMapping);
    Map<String, AttributeConfigElement> attributes = instanceRuntimeRpc.fromXml(xml);
    attributes = sortAttributes(attributes, xml);
    return new OperationExecution(on, instanceRuntimeRpc.getName(), attributes, instanceRuntimeRpc.getReturnType(), namespace);
}
Also used : AttributeConfigElement(org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement) RuntimeRpcElementResolved(org.opendaylight.controller.config.facade.xml.rpc.RuntimeRpcElementResolved) Rpcs(org.opendaylight.controller.config.facade.xml.rpc.Rpcs) ModuleRpcs(org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs) InstanceRuntimeRpc(org.opendaylight.controller.config.facade.xml.rpc.InstanceRuntimeRpc) XmlElement(org.opendaylight.controller.config.util.xml.XmlElement) ModuleRpcs(org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs) ObjectName(javax.management.ObjectName)

Example 2 with ModuleRpcs

use of org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs in project controller by opendaylight.

the class RpcFacade method mapRpcs.

public Rpcs mapRpcs() {
    final Map<String, Map<String, ModuleRpcs>> map = new HashMap<>();
    for (final Map.Entry<String, Map<String, ModuleMXBeanEntry>> namespaceToModuleEntry : yangStoreService.getModuleMXBeanEntryMap().entrySet()) {
        Map<String, ModuleRpcs> namespaceToModules = map.computeIfAbsent(namespaceToModuleEntry.getKey(), k -> new HashMap<>());
        for (final Map.Entry<String, ModuleMXBeanEntry> moduleEntry : namespaceToModuleEntry.getValue().entrySet()) {
            ModuleRpcs rpcMapping = namespaceToModules.computeIfAbsent(moduleEntry.getKey(), k -> new ModuleRpcs(yangStoreService.getEnumResolver()));
            final ModuleMXBeanEntry entry = moduleEntry.getValue();
            for (final RuntimeBeanEntry runtimeEntry : entry.getRuntimeBeans()) {
                rpcMapping.addNameMapping(runtimeEntry);
                for (final RuntimeBeanEntry.Rpc rpc : runtimeEntry.getRpcs()) {
                    rpcMapping.addRpc(runtimeEntry, rpc);
                }
            }
        }
    }
    return new Rpcs(map);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) RuntimeBeanEntry(org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry) Rpcs(org.opendaylight.controller.config.facade.xml.rpc.Rpcs) ModuleRpcs(org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs) ModuleRpcs(org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs) ModuleMXBeanEntry(org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

ModuleRpcs (org.opendaylight.controller.config.facade.xml.rpc.ModuleRpcs)2 Rpcs (org.opendaylight.controller.config.facade.xml.rpc.Rpcs)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ObjectName (javax.management.ObjectName)1 AttributeConfigElement (org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement)1 InstanceRuntimeRpc (org.opendaylight.controller.config.facade.xml.rpc.InstanceRuntimeRpc)1 RuntimeRpcElementResolved (org.opendaylight.controller.config.facade.xml.rpc.RuntimeRpcElementResolved)1 XmlElement (org.opendaylight.controller.config.util.xml.XmlElement)1 ModuleMXBeanEntry (org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry)1 RuntimeBeanEntry (org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry)1