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.dynamicmbean.DynamicReadableWrapper;
14 import org.opendaylight.controller.config.manager.impl.jmx.ModuleJMXRegistrator;
15 import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl;
16 import org.opendaylight.controller.config.manager.impl.osgi.BeanToOsgiServiceManager.OsgiRegistration;
17 import org.opendaylight.yangtools.concepts.Identifiable;
20 * Provides metadata about Module from controller to registry.
22 public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
23 Identifiable<ModuleIdentifier>{
25 private final ModuleIdentifier name;
26 // this registrator is passed to runtime bean registrator and config
27 // registry to register read only module.
28 // writable modules are registered using TransactionJMXRegistrator
30 private final DynamicReadableWrapper readableModule;
32 private final RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator;
33 // added when bean instance is registered to Osgi
34 // can be unregistered using this registration
35 private final OsgiRegistration osgiRegistration;
36 private final ModuleJMXRegistrator moduleJMXRegistrator;
37 private final int orderingIdx;
38 private final boolean isDefaultBean;
40 public ModuleInternalInfo(ModuleIdentifier name,
41 @Nullable DynamicReadableWrapper readableModule,
42 OsgiRegistration osgiRegistration,
43 RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator,
44 ModuleJMXRegistrator moduleJMXRegistrator, int orderingIdx,
45 boolean isDefaultBean) {
47 if (osgiRegistration == null) {
48 throw new IllegalArgumentException(
49 "Parameter 'osgiRegistration' is missing");
51 if (runtimeBeanRegistrator == null) {
52 throw new IllegalArgumentException(
53 "Parameter 'runtimeBeanRegistrator' is missing");
55 this.readableModule = readableModule;
56 this.osgiRegistration = osgiRegistration;
57 this.runtimeBeanRegistrator = runtimeBeanRegistrator;
59 this.moduleJMXRegistrator = moduleJMXRegistrator;
60 this.orderingIdx = orderingIdx;
61 this.isDefaultBean = isDefaultBean;
64 public DynamicReadableWrapper getReadableModule() {
65 return readableModule;
68 public ModuleJMXRegistrator getModuleJMXRegistrator() {
69 return moduleJMXRegistrator;
74 * @return iif an running instance exists in the system.
76 public boolean hasReadableModule() {
77 return readableModule != null;
81 public String toString() {
82 return "ModuleInternalInfo [name=" + name + "]";
85 public RootRuntimeBeanRegistratorImpl getRuntimeBeanRegistrator() {
86 return runtimeBeanRegistrator;
89 public OsgiRegistration getOsgiRegistration() {
90 return osgiRegistration;
94 public ModuleIdentifier getName() {
99 * Get index representing dependency ordering within a transaction.
101 public int getOrderingIdx() {
106 * Compare using orderingIdx
109 public int compareTo(ModuleInternalInfo o) {
110 return Integer.compare(orderingIdx, o.orderingIdx);
113 public DestroyedModule toDestroyedModule() {
114 return new DestroyedModule(getName(),
115 getReadableModule().getInstance(), getModuleJMXRegistrator(),
116 getOsgiRegistration(), getOrderingIdx());
120 public ModuleIdentifier getIdentifier() {
124 public boolean isDefaultBean() {
125 return isDefaultBean;