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 prevModule)
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 prevModule)
Users are welcome to override this method to provide custom logic for
advanced reusability detection.
|
protected abstract AutoCloseable |
createInstance()
Create instance.
|
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 prevInstance)
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 Module
protected abstract AutoCloseable createInstance()
public final boolean canReuse(Module prevModule)
Module
protected abstract boolean canReuseInstance(M prevModule)
prevModule
- old instance of a Moduleprotected AutoCloseable reuseInstance(AutoCloseable prevInstance)
prevInstance
- old instance of a class wrapped by the moduleprotected abstract void resolveDependencies()
Copyright © 2019 OpenDaylight. All rights reserved.