title: How to restore state machine from context builded in runtime?
body: <p>I have a state machine</p>
  
  <pre class="lang-java prettyprint-override"><code>@EnableStateMachine
  @Configuration
  public class StateMachineConfiguration extends EnumStateMachineConfigurerAdapter&lt;Status, Event&gt; {
      @Override
      public void configure(StateMachineStateConfigurer&lt;Status, Event&gt; states) throws Exception {
          states.withStates()
                  .initial(Status.DRAFT)
                  .states(EnumSet.allOf(Status.class));
      }
  
      @Override
      public void configure(StateMachineTransitionConfigurer&lt;Status, Event&gt; transitions) throws Exception {
          transitions
  
                  .withExternal()
                  .target(Status.INVITATION).source(Status.DRAFT)
                  .event(Event.INVITED)
                  .guard(new Guard())
                  .action(new ActionInvited())
                  .and()
  
                  .withExternal()
                  .target(Status.DECLINED).source(Status.INVITATION)
                  .event(Event.DECLINED)
                  .action(new ActionDeclined());
      }
  
      @Override
      public void configure(StateMachineConfigurationConfigurer&lt;Status, Event&gt; config) throws Exception {
          config.withConfiguration().autoStartup(true);
      }
  }
  </code></pre>
  
  <p>and I have a model, for example <strong>Order</strong>.
  Model persists in DB. I extract model from DB, now my model has a status <code>Order.status == INVITATION</code>. I want to continue processing model with statemachine, but instance of statemachine will starts processing with initial state <strong>DRAFT</strong> but I needs continue processing from status <strong>INVITATION</strong>. In other words I want to execute</p>
  
  <pre class="lang-java prettyprint-override"><code>stateMachine.sendEvent(MessageBuilder
    .withPayload(Event.DECLINED)
    .setHeader("orderId", order.id)
    .build()
  )
  </code></pre>
  
  <p>and execute action <code>ActionDeclined()</code>. I don't want to persist a context of state machine in DB. I want to setting a state of stateMachine to state of my Model in runtime. How can I do that in right way? Using DefaultStateContext constructor or have an other, more beautiful way?</p>