mirror of https://github.com/dapr/java-sdk.git
Adding logger to WorkflowActivityContext
Signed-off-by: Artur Ciocanu <ciocanu@adobe.com>
This commit is contained in:
parent
5e0098a4c5
commit
b5b5e9e78d
|
|
@ -13,8 +13,12 @@ limitations under the License.
|
||||||
|
|
||||||
package io.dapr.workflows;
|
package io.dapr.workflows;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
public interface WorkflowActivityContext {
|
public interface WorkflowActivityContext {
|
||||||
|
|
||||||
|
Logger getLogger();
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
String getTaskExecutionId();
|
String getTaskExecutionId();
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,15 @@ package io.dapr.workflows.runtime;
|
||||||
|
|
||||||
import io.dapr.durabletask.TaskActivityContext;
|
import io.dapr.durabletask.TaskActivityContext;
|
||||||
import io.dapr.workflows.WorkflowActivityContext;
|
import io.dapr.workflows.WorkflowActivityContext;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for Durable Task Framework {@link TaskActivityContext}.
|
* Wrapper for Durable Task Framework {@link TaskActivityContext}.
|
||||||
*/
|
*/
|
||||||
class DefaultWorkflowActivityContext implements WorkflowActivityContext {
|
class DefaultWorkflowActivityContext implements WorkflowActivityContext {
|
||||||
private final TaskActivityContext innerContext;
|
private final TaskActivityContext innerContext;
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for WorkflowActivityContext.
|
* Constructor for WorkflowActivityContext.
|
||||||
|
|
@ -29,10 +32,36 @@ class DefaultWorkflowActivityContext implements WorkflowActivityContext {
|
||||||
* @throws IllegalArgumentException if context is null
|
* @throws IllegalArgumentException if context is null
|
||||||
*/
|
*/
|
||||||
public DefaultWorkflowActivityContext(TaskActivityContext context) throws IllegalArgumentException {
|
public DefaultWorkflowActivityContext(TaskActivityContext context) throws IllegalArgumentException {
|
||||||
|
this(context, LoggerFactory.getLogger(WorkflowActivityContext .class));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for WorkflowActivityContext.
|
||||||
|
*
|
||||||
|
* @param context TaskActivityContext
|
||||||
|
* @throws IllegalArgumentException if context is null
|
||||||
|
*/
|
||||||
|
public DefaultWorkflowActivityContext(TaskActivityContext context, Logger logger) throws IllegalArgumentException {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new IllegalArgumentException("Context cannot be null");
|
throw new IllegalArgumentException("Context cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logger == null) {
|
||||||
|
throw new IllegalArgumentException("Logger cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
this.innerContext = context;
|
this.innerContext = context;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the logger for the current activity.
|
||||||
|
*
|
||||||
|
* @return the logger for the current activity
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Logger getLogger() {
|
||||||
|
return this.logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ public class DefaultWorkflowContext implements WorkflowContext {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new IllegalArgumentException("Context cannot be null");
|
throw new IllegalArgumentException("Context cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logger == null) {
|
if (logger == null) {
|
||||||
throw new IllegalArgumentException("Logger cannot be null");
|
throw new IllegalArgumentException("Logger cannot be null");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue