Class DBOSAspect

java.lang.Object
dev.dbos.transact.spring.DBOSAspect

public class DBOSAspect extends Object
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

    Constructors
    Constructor
    Description
    DBOSAspect(dev.dbos.transact.DBOS dbos, org.springframework.context.ApplicationContext applicationContext)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    aroundStep(org.aspectj.lang.ProceedingJoinPoint pjp, dev.dbos.transact.workflow.Step step)
    Intercepts @Step annotated methods.
    aroundWorkflow(org.aspectj.lang.ProceedingJoinPoint pjp, dev.dbos.transact.workflow.Workflow workflow)
    Intercepts @Workflow annotated methods and routes them through DBOS for durable execution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 @Workflow annotated methods and routes them through DBOS for durable execution. The workflow is looked up by the target's class name (or its WorkflowClassName alias) and the method name (or the annotation's name attribute).
      Throws:
      Throwable
    • aroundStep

      public Object aroundStep(org.aspectj.lang.ProceedingJoinPoint pjp, dev.dbos.transact.workflow.Step step) throws Throwable
      Intercepts @Step annotated 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