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 import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator
16 .TransactionModuleJMXRegistration;
17 import org.opendaylight.controller.config.spi.Module;
18 import org.opendaylight.controller.config.spi.ModuleFactory;
19 import org.opendaylight.yangtools.concepts.Identifiable;
21 public class ModuleInternalTransactionalInfo implements Identifiable<ModuleIdentifier> {
22 private final ModuleIdentifier name;
23 private final Module module;
24 private final ModuleFactory moduleFactory;
26 private final ModuleInternalInfo maybeOldInternalInfo;
27 private final TransactionModuleJMXRegistration transactionModuleJMXRegistration;
29 ModuleInternalTransactionalInfo(ModuleIdentifier name, Module module,
30 ModuleFactory moduleFactory,
31 ModuleInternalInfo maybeOldInternalInfo,
32 TransactionModuleJMXRegistration transactionModuleJMXRegistration) {
35 this.moduleFactory = moduleFactory;
36 this.maybeOldInternalInfo = maybeOldInternalInfo;
37 this.transactionModuleJMXRegistration = transactionModuleJMXRegistration;
40 public ModuleIdentifier getName() {
44 public boolean hasOldModule() {
45 return maybeOldInternalInfo != null;
48 public DestroyedModule toDestroyedModule() {
49 if (maybeOldInternalInfo == null) {
50 throw new IllegalStateException("Cannot destroy uncommitted module");
52 DynamicReadableWrapper oldModule = maybeOldInternalInfo
54 return new DestroyedModule(name, oldModule.getInstance(),
55 maybeOldInternalInfo.getModuleJMXRegistrator(),
56 maybeOldInternalInfo.getOsgiRegistration(),
57 maybeOldInternalInfo.getOrderingIdx());
61 public Module getModule() {
65 public ModuleFactory getModuleFactory() {
70 public ModuleInternalInfo getOldInternalInfo() {
71 if (maybeOldInternalInfo == null)
72 throw new NullPointerException();
73 return maybeOldInternalInfo;
76 public TransactionModuleJMXRegistration getTransactionModuleJMXRegistration() {
77 return transactionModuleJMXRegistration;
81 public ModuleIdentifier getIdentifier() {