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;
19 * Provides metadata about Module from controller to registry.
21 public class ModuleInternalInfo implements Comparable<ModuleInternalInfo> {
23 private final ModuleIdentifier name;
24 // this registrator is passed to runtime bean registrator and config
25 // registry to register read only module.
26 // writable modules are registered using TransactionJMXRegistrator
28 private final DynamicReadableWrapper readableModule;
30 private final RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator;
31 // added when bean instance is registered to Osgi
32 // can be unregistered using this registration
33 private final OsgiRegistration osgiRegistration;
34 private final ModuleJMXRegistrator moduleJMXRegistrator;
35 private final int orderingIdx;
37 public ModuleInternalInfo(ModuleIdentifier name,
38 @Nullable DynamicReadableWrapper readableModule,
39 OsgiRegistration osgiRegistration,
40 RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator,
41 ModuleJMXRegistrator moduleJMXRegistrator, int orderingIdx) {
43 if (osgiRegistration == null) {
44 throw new IllegalArgumentException(
45 "Parameter 'osgiRegistration' is missing");
47 if (runtimeBeanRegistrator == null) {
48 throw new IllegalArgumentException(
49 "Parameter 'runtimeBeanRegistrator' is missing");
51 this.readableModule = readableModule;
52 this.osgiRegistration = osgiRegistration;
53 this.runtimeBeanRegistrator = runtimeBeanRegistrator;
55 this.moduleJMXRegistrator = moduleJMXRegistrator;
56 this.orderingIdx = orderingIdx;
59 public DynamicReadableWrapper getReadableModule() {
60 return readableModule;
63 public ModuleJMXRegistrator getModuleJMXRegistrator() {
64 return moduleJMXRegistrator;
69 * @return iif an running instance exists in the system.
71 public boolean hasReadableModule() {
72 return readableModule != null;
76 public String toString() {
77 return "ModuleInternalInfo [name=" + name + "]";
80 public RootRuntimeBeanRegistratorImpl getRuntimeBeanRegistrator() {
81 return runtimeBeanRegistrator;
84 public OsgiRegistration getOsgiRegistration() {
85 return osgiRegistration;
88 public ModuleIdentifier getName() {
93 * Get index representing dependency ordering within a transaction.
95 public int getOrderingIdx() {
100 * Compare using orderingIdx
103 public int compareTo(ModuleInternalInfo o) {
104 return Integer.compare(orderingIdx, o.orderingIdx);
107 public DestroyedModule toDestroyedModule() {
108 return new DestroyedModule(getName(),
109 getReadableModule().getInstance(), getModuleJMXRegistrator(),
110 getOsgiRegistration(), getOrderingIdx());