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 org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ModuleConfig;
13 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ServiceRegistryWrapper;
14 import org.w3c.dom.Document;
15 import org.w3c.dom.Element;
17 import javax.management.ObjectName;
18 import java.util.Collection;
21 public class ModuleRuntime {
23 private final String moduleName;
24 private final InstanceRuntime instanceRuntime;
26 public ModuleRuntime(String moduleName, InstanceRuntime instanceRuntime) {
27 this.moduleName = moduleName;
28 this.instanceRuntime = instanceRuntime;
31 public InstanceRuntime getMbeanMapping() {
32 return instanceRuntime;
35 private ObjectName findRoot(Collection<ObjectName> runtimeBeanOns) {
36 for (ObjectName objectName : runtimeBeanOns) {
37 if (objectName.getKeyPropertyList().size() == 3)
40 throw new IllegalStateException("Root runtime bean not found among " + runtimeBeanOns);
43 public Element toXml(String namespace, Collection<ObjectName> runtimeBeanOns,
44 Document document, ModuleConfig moduleConfig, ObjectName configBeanON, ServiceRegistryWrapper serviceTracker) {
46 Element moduleElement = moduleConfig.toXml(configBeanON, serviceTracker, document, namespace);
48 ObjectName rootName = findRoot(runtimeBeanOns);
50 Set<ObjectName> childrenRuntimeBeans = Sets.newHashSet(runtimeBeanOns);
51 childrenRuntimeBeans.remove(rootName);
53 instanceRuntime.toXml(rootName, childrenRuntimeBeans, document, moduleElement, namespace);