11e5bfc63ead7c5fb2852ff2546a973cc9d9ff1b
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / ConfigTransactionControllerInternal.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.config.manager.impl;
9
10 import java.util.Collection;
11 import java.util.List;
12 import javax.management.ObjectName;
13 import org.opendaylight.controller.config.api.ModuleIdentifier;
14 import org.opendaylight.controller.config.api.ValidationException;
15 import org.opendaylight.controller.config.spi.ModuleFactory;
16 import org.osgi.framework.BundleContext;
17
18 /**
19  * Defines contract between {@link ConfigTransactionControllerImpl} (producer)
20  * and {@link ConfigRegistryImpl} (consumer).
21  */
22 interface ConfigTransactionControllerInternal extends
23         ConfigTransactionControllerImplMXBean, AutoCloseable {
24
25
26
27     /**
28      * 1, Copy already committed modules to current transaction.
29      * 2, Diff: compute added and removed factories from last run, then create new modules using
30      * {@link org.opendaylight.controller.config.spi.ModuleFactory#getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory, BundleContext)}
31      * and remove modules belonging to removed factories.
32      */
33     void copyExistingModulesAndProcessFactoryDiff(Collection<ModuleInternalInfo> entries, List<ModuleFactory> lastListOfFactories);
34
35     /**
36      * Call {@link org.opendaylight.controller.config.spi.Module#validate()} on
37      * all beans in transaction. Lock transaction after successful validation.
38      * This method can be called multiple times if validation fails, but cannot
39      * be called after it did not throw exception.
40      *
41      * @throws {@link RuntimeException} if validation fails. It is safe to run
42      *         this method in future
43      * @return CommitInfo
44      */
45     CommitInfo validateBeforeCommitAndLockTransaction()
46             throws ValidationException;
47
48     /**
49      * Call {@link org.opendaylight.controller.config.spi.Module#getInstance()}
50      * on all beans in transaction. This method can be only called once.
51      *
52      * @throws {@link RuntimeException} commit fails, indicates bug in config
53      *         bean
54      * @return ordered list of module identifiers that respects dependency
55      *         order.
56      */
57     List<ModuleIdentifier> secondPhaseCommit();
58
59     /**
60      * @return ObjectName of this transaction controller
61      */
62     ObjectName getControllerObjectName();
63
64     /**
65      * @return true iif transaction was committed or aborted.
66      */
67     boolean isClosed();
68
69     List<ModuleFactory> getCurrentlyRegisteredFactories();
70
71     BundleContext getModuleFactoryBundleContext(String factoryName);
72
73     SearchableServiceReferenceWritableRegistry  getWritableRegistry();
74
75     TransactionIdentifier getTransactionIdentifier();
76
77     @Override
78     void close();
79 }