2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.runtime;
11 import com.google.common.collect.Sets;
12 import java.util.Collection;
14 import javax.management.ObjectName;
15 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ModuleConfig;
16 import org.w3c.dom.Document;
17 import org.w3c.dom.Element;
19 public class ModuleRuntime {
21 private final InstanceRuntime instanceRuntime;
23 public ModuleRuntime(InstanceRuntime instanceRuntime) {
24 this.instanceRuntime = instanceRuntime;
27 private ObjectName findRoot(Collection<ObjectName> runtimeBeanOns) {
28 for (ObjectName objectName : runtimeBeanOns) {
29 if (objectName.getKeyPropertyList().size() == 3){
33 throw new IllegalStateException("Root runtime bean not found among " + runtimeBeanOns);
36 public Element toXml(String namespace, Collection<ObjectName> runtimeBeanOns,
37 Document document, ModuleConfig moduleConfig, ObjectName configBeanON) {
39 Element moduleElement = moduleConfig.toXml(configBeanON, document, namespace);
41 ObjectName rootName = findRoot(runtimeBeanOns);
43 Set<ObjectName> childrenRuntimeBeans = Sets.newHashSet(runtimeBeanOns);
44 childrenRuntimeBeans.remove(rootName);
46 // FIXME: why is this called and not used?
47 instanceRuntime.toXml(rootName, childrenRuntimeBeans, document, moduleElement, namespace);