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 TriggerHandlers, ConditionHandlers and ActionHandlers
needed for the operation of the Modules included in Rules.
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 ModuleHandlergetHandler(Module module, String ruleUID) getTypes()Returns the UIDs of the module types currently supported by this factory.voidungetHandler(Module module, String ruleUID, ModuleHandler handler) Releases theModuleHandlerinstance when it is not needed anymore for handling the specifiedmodulein theRulewith the specifiedruleUID.
-
Method Details
-
getTypes
Collection<String> getTypes()Returns the UIDs of the module types currently supported by this factory. AModuleHandlerFactoryinstance can add new types to this list, but should not remove. If a module type is no longer supported, theModuleHandlerFactoryservice must be unregistered, and then registered again with the new list.If two or more
ModuleHandlerFactorys 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- theModulefor which aModuleHandlerinstance must be created.ruleUID- the identifier of theRulethat the given module belongs to.- Returns:
- a new
ModuleHandlerinstance, ornullif the type of themoduleparameter is not supported by this factory.
-
ungetHandler
Releases theModuleHandlerinstance when it is not needed anymore for handling the specifiedmodulein theRulewith the specifiedruleUID. If no otherRules andModules use thishandlerinstance, it should be disposed.- Parameters:
module- theModulefor which thehandlerwas created.ruleUID- the identifier of theRulethat the given module belongs to.handler- theModuleHandlerinstance that is no longer needed.
-