# AbstractActor (dapr-sdk-parent 1.10.0 API)

Package io.dapr.actors.runtime

## Class AbstractActor

- java.lang.Object
- - io.dapr.actors.runtime.AbstractActor

    public abstract class AbstractActor
    extends Object

Represents the base class for actors. The base type for actors, that provides the common functionality for actors. The state is preserved across actor garbage collections and fail-overs.

### Constructor Summary

Constructors
`protected` `AbstractActor​(ActorRuntimeContext runtimeContext, ActorId id)` Instantiates a new Actor.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected ActorStateManager` `getActorStateManager()` Returns the state store manager for this Actor.
`protected ActorId` `getId()` Returns the id of the actor.
`protected reactor.core.publisher.Mono<Void>` `onActivate()` Callback function invoked after an Actor has been activated.
`protected reactor.core.publisher.Mono<Void>` `onDeactivate()` Callback function invoked after an Actor has been deactivated.
`protected reactor.core.publisher.Mono<Void>` `onPostActorMethod​(ActorMethodContext actorMethodContext)` Callback function invoked after method is invoked.
`protected reactor.core.publisher.Mono<Void>` `onPreActorMethod​(ActorMethodContext actorMethodContext)` Callback function invoked before method is invoked.
`protected <T> reactor.core.publisher.Mono<String>` `registerActorTimer​(String timerName, String callback, T state, Duration dueTime, Duration period)` Registers a Timer for the actor.
`protected <T> reactor.core.publisher.Mono<Void>` `registerReminder​(String reminderName, T state, Duration dueTime, Duration period)` Registers a reminder for this Actor.
`protected reactor.core.publisher.Mono<Void>` `saveState()` Saves the state of this Actor.
`protected reactor.core.publisher.Mono<Void>` `unregisterReminder​(String reminderName)` Unregisters a Reminder.
`protected reactor.core.publisher.Mono<Void>` `unregisterTimer​(String timerName)` Unregisters an Actor timer.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractActor

    protected AbstractActor​(ActorRuntimeContext runtimeContext,
                            ActorId id)

Instantiates a new Actor.

Parameters:
  `runtimeContext` - Context for the runtime.
  `id` - Actor identifier.

### Method Detail

#### getId

    protected ActorId getId()

Returns the id of the actor.

Returns:
  Actor id.

#### getActorStateManager

    protected ActorStateManager getActorStateManager()

Returns the state store manager for this Actor.

Returns:
  State store manager for this Actor

#### registerReminder

    protected <T> reactor.core.publisher.Mono<Void> registerReminder​(String reminderName,
                                                                     T state,
                                                                     Duration dueTime,
                                                                     Duration period)

Registers a reminder for this Actor.

Type Parameters:
  `T` - Type of the state object.
Parameters:
  `reminderName` - Name of the reminder.
  `state` - State to be send along with reminder triggers.
  `dueTime` - Due time for the first trigger.
  `period` - Frequency for the triggers.
Returns:
  Asynchronous void response.

#### registerActorTimer

    protected <T> reactor.core.publisher.Mono<String> registerActorTimer​(String timerName,
                                                                         String callback,
                                                                         T state,
                                                                         Duration dueTime,
                                                                         Duration period)

Registers a Timer for the actor. A timer name is autogenerated by the runtime to keep track of it.

Type Parameters:
  `T` - Type for the state to be passed in to timer.
Parameters:
  `timerName` - Name of the timer, unique per Actor (auto-generated if null).
  `callback` - Name of the method to be called.
  `state` - State to be passed it to the method when timer triggers.
  `dueTime` - The amount of time to delay before the async callback is first invoked. Specify negative one (-1) milliseconds to prevent the timer from starting. Specify zero (0) to start the timer immediately.
  `period` - The time interval between invocations of the async callback. Specify negative one (-1) milliseconds to disable periodic signaling.
Returns:
  Asynchronous result with timer's name.

#### unregisterTimer

    protected reactor.core.publisher.Mono<Void> unregisterTimer​(String timerName)

Unregisters an Actor timer.

Parameters:
  `timerName` - Name of Timer to be unregistered.
Returns:
  Asynchronous void response.

#### unregisterReminder

    protected reactor.core.publisher.Mono<Void> unregisterReminder​(String reminderName)

Unregisters a Reminder.

Parameters:
  `reminderName` - Name of Reminder to be unregistered.
Returns:
  Asynchronous void response.

#### onActivate

    protected reactor.core.publisher.Mono<Void> onActivate()

Callback function invoked after an Actor has been activated.

Returns:
  Asynchronous void response.

#### onDeactivate

    protected reactor.core.publisher.Mono<Void> onDeactivate()

Callback function invoked after an Actor has been deactivated.

Returns:
  Asynchronous void response.

#### onPreActorMethod

    protected reactor.core.publisher.Mono<Void> onPreActorMethod​(ActorMethodContext actorMethodContext)

Callback function invoked before method is invoked.

Parameters:
  `actorMethodContext` - Method context.
Returns:
  Asynchronous void response.

#### onPostActorMethod

    protected reactor.core.publisher.Mono<Void> onPostActorMethod​(ActorMethodContext actorMethodContext)

Callback function invoked after method is invoked.

Parameters:
  `actorMethodContext` - Method context.
Returns:
  Asynchronous void response.

#### saveState

    protected reactor.core.publisher.Mono<Void> saveState()

Saves the state of this Actor.

Returns:
  Asynchronous void response.