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;
11 import org.opendaylight.controller.config.api.ModuleIdentifier;
12 import org.opendaylight.controller.config.manager.impl.dependencyresolver.DestroyedModule;
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.controller.config.spi.ModuleFactory;
18 import org.opendaylight.yangtools.concepts.Identifiable;
19 import org.osgi.framework.BundleContext;
22 * Provides metadata about Module from controller to registry.
24 public class ModuleInternalInfo implements Comparable<ModuleInternalInfo>,
25 Identifiable<ModuleIdentifier>{
27 private final ModuleIdentifier name;
28 // this registrator is passed to runtime bean registrator and config
29 // registry to register read only module.
30 // writable modules are registered using TransactionJMXRegistrator
32 private final DynamicReadableWrapper readableModule;
34 private final RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator;
35 // added when bean instance is registered to Osgi
36 // can be unregistered using this registration
37 private final OsgiRegistration osgiRegistration;
38 private final ModuleJMXRegistrator moduleJMXRegistrator;
39 private final int orderingIdx;
40 private final boolean isDefaultBean;
41 private final ModuleFactory moduleFactory;
42 private final BundleContext bundleContext;
44 public ModuleInternalInfo(ModuleIdentifier name,
45 @Nullable DynamicReadableWrapper readableModule,
46 OsgiRegistration osgiRegistration,
47 RootRuntimeBeanRegistratorImpl runtimeBeanRegistrator,
48 ModuleJMXRegistrator moduleJMXRegistrator, int orderingIdx,
49 boolean isDefaultBean, ModuleFactory moduleFactory, BundleContext bundleContext) {
51 if (osgiRegistration == null) {
52 throw new IllegalArgumentException(
53 "Parameter 'osgiRegistration' is missing");
55 if (runtimeBeanRegistrator == null) {
56 throw new IllegalArgumentException(
57 "Parameter 'runtimeBeanRegistrator' is missing");
59 this.readableModule = readableModule;
60 this.osgiRegistration = osgiRegistration;
61 this.runtimeBeanRegistrator = runtimeBeanRegistrator;
63 this.moduleJMXRegistrator = moduleJMXRegistrator;
64 this.orderingIdx = orderingIdx;
65 this.isDefaultBean = isDefaultBean;
66 this.moduleFactory = moduleFactory;
67 this.bundleContext = bundleContext;
70 public DynamicReadableWrapper getReadableModule() {
71 return readableModule;
74 public ModuleJMXRegistrator getModuleJMXRegistrator() {
75 return moduleJMXRegistrator;
80 * @return iif an running instance exists in the system.
82 public boolean hasReadableModule() {
83 return readableModule != null;
87 public String toString() {
88 return "ModuleInternalInfo [name=" + name + "]";
91 public RootRuntimeBeanRegistratorImpl getRuntimeBeanRegistrator() {
92 return runtimeBeanRegistrator;
95 public OsgiRegistration getOsgiRegistration() {
96 return osgiRegistration;
100 * Get index representing dependency ordering within a transaction.
102 public int getOrderingIdx() {
107 * Compare using orderingIdx
110 public int compareTo(ModuleInternalInfo o) {
111 return Integer.compare(orderingIdx, o.orderingIdx);
114 public DestroyedModule toDestroyedModule() {
115 return new DestroyedModule(getIdentifier(),
116 getReadableModule().getInstance(), getModuleJMXRegistrator(),
117 getOsgiRegistration(), getOrderingIdx());
121 public ModuleIdentifier getIdentifier() {
125 public boolean isDefaultBean() {
126 return isDefaultBean;
129 public ModuleFactory getModuleFactory() {
130 return moduleFactory;
133 public BundleContext getBundleContext() {
134 return bundleContext;