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 org.opendaylight.controller.config.api.ModuleIdentifier;
11 import org.opendaylight.controller.config.manager.impl.dynamicmbean.DynamicReadableWrapper;
12 import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator.TransactionModuleJMXRegistration;
13 import org.opendaylight.controller.config.spi.Module;
14 import org.opendaylight.controller.config.spi.ModuleFactory;
15 import org.opendaylight.yangtools.concepts.Identifiable;
17 import javax.annotation.Nullable;
19 public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
20 private final ModuleIdentifier name;
21 private final Module module;
22 private final ModuleFactory moduleFactory;
24 private final ModuleInternalInfo maybeOldInternalInfo;
25 private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
26 private final boolean isDefaultBean;
28 ModuleInternalTransactionalInfo(ModuleIdentifier name, Module module,
29 ModuleFactory moduleFactory,
30 ModuleInternalInfo maybeOldInternalInfo,
31 TransactionModuleJMXRegistration transactionModuleJMXRegistration,
32 boolean isDefaultBean) {
35 this.moduleFactory = moduleFactory;
36 this.maybeOldInternalInfo = maybeOldInternalInfo;
37 this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
38 this.isDefaultBean = isDefaultBean;
42 public boolean hasOldModule() {
43 return maybeOldInternalInfo != null;
46 public DestroyedModule toDestroyedModule() {
47 if (maybeOldInternalInfo == null) {
48 throw new IllegalStateException("Cannot destroy uncommitted module");
50 DynamicReadableWrapper oldModule = maybeOldInternalInfo
52 return new DestroyedModule(name, oldModule.getInstance(),
53 maybeOldInternalInfo.getModuleJMXRegistrator(),
54 maybeOldInternalInfo.getOsgiRegistration(),
55 maybeOldInternalInfo.getOrderingIdx());
59 public Module getModule() {
63 public ModuleFactory getModuleFactory() {
68 public ModuleInternalInfo getOldInternalInfo() {
69 if (maybeOldInternalInfo == null) {
70 throw new NullPointerException();
72 return maybeOldInternalInfo;
75 public TransactionModuleJMXRegistration getTransactionModuleJMXRegistration() {
76 return transactionModuleJMXRegistration;
80 public ModuleIdentifier getIdentifier() {
84 public boolean isDefaultBean() {