Class BaseModuleHandlerFactory
java.lang.Object
org.openhab.core.automation.handler.BaseModuleHandlerFactory
- All Implemented Interfaces:
ModuleHandlerFactory
- Direct Known Subclasses:
AnnotatedThingActionModuleTypeProvider
@NonNullByDefault
public abstract class BaseModuleHandlerFactory
extends Object
implements ModuleHandlerFactory
This class provides a
ModuleHandlerFactory
base implementation. It is used by its subclasses for base
implementation of creating and disposing ModuleHandler
instances. They only have to implement
internalCreate(Module, String)
method for creating concrete instances needed for the operation of the
Module
s.- Author:
- Kai Kreuzer - Initial contribution, Benedikt Niehues - change behavior for unregistering ModuleHandler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Should be overridden by the implementations that extend this base class.@Nullable ModuleHandler
getHandler
(Module module, String ruleUID) protected Map
<String, ModuleHandler> Provides all availableModuleHandler
s created by concrete factory implementation.protected String
getModuleIdentifier
(String ruleUid, String moduleId) protected abstract @Nullable ModuleHandler
internalCreate
(Module module, String ruleUID) void
ungetHandler
(Module module, String ruleUID, ModuleHandler handler) Releases theModuleHandler
instance when it is not needed anymore for handling the specifiedmodule
in theRule
with the specifiedruleUID
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openhab.core.automation.handler.ModuleHandlerFactory
getTypes
-
Constructor Details
-
BaseModuleHandlerFactory
public BaseModuleHandlerFactory()
-
-
Method Details
-
deactivate
protected void deactivate()Should be overridden by the implementations that extend this base class. Called from DS to deactivate theModuleHandlerFactory
. -
getHandlers
Provides all availableModuleHandler
s created by concrete factory implementation.- Returns:
- a map with keys calculated by concatenated rule UID and module Id and values representing
ModuleHandler
created for concrete module corresponding to the module Id and belongs to rule with such UID.
-
getHandler
Description copied from interface:ModuleHandlerFactory
- Specified by:
getHandler
in interfaceModuleHandlerFactory
- Parameters:
module
- theModule
for which aModuleHandler
instance must be created.ruleUID
- the identifier of theRule
that the given module belongs to.- Returns:
- a new
ModuleHandler
instance, ornull
if the type of themodule
parameter is not supported by this factory.
-
internalCreate
- Parameters:
module
- theModule
for which a handler should be created.ruleUID
- the identifier of theRule
that the given module belongs to.- Returns:
- a
ModuleHandler
instance ornull
if this module type is not supported.
-
ungetHandler
Description copied from interface:ModuleHandlerFactory
Releases theModuleHandler
instance when it is not needed anymore for handling the specifiedmodule
in theRule
with the specifiedruleUID
. If no otherRule
s andModule
s use thishandler
instance, it should be disposed.- Specified by:
ungetHandler
in interfaceModuleHandlerFactory
- Parameters:
module
- theModule
for which thehandler
was created.ruleUID
- the identifier of theRule
that the given module belongs to.handler
- theModuleHandler
instance that is no longer needed.
-
getModuleIdentifier
-