Search code examples
javaspringstatic-classesspring-statemachine

Spring State Machine - Why documentation use static classes


In Spring Statemachine the main example use static classes for @Configuration

@Configuration
@EnableStateMachine
static class Config1 extends EnumStateMachineConfigurerAdapter<States, Events> {

And Beans

@WithStateMachine
static class MyBean {

Also using @Autowired:

static class MyApp {
   @Autowired
   StateMachine<States, Events> stateMachine;

Is it old/sample documentation that can be ignored or is there a real reason/need to use static classes?


Solution

  • Is it old/sample documentation that can be ignored or is there a real reason/need to use static classes?

    Yes.

    No need for statics - check out the recent examples in the Appendices -> Quick Example - https://docs.spring.io/spring-statemachine/docs/2.1.3.RELEASE/reference/#quick-example and even in the pre-release 3.0.0M1 - https://docs.spring.io/spring-statemachine/docs/3.0.0.M1/reference/#appendices