AutoSaveStateMiddleware Class

  • java.lang.Object
    • com.microsoft.bot.builder.AutoSaveStateMiddleware

Implements

public class AutoSaveStateMiddleware
implements Middleware

Middleware to automatically call .SaveChanges() at the end of the turn for all BotState class it is managing.

Constructor Summary

Constructor Description
AutoSaveStateMiddleware(BotState[] botStates)

Initializes a new instance of the AutoSaveStateMiddleware class.

AutoSaveStateMiddleware(BotStateSet withBotStateSet)

Initializes a new instance of the AutoSaveStateMiddleware class.

Method Summary

Modifier and Type Method and Description
AutoSaveStateMiddleware add(BotState botState)

Add a BotState to the list of sources to load.

BotStateSet getBotStateSet()

Gets the list of state management objects managed by this object.

java.util.concurrent.CompletableFuture<java.lang.Void> onTurn(TurnContext turnContext, NextDelegate next)

Middleware implementation which calls savesChanges automatically at the end of the turn.

void setBotStateSet(BotStateSet withBotStateSet)

Gets the list of state management objects managed by this object.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

AutoSaveStateMiddleware

public AutoSaveStateMiddleware(BotState[] botStates)

Initializes a new instance of the AutoSaveStateMiddleware class.

Parameters:

botStates - Initial list of BotState objects to manage.

AutoSaveStateMiddleware

public AutoSaveStateMiddleware(BotStateSet withBotStateSet)

Initializes a new instance of the AutoSaveStateMiddleware class.

Parameters:

withBotStateSet - Initial BotStateSet object to manage.

Method Details

add

public AutoSaveStateMiddleware add(BotState botState)

Add a BotState to the list of sources to load.

Parameters:

botState - botState to manage.

Returns:

botstateset for chaining more .use().

getBotStateSet

public BotStateSet getBotStateSet()

Gets the list of state management objects managed by this object.

Returns:

The state management objects managed by this object.

onTurn

public CompletableFuture onTurn(TurnContext turnContext, NextDelegate next)

Middleware implementation which calls savesChanges automatically at the end of the turn.

Parameters:

turnContext - The context object for this turn.
next - The delegate to call to continue the bot middleware pipeline.

Returns:

A task representing the asynchronous operation.

setBotStateSet

public void setBotStateSet(BotStateSet withBotStateSet)

Gets the list of state management objects managed by this object.

Parameters:

withBotStateSet - The state management objects managed by this object.

Applies to