Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
import io.dapr.workflows.WorkflowActivity;
import io.dapr.workflows.runtime.WorkflowRuntime;
import io.dapr.workflows.runtime.WorkflowRuntimeBuilder;
import io.micrometer.common.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.Map;

Expand Down Expand Up @@ -54,8 +56,18 @@ private void registerWorkflowsAndActivities(ApplicationContext applicationContex
Map<String, WorkflowActivity> workflowActivitiesBeans = applicationContext.getBeansOfType(WorkflowActivity.class);

for (WorkflowActivity activity : workflowActivitiesBeans.values()) {
LOGGER.info("Dapr Workflow Activity: '{}' registered", activity.getClass().getName());
// Get the @Component annotation
Component componentAnnotation = activity.getClass().getAnnotation(Component.class);
activity.getName()
if (componentAnnotation != null) {
var componentValue = componentAnnotation.value();
if (StringUtils.isNotEmpty(componentValue)) {
LOGGER.info("Dapr Workflow Activity: '{}' with name '{}' registered", activity.getClass().getName(), componentValue);
workflowRuntimeBuilder.registerActivity(componentValue, activity);
}
}

LOGGER.info("Dapr Workflow Activity: '{}' registered", activity.getClass().getName());
workflowRuntimeBuilder.registerActivity(activity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.concurrent.TimeUnit;


public class CleanUpActivity implements WorkflowActivity {
@Override
public Object run(WorkflowActivityContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ public interface WorkflowActivity {
* @return any serializable value to be returned to the calling orchestrator.
*/
Object run(WorkflowActivityContext ctx);

default String getName() {
return this.getClass().getCanonicalName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ public <T extends Workflow> WorkflowRuntimeBuilder registerWorkflow(Class<T> cla
this.builder.addOrchestration(new WorkflowClassWrapper<>(clazz));
this.workflowSet.add(clazz.getCanonicalName());
this.workflows.add(clazz.getSimpleName());

this.logger.info("Registered Workflow: {}", clazz.getSimpleName());

return this;
}

/**
* Registers a Workflow object.
*
* @param <T> any Workflow type
* @param clazz the class being registered
* @return the WorkflowRuntimeBuilder
*/
public <T extends Workflow> WorkflowRuntimeBuilder registerWorkflow(String name, Class<T> clazz) {
this.builder.addOrchestration(new WorkflowClassWrapper<>(clazz));
this.workflowSet.add(name);
this.workflows.add(name);

this.logger.info("Registered Workflow: {}", clazz.getSimpleName());

Expand Down
Loading