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
8 package org.opendaylight.controller.config.manager.impl;
10 import javax.annotation.Nullable;
12 import org.opendaylight.controller.config.api.ModuleIdentifier;
13 import org.opendaylight.controller.config.manager.impl.dependencyresolver.DestroyedModule;
14 import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
15 import org.opendaylight.controller.config.manager.impl.jmx.ModuleJMXRegistrator;
16 import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl;
17 import org.opendaylight.controller.config.manager.impl.osgi.BeanToOsgiServiceManager.OsgiRegistration;
18 import org.opendaylight.yangtools.concepts.Identifiable;
21 * Provides metadata about Module from controller to registry.
23 public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
24 Identifiable<ModuleIdentifier>{
26 private final ModuleIdentifier name;
27 // this registrator is passed to runtime bean registrator and config
28 // registry to register read only module.
29 // writable modules are registered using TransactionJMXRegistrator
31 private final DynamicReadableWrapper readableModule;
33 private final RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator;
34 // added when bean instance is registered to Osgi
35 // can be unregistered using this registration
36 private final OsgiRegistration osgiRegistration;
37 private final ModuleJMXRegistrator moduleJMXRegistrator;
38 private final int orderingIdx;
39 private final boolean isDefaultBean;
41 public ModuleInternalInfo(ModuleIdentifier name,
42 @Nullable DynamicReadableWrapper readableModule,
43 OsgiRegistration osgiRegistration,
44 RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator,
45 ModuleJMXRegistrator moduleJMXRegistrator, int orderingIdx,
46 boolean isDefaultBean) {
48 if (osgiRegistration == null) {
49 throw new IllegalArgumentException(
50 "Parameter 'osgiRegistration' is missing");
52 if (runtimeBeanRegistrator == null) {
53 throw new IllegalArgumentException(
54 "Parameter 'runtimeBeanRegistrator' is missing");
56 this.readableModule = readableModule;
57 this.osgiRegistration = osgiRegistration;
58 this.runtimeBeanRegistrator = runtimeBeanRegistrator;
60 this.moduleJMXRegistrator = moduleJMXRegistrator;
61 this.orderingIdx = orderingIdx;
62 this.isDefaultBean = isDefaultBean;
65 public DynamicReadableWrapper getReadableModule() {
66 return readableModule;
69 public ModuleJMXRegistrator getModuleJMXRegistrator() {
70 return moduleJMXRegistrator;
75 * @return iif an running instance exists in the system.
77 public boolean hasReadableModule() {
78 return readableModule != null;
82 public String toString() {
83 return "ModuleInternalInfo [name=" + name + "]";
86 public RootRuntimeBeanRegistratorImpl getRuntimeBeanRegistrator() {
87 return runtimeBeanRegistrator;
90 public OsgiRegistration getOsgiRegistration() {
91 return osgiRegistration;
95 * Get index representing dependency ordering within a transaction.
97 public int getOrderingIdx() {
102 * Compare using orderingIdx
105 public int compareTo(ModuleInternalInfo o) {
106 return Integer.compare(orderingIdx, o.orderingIdx);
109 public DestroyedModule toDestroyedModule() {
110 return new DestroyedModule(getIdentifier(),
111 getReadableModule().getInstance(), getModuleJMXRegistrator(),
112 getOsgiRegistration(), getOrderingIdx());
116 public ModuleIdentifier getIdentifier() {
120 public boolean isDefaultBean() {
121 return isDefaultBean;