M - Type of module implementation. Enables easier implementation for the #isSame methodpublic abstract class AbstractModule<M extends AbstractModule<M>> extends Object implements Module
| Modifier and Type | Field and Description |
|---|---|
protected DependencyResolver |
dependencyResolver |
protected ModuleIdentifier |
identifier |
| Constructor and Description |
|---|
AbstractModule(ModuleIdentifier identifier,
DependencyResolver dependencyResolver)
Called when module is configured.
|
AbstractModule(ModuleIdentifier identifier,
DependencyResolver dependencyResolver,
M oldModule,
AutoCloseable oldInstance)
Called when module is reconfigured.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canReuse(Module oldModule)
Compare current module with oldModule and if the instance/live object
produced by the old module can be reused in this module as well return true.
|
protected abstract boolean |
canReuseInstance(M oldModule)
Users are welcome to override this method to provide custom logic for advanced reusability detection.
|
protected abstract AutoCloseable |
createInstance() |
ModuleIdentifier |
getIdentifier() |
AutoCloseable |
getInstance()
General algorithm for spawning/closing and reusing wrapped instances.
|
protected abstract void |
resolveDependencies()
Inject all the dependencies using dependency resolver instance.
|
protected AutoCloseable |
reuseInstance(AutoCloseable oldInstance)
By default the oldInstance is returned since this method is by default called only if the oldModule had the same configuration and dependencies configured.
|
void |
setCanReuseInstance(boolean canReuseInstance) |
protected final DependencyResolver dependencyResolver
protected final ModuleIdentifier identifier
public AbstractModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver)
identifier - id of current instance.dependencyResolver - resolver used in dependency injection and validation.public AbstractModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver, M oldModule, AutoCloseable oldInstance)
identifier - id of current instance.dependencyResolver - resolver used in dependency injection and validation.oldModule - old instance of module that is being reconfigred(replaced) by current instance. The old instance can be examined for reuse.oldInstance - old instance wrapped by the old module. This is the resource that is actually being reused if possible or closed otherwise.public ModuleIdentifier getIdentifier()
getIdentifier in interface org.opendaylight.yangtools.concepts.Identifiable<ModuleIdentifier>public final void setCanReuseInstance(boolean canReuseInstance)
public final AutoCloseable getInstance()
getInstance in interface Moduleprotected abstract AutoCloseable createInstance()
public final boolean canReuse(Module oldModule)
Moduleprotected abstract boolean canReuseInstance(M oldModule)
oldModule - old instance of a Moduleprotected AutoCloseable reuseInstance(AutoCloseable oldInstance)
oldInstance - old instance of a class wrapped by the moduleprotected abstract void resolveDependencies()
Copyright © 2017 OpenDaylight. All rights reserved.