AnsweredAssumed Answered

Help understanding @BusinessProcessScoped beans

Question asked by pkonyves on Jun 6, 2013
Latest reply on Jun 10, 2013 by jbarrez
I came across the @BusinessProcessScoped bean section in the activiti online documentation, but I don't know how I or Actviti knows which BusinessProcessScoped bean to inject.

I assume if I create such a bean with the @Named annotation, I can reference it from the process definition. Then Activiti will know which BusinessProcessScoped bean belongs to which process instance.

However what if I want to @Inject this bean into other CDI beans e.g. a @RequestScope bean in  a JSF application. e.g.:


@BusinessProcessScoped
public class MyProcessBean implements java.io.Serializable {
  // this bean persists its state throughout the whole process instance
  private String lastChangingUser;

  //getters&setters
}

@RequestScoped
public class MyTaskController {

  @Inject MyProcessBean myProcessBean;

  public void updateLastChangingUser() {
   Principal principal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
   myProcessBean.setLastChangingUser( principal.getName() );
  }
}

How will Activiti know, how can I tell it for which process instance it should inject the MyProcessBean?
Thanks, Pal

Outcomes