# DaprSagaContextImpl (dapr-sdk-parent 1.12.2 API)
declaration: package: io.dapr.workflows.saga, class: DaprSagaContextImpl

Package io.dapr.workflows.saga

# Class DaprSagaContextImpl

java.lang.Object
io.dapr.workflows.saga.DaprSagaContextImpl

All Implemented Interfaces:
  `SagaContext`

public class DaprSagaContextImpl extends Object implements SagaContext
Dapr Saga Context implementation.

## Constructor Summary

Constructors
Constructor
Description
`DaprSagaContextImpl(Saga saga, WorkflowContext workflowContext)`
Constructor to build up instance.

## Method Summary

Modifier and Type
Method
Description
`void`
`compensate()`
Compensate all registered activities.
`void`
`registerCompensation(String activityClassName, Object activityInput)`
Register a compensation activity.

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

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

## Constructor Details

### DaprSagaContextImpl

public DaprSagaContextImpl(Saga saga, WorkflowContext workflowContext)
Constructor to build up instance.

Parameters:
  `saga` - Saga instance.
  `workflowContext` - Workflow context.
Throws:
  `IllegalArgumentException` - if saga or workflowContext is null.

## Method Details

### registerCompensation

public void registerCompensation(String activityClassName, Object activityInput)
Description copied from interface: `SagaContext`
Register a compensation activity.

Specified by:
  `registerCompensation` in interface `SagaContext`
Parameters:
  `activityClassName` - name of the activity class
  `activityInput` - input of the activity to be compensated

### compensate

public void compensate()
Description copied from interface: `SagaContext`
Compensate all registered activities.

Specified by:
  `compensate` in interface `SagaContext`