Package com.github.devmix.process.acto
Interface ActiveObjectsDispatcher
public interface ActiveObjectsDispatcher
The ActiveObjectsDispatcher interface defines methods for managing active objects and their lifecycle in a system.
- Author:
- Sergey Grachev
-
Method Summary
Modifier and TypeMethodDescription<T,I, O> ActiveObject <T> create(ActiveObjectFactory<T, I, O> factory, I id, O options) Creates an instance of an active object using the provided factory, id, and options.<T,I, O> ActiveObject <T> Creates an instance of an active object using the provided class type, id, and options.booleanDestroys an active object with the specified ID.<T> ActiveObject<T> Finds an active object by its ID.<T> ActiveObject<T> Finds an active object by its ID.longReturns the idle timeout for an active object in nanoseconds.longReturns the wait messages timeout for an active object in nanoseconds.<T,I, O> void registerFactory(Class<T> objectClass, ActiveObjectFactory<T, I, O> factory) Registers a factory with this dispatcher, which will be used to create instances of the specified class type.<T,I, O> void registerLifecycle(Class<T> objectClass, ActiveObjectLifecycle<T> lifecycle) Registers a lifecycle callback for the specified class type.voidshutdown(boolean force) Shuts down all active objects managed by this dispatcher.voidunregisterFactory(Class<?> objectClass) Unregisters a previously registered factory for the specified class type.
-
Method Details
-
create
Creates an instance of an active object using the provided factory, id, and options.- Type Parameters:
T- The type of the active object to be created.I- The type of the identifier used for the active object.O- The type of the options used for the active object.- Parameters:
factory- An implementation of ActiveObjectFactory which will create the instance of the active object.id- The unique identifier for the active object.options- Options that can be used by the factory to configure the active object.- Returns:
- A new instance of the active object.
-
create
Creates an instance of an active object using the provided class type, id, and options.- Type Parameters:
T- The type of the active object to be created.I- The type of the identifier used for the active object.O- The type of the options used for the active object.- Parameters:
objectClass- The class type of the active object to create.id- The unique identifier for the active object.options- Options that can be used by the factory to configure the active object.- Returns:
- A new instance of the active object.
-
findById
Finds an active object by its ID. If no active object is found with that ID, returns null.- Type Parameters:
T- The type of the active object to find.- Parameters:
id- The unique identifier of the active object to find.- Returns:
- An instance of ActiveObject if found; otherwise, null.
-
getById
Finds an active object by its ID. If no active object is found with that ID, this method throws an exception.- Type Parameters:
T- The type of the active object to find.- Parameters:
id- The unique identifier of the active object to find.- Returns:
- An instance of ActiveObject if found.
- Throws:
IllegalArgumentException- If no active object is found with the specified ID.
-
getIdleTimeout
long getIdleTimeout()Returns the idle timeout for an active object in nanoseconds. The maximum value that can be returned by this method is 106751 days.- Returns:
- Idle timeout in nanoseconds.
-
getWaitMessagesTimeout
long getWaitMessagesTimeout()Returns the wait messages timeout for an active object in nanoseconds. This is the time the system waits for messages to be processed by an active object.- Returns:
- Wait messages timeout in nanoseconds.
-
registerFactory
Registers a factory with this dispatcher, which will be used to create instances of the specified class type.- Type Parameters:
T- The type of active object for which the factory is being registered.I- The type of identifier used by this factory.O- The type of options used by this factory.- Parameters:
objectClass- The class type of the active objects created by the specified factory.factory- The ActiveObjectFactory instance which will be registered with this dispatcher.
-
registerLifecycle
Registers a lifecycle callback for the specified class type. This callback will be invoked when active objects of that type are created or destroyed.- Type Parameters:
T- The type of active object for which the lifecycle is being registered.I- The type of identifier used by this lifecycle.O- The type of options used by this lifecycle.- Parameters:
objectClass- The class type of the active objects for which this lifecycle will be used.lifecycle- An instance of ActiveObjectLifecycle to register.
-
shutdown
void shutdown(boolean force) Shuts down all active objects managed by this dispatcher. If force is true, it will forcibly terminate all active objects; otherwise, it will attempt to shut them down gracefully.- Parameters:
force- Indicates whether to forcefully shutdown the active objects (true) or not (false).
-
unregisterFactory
Unregisters a previously registered factory for the specified class type. This means that this dispatcher will no longer use this factory to create instances of that class.- Parameters:
objectClass- The class type for which the factory is being unregistered.
-
destroy
Destroys an active object with the specified ID. If force is true, it will forcibly terminate the active object; otherwise, it will attempt to destroy it gracefully.- Parameters:
objectId- The unique identifier of the active object to be destroyed.force- Indicates whether to forcefully destroy the active object (true) or not (false).- Returns:
- True if the active object was successfully destroyed; otherwise, false.
-