Package dev.dbos.transact.spring
Class DBOSAspect
java.lang.Object
dev.dbos.transact.spring.DBOSAspect
Spring AOP aspect that intercepts
@Workflow and @Step annotated
methods on Spring-managed beans and delegates execution to DBOS.
When a @Workflow method is called through a Spring proxy, this aspect intercepts the
call and routes it through DBOS.invokeWorkflow() so the execution is durably recorded and
recoverable. Step calls made with @Step inside a workflow body are similarly intercepted
and executed as DBOS steps.
Important: Spring AOP only intercepts calls made through the Spring proxy.
Calls to this.someStep() inside a workflow method body bypass the proxy and are therefore
not intercepted. To ensure step and child-workflow calls are durable, inject a self-reference via
@Autowired and call through it:
@Service
public class MyService {
@Autowired MyService self;
@Workflow
public String myWorkflow() {
return self.myStep(); // intercepted by DBOSAspect
}
@Step
public String myStep() { ... }
}
This bean is registered by DBOSAutoConfiguration; declare your own @Bean
DBOSAspect to replace it.
-
Constructor Summary
ConstructorsConstructorDescriptionDBOSAspect(dev.dbos.transact.DBOS dbos, org.springframework.context.ApplicationContext applicationContext) -
Method Summary
Modifier and TypeMethodDescriptionaroundStep(org.aspectj.lang.ProceedingJoinPoint pjp, dev.dbos.transact.workflow.Step step) Intercepts@Stepannotated methods.aroundWorkflow(org.aspectj.lang.ProceedingJoinPoint pjp, dev.dbos.transact.workflow.Workflow workflow) Intercepts@Workflowannotated methods and routes them through DBOS for durable execution.
-
Constructor Details
-
DBOSAspect
public DBOSAspect(dev.dbos.transact.DBOS dbos, org.springframework.context.ApplicationContext applicationContext)
-
-
Method Details
-
aroundWorkflow
public Object aroundWorkflow(org.aspectj.lang.ProceedingJoinPoint pjp, dev.dbos.transact.workflow.Workflow workflow) throws Throwable Intercepts@Workflowannotated methods and routes them through DBOS for durable execution. The workflow is looked up by the target's class name (or itsWorkflowClassNamealias) and the method name (or the annotation'snameattribute).- Throws:
Throwable
-
aroundStep
public Object aroundStep(org.aspectj.lang.ProceedingJoinPoint pjp, dev.dbos.transact.workflow.Step step) throws Throwable Intercepts@Stepannotated methods. When called inside a workflow context the execution is delegated to DBOS so it is recorded as a durable step. When called outside a workflow context the method is executed directly without DBOS involvement.- Throws:
Throwable
-