2 * Copyright (c) 2015 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.config.facade.xml.runtime;
11 import com.google.common.collect.Sets;
12 import java.util.Collection;
14 import javax.management.ObjectName;
15 import org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig;
16 import org.opendaylight.controller.config.facade.xml.osgi.EnumResolver;
17 import org.w3c.dom.Document;
18 import org.w3c.dom.Element;
20 public class ModuleRuntime {
22 private final InstanceRuntime instanceRuntime;
24 public ModuleRuntime(InstanceRuntime instanceRuntime) {
25 this.instanceRuntime = instanceRuntime;
28 private ObjectName findRoot(Collection<ObjectName> runtimeBeanOns) {
29 for (ObjectName objectName : runtimeBeanOns) {
30 if (objectName.getKeyPropertyList().size() == 3){
34 throw new IllegalStateException("Root runtime bean not found among " + runtimeBeanOns);
37 public Element toXml(String namespace, Collection<ObjectName> runtimeBeanOns,
38 Document document, ModuleConfig moduleConfig, ObjectName configBeanON, final EnumResolver enumResolver) {
40 Element moduleElement = moduleConfig.toXml(configBeanON, document, namespace, enumResolver);
42 ObjectName rootName = findRoot(runtimeBeanOns);
44 Set<ObjectName> childrenRuntimeBeans = Sets.newHashSet(runtimeBeanOns);
45 childrenRuntimeBeans.remove(rootName);
47 // FIXME: why is this called and not used?
48 instanceRuntime.toXml(rootName, childrenRuntimeBeans, document, moduleElement, namespace, enumResolver);