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.TransactionModuleJMXRegistrator
15 .TransactionModuleJMXRegistration;
16 import org.opendaylight.controller.config.spi.Module;
17 import org.opendaylight.controller.config.spi.ModuleFactory;
18 import org.opendaylight.yangtools.concepts.Identifiable;
20 public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
21 private final ModuleIdentifier name;
22 private final Module module;
23 private final ModuleFactory moduleFactory;
25 private final ModuleInternalInfo maybeOldInternalInfo;
26 private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
27 private final boolean isDefaultBean;
29 ModuleInternalTransactionalInfo(ModuleIdentifier name, Module module,
30 ModuleFactory moduleFactory,
31 ModuleInternalInfo maybeOldInternalInfo,
32 TransactionModuleJMXRegistration transactionModuleJMXRegistration,
33 boolean isDefaultBean) {
36 this.moduleFactory = moduleFactory;
37 this.maybeOldInternalInfo = maybeOldInternalInfo;
38 this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
39 this.isDefaultBean = isDefaultBean;
43 public boolean hasOldModule() {
44 return maybeOldInternalInfo != null;
47 public DestroyedModule toDestroyedModule() {
48 if (maybeOldInternalInfo == null) {
49 throw new IllegalStateException("Cannot destroy uncommitted module");
51 DynamicReadableWrapper oldModule = maybeOldInternalInfo
53 return new DestroyedModule(name, oldModule.getInstance(),
54 maybeOldInternalInfo.getModuleJMXRegistrator(),
55 maybeOldInternalInfo.getOsgiRegistration(),
56 maybeOldInternalInfo.getOrderingIdx());
60 public Module getModule() {
64 public ModuleFactory getModuleFactory() {
69 public ModuleInternalInfo getOldInternalInfo() {
70 if (maybeOldInternalInfo == null)
71 throw new NullPointerException();
72 return maybeOldInternalInfo;
75 public TransactionModuleJMXRegistration getTransactionModuleJMXRegistration() {
76 return transactionModuleJMXRegistration;
80 public ModuleIdentifier getIdentifier() {
84 public boolean isDefaultBean() {