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;
39 public ModuleInternalInfo(ModuleIdentifier name,
40 @Nullable DynamicReadableWrapper readableModule,
41 OsgiRegistration osgiRegistration,
42 RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator,
43 ModuleJMXRegistrator moduleJMXRegistrator, int orderingIdx) {
45 if (osgiRegistration == null) {
46 throw new IllegalArgumentException(
47 "Parameter 'osgiRegistration' is missing");
49 if (runtimeBeanRegistrator == null) {
50 throw new IllegalArgumentException(
51 "Parameter 'runtimeBeanRegistrator' is missing");
53 this.readableModule = readableModule;
54 this.osgiRegistration = osgiRegistration;
55 this.runtimeBeanRegistrator = runtimeBeanRegistrator;
57 this.moduleJMXRegistrator = moduleJMXRegistrator;
58 this.orderingIdx = orderingIdx;
61 public DynamicReadableWrapper getReadableModule() {
62 return readableModule;
65 public ModuleJMXRegistrator getModuleJMXRegistrator() {
66 return moduleJMXRegistrator;
71 * @return iif an running instance exists in the system.
73 public boolean hasReadableModule() {
74 return readableModule != null;
78 public String toString() {
79 return "ModuleInternalInfo [name=" + name + "]";
82 public RootRuntimeBeanRegistratorImpl getRuntimeBeanRegistrator() {
83 return runtimeBeanRegistrator;
86 public OsgiRegistration getOsgiRegistration() {
87 return osgiRegistration;
91 public ModuleIdentifier getName() {
96 * Get index representing dependency ordering within a transaction.
98 public int getOrderingIdx() {
103 * Compare using orderingIdx
106 public int compareTo(ModuleInternalInfo o) {
107 return Integer.compare(orderingIdx, o.orderingIdx);
110 public DestroyedModule toDestroyedModule() {
111 return new DestroyedModule(getName(),
112 getReadableModule().getInstance(), getModuleJMXRegistrator(),
113 getOsgiRegistration(), getOrderingIdx());
117 public ModuleIdentifier getIdentifier() {