Package com.github.devmix.process.acto
Interface ActiveObject<T>
- Type Parameters:
T- the type of the encapsulated instance
public interface ActiveObject<T>
Represents an active object that encapsulates its state and processes requests asynchronously.
- Author:
- Sergey Grachev
-
Method Summary
Modifier and TypeMethodDescription<R> CompletableFuture<R> get(AttributeGetter<T, R> action) Asynchronously retrieves an attribute from the encapsulated instance using the providedAttributeGetter.getId()Returns a unique identifier for this active object.Returns the encapsulated instance managed by this active object.Asynchronously invokes a method on the encapsulated instance using the providedInvoke.voidinvokeAnForget(Invoke<T> invoke) Asynchronously invokes a method on the encapsulated instance using the providedInvoke, without waiting for the operation to complete.<R> CompletableFuture<R> Asynchronously processes a request message, returning the result.voidrequestAndForget(Object message) Asynchronously processes a request message without waiting for the result.<V> CompletableFuture<Void> set(AttributeSetter<T, V> action, V value) Asynchronously sets an attribute in the encapsulated instance using the providedAttributeSetter.<V> voidsetAndForget(AttributeSetter<T, V> action, V value) Asynchronously sets an attribute in the encapsulated instance using the providedAttributeSetter, without waiting for the operation to complete.
-
Method Details
-
getId
Object getId()Returns a unique identifier for this active object.- Returns:
- the ID of this active object
-
getInstance
T getInstance()Returns the encapsulated instance managed by this active object.- Returns:
- the encapsulated instance
-
get
Asynchronously retrieves an attribute from the encapsulated instance using the providedAttributeGetter.- Type Parameters:
R- the type of the attribute to get- Parameters:
action- the action that retrieves the attribute- Returns:
- a CompletableFuture containing the retrieved attribute value
-
set
Asynchronously sets an attribute in the encapsulated instance using the providedAttributeSetter.- Type Parameters:
V- the type of the attribute to set- Parameters:
action- the action that sets the attributevalue- the new value for the attribute, or null if applicable- Returns:
- a CompletableFuture indicating completion of the operation
-
setAndForget
Asynchronously sets an attribute in the encapsulated instance using the providedAttributeSetter, without waiting for the operation to complete.- Type Parameters:
V- the type of the attribute to set- Parameters:
action- the action that sets the attributevalue- the new value for the attribute, or null if applicable
-
invoke
Asynchronously invokes a method on the encapsulated instance using the providedInvoke.- Parameters:
invoke- the invocation action to perform- Returns:
- a CompletableFuture indicating completion of the operation
-
invokeAnForget
Asynchronously invokes a method on the encapsulated instance using the providedInvoke, without waiting for the operation to complete.- Parameters:
invoke- the invocation action to perform
-
request
Asynchronously processes a request message, returning the result.- Type Parameters:
R- the type of the result- Parameters:
message- the request message to process- Returns:
- a CompletableFuture containing the result of processing the request
-
requestAndForget
Asynchronously processes a request message without waiting for the result.- Parameters:
message- the request message to process
-