Interface ModuleHandlerFactory
- All Known Implementing Classes:
AnnotatedThingActionModuleTypeProvider
,BaseModuleHandlerFactory
@NonNullByDefault
public interface ModuleHandlerFactory
This interface represents a factory for
ModuleHandler
instances. It is used for creating
and disposing the TriggerHandler
s, ConditionHandler
s and ActionHandler
s
needed for the operation of the Module
s included in Rule
s.
ModuleHandlerFactory
implementations must be registered as services in the OSGi framework.
- Author:
- Yordan Mihaylov - Initial contribution, Benedikt Niehues - change behavior for unregistering ModuleHandler
-
Method Summary
Modifier and TypeMethodDescription@Nullable ModuleHandler
getHandler
(Module module, String ruleUID) getTypes()
Returns the UIDs of the module types currently supported by this factory.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
.
-
Method Details
-
getTypes
Collection<String> getTypes()Returns the UIDs of the module types currently supported by this factory. AModuleHandlerFactory
instance can add new types to this list, but should not remove. If a module type is no longer supported, theModuleHandlerFactory
service must be unregistered, and then registered again with the new list.If two or more
ModuleHandlerFactory
s support the same module type, the Rule Engine will choose one of them randomly. Once a factory is chosen, it will be used to create instances of this module type until its service is unregistered.- Returns:
- collection of module type UIDs supported by this factory.
-
getHandler
- 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.
-
ungetHandler
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.- 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.
-