Skip to content

Add a new Java-based Flow Definition syntax [SWF-295] #157

@spring-operator

Description

@spring-operator

Keith Donald opened SWF-295 and commented

There are several opportunities for defining simpler flow definitions in native Java. This ticket should realize some of these opportunities.

Specifically:

  • Flow definitions that don't span more than one request to the server can easily be mapped to a Java method call. Declarative support for method argument binding and view selection should also be possible (perhaps using Annotations). Arjen Poutsma checked in some code into the Spring sandbox initially targeted as a Spring MVC extension that is relevant to work in this area.
  • Rod Johnson prototyped a pure native-Java alternative for defining flows that is definitely worth investigating more. The prototype code is attached to this issue.

Example Java-based flow:

@Flow("editAccount")
public class EditAccountFlow {

@PersistenceContext(type=PersistenceContextType.EXTENDED)
private EntityManager entityManager;
		
private Long id;
		
private Account account;
		
// flow startup callback (typed flow input)
public State start(Long id) {
    this.id = id;
    this.account = entityManager.find(Account.class, id);
    // return the next view
    return new AccountView();
}
		
@ViewState
public class AccountView {
    // view event handler
   @Transactional
   public State confirmEdits() {
       entityManager.joinTransaction();
       // end flow
      return new Finish();
   }
}

// flow end callback
public void end() {
    this.entityManager.close();
}

}


Affects: 1.0

Attachments:

15 votes, 19 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions