Kanzi Framework  3.9.0
Java API
Action Class Referenceabstract

Actions are small operations that Kanzi executes when the trigger event that contains that action occurs and the trigger conditions are met. More...

Inheritance diagram for Action:
[legend]

Public Member Functions

void close ()
 Close the object, and release native resources.
 
Duration getDelay ()
 Returns the delay that Kanzi waits before it invokes an action. More...
 
Trigger getTrigger ()
 Returns the pointer to a trigger to which an action is attached. More...
 
void invoke ()
 Invokes the action.
 
void setDelay (Duration duration)
 Sets the delay that Kanzi waits before it invokes an action. More...
 
- Public Member Functions inherited from ActionBase
String getName ()
 Gets the name of an action. More...
 
- Public Member Functions inherited from KanziObject
boolean equals (Object object)
 
Domain getDomain ()
 Returns the domain the object belongs to. More...
 
Metaclass getDynamicMetaclass ()
 Returns the metaclass of the dynamic type of the object. More...
 
boolean isStale ()
 Test if the object is stale i.e. More...
 
void removeLocalValue (PropertyType propertyType)
 Removes the local value associated with the property. More...
 

Static Public Attributes

static final Metaclass metaclass = com.rightware.kanzi.metadata.ActionMetadata.metaclass
 The Metaclass for the class.
 
- Static Public Attributes inherited from ActionBase
static final Metaclass metaclass
 The Metaclass for the class. More...
 
- Static Public Attributes inherited from KanziObject
static final Metaclass metaclass = new AbstractMetaclass("Kanzi.Object")
 The Metaclass for the class.
 

Protected Member Functions

 Action (Domain domain, long handle, Metaclass metaclass)
 Wraps a given native Action. More...
 
void initialize ()
 Initializes the Action.
 
void onAttach ()
 Callback called by Kanzi during attach.
 
void onDelayedInvoke ()
 Callback called by Kanzi when the action is invoked by trigger with delay, after the delay duration expires. More...
 
void onDetach ()
 Callback called by Kanzi during detach.
 
void onInvoke ()
 Callback called by Kanzi when the action is invoked by its trigger without delay. More...
 
void onPrepareDelayedInvoke ()
 Callback called by Kanzi when the action is invoked by its trigger with delay. More...
 
void onUnprepareDelayedInvoke ()
 Kanzi calls this callback when an action is invoked by trigger with delay, after Action#onDelayedInvoke() callback, or when it cancels a delayed execution. More...
 

Static Protected Member Functions

static< Derived extends Action > ObjectRef< Derived > createDerived (Domain domain, String name, Metaclass metaclass)
 Creates a derived class instance. More...
 

Additional Inherited Members

- Public Attributes inherited from ActionBaseMetadata
AbstractMetaclass metaclass = new AbstractMetaclass("Kanzi.ActionBase")
 Metaclass for ActionBase.
 
- Public Attributes inherited from ActionMetadata
DynamicPropertyType< Integer > DelayProperty
 The time in milliseconds after which Kanzi invokes the action. More...
 
AbstractMetaclass metaclass = new AbstractMetaclass("Kanzi.Action")
 Metaclass for Action.
 

Detailed Description

Actions are small operations that Kanzi executes when the trigger event that contains that action occurs and the trigger conditions are met.

Action is the base class for actions. For example, if you want to perform a simple operation, such as set a value of a property, you can use a trigger with the SetPropertyAction action.

Kanzi provides a number of built-in action classes, such as SetPropertyAction that you can use to set the value of a property of a target node, and DispatchMessageAction that you can use to dispatch a message of specified type to a specified target. However, Kanzi also enables you to define your own actions by deriving from the Action class.

When you want to create an action that receives arguments of its triggering message or properties of a node, derive that action from the ForwardingAction class, which provides generic functionality for this purpose.

You can delay the invocation of an action by the amount of time that you set in the Action#DelayProperty

Constructor & Destructor Documentation

◆ Action()

Action ( Domain  domain,
long  handle,
Metaclass  metaclass 
)
protected

Wraps a given native Action.

Called by KanziObject.connectObject(ObjectWrapper) when connecting to a native action.

Parameters
domainUI Domain where this action belongs.
handleNative object that is backing this action.
metaclassMetaclass data for this action.

Member Function Documentation

◆ createDerived()

static <Derived extends Action> ObjectRef<Derived> createDerived ( Domain  domain,
String  name,
Metaclass  metaclass 
)
staticprotected

Creates a derived class instance.

Call this method as part of the create method for a derived class.

Parameters
domainUI Domain where this action belongs.
nameName of the action
metaclassMetaclass data of the action.
Returns
An ObjectRef that holds the created instance.

◆ getDelay()

Duration getDelay ( )

Returns the delay that Kanzi waits before it invokes an action.

You can set the delay in milliseconds with the Action#DelayProperty.

Returns
Delay for the action

◆ getTrigger()

Trigger getTrigger ( )

Returns the pointer to a trigger to which an action is attached.

Returns
The attached trigger.

◆ onDelayedInvoke()

void onDelayedInvoke ( )
protected

Callback called by Kanzi when the action is invoked by trigger with delay, after the delay duration expires.

Use this to execute an action with delay.

◆ onInvoke()

void onInvoke ( )
protected

Callback called by Kanzi when the action is invoked by its trigger without delay.

Use this to execute an action without delay.

◆ onPrepareDelayedInvoke()

void onPrepareDelayedInvoke ( )
protected

Callback called by Kanzi when the action is invoked by its trigger with delay.

Use this to prepare for delayed execution.

◆ onUnprepareDelayedInvoke()

void onUnprepareDelayedInvoke ( )
protected

Kanzi calls this callback when an action is invoked by trigger with delay, after Action#onDelayedInvoke() callback, or when it cancels a delayed execution.

An example of cancellation of delayed execution is when you detach the action before the execution is done. Use this function to roll back any preparations made for a delayed execution.

◆ setDelay()

void setDelay ( Duration  duration)

Sets the delay that Kanzi waits before it invokes an action.

Parameters
durationThe delay for invoking the action.