public Set<State> postEvent(EventData eventData,Long stateMachineInstanceId,String correlationId){
  StateMachine stateMachine=null;
  if (stateMachineInstanceId != null) {
    stateMachine=retrieveStateMachine(stateMachineInstanceId);
  }
 else   if (correlationId != null) {
    stateMachine=retrieveStateMachineByCorrelationId(correlationId);
    stateMachineInstanceId=(stateMachine == null) ? null : stateMachine.getId();
  }
  if (stateMachine == null)   throw new UnknownStateMachine("State machine with id: " + stateMachineInstanceId + " or correlation id "+ correlationId+ " not found");
  Event event=eventsDAO.findBySMIdAndName(stateMachineInstanceId,eventData.getName());
  if (event == null)   throw new IllegalEventException("Event with stateMachineId: " + stateMachineInstanceId + ", event name: "+ eventData.getName()+ " not found");
  event.setStatus(Event.EventStatus.triggered);
  event.setEventData(eventData.getData());
  event.setEventSource(eventData.getEventSource());
  eventsDAO.updateEvent(event);
  Context context=new RAMContext(System.currentTimeMillis(),null,stateMachine);
  final Set<State> dependantStates=context.getDependantStates(eventData.getName());
  logger.debug("These states {} depend on event {}",dependantStates,eventData.getName());
  Set<State> executableStates=getExecutableStates(dependantStates,stateMachineInstanceId);
  logger.debug("These states {} are now unblocked after event {}",executableStates,eventData.getName());
  executeStates(stateMachineInstanceId,executableStates);
  return executableStates;
}

public Set < State > postEvent ( EventData eventData , Long stateMachineInstanceId , String correlationId ) { StateMachine stateMachine = null ; if ( stateMachineInstanceId != null ) { stateMachine = retrieveStateMachine ( stateMachineInstanceId ) ; } else if ( correlationId != null ) { stateMachine = retrieveStateMachineByCorrelationId ( correlationId ) ; stateMachineInstanceId = ( stateMachine == null ) ? null : stateMachine . getId ( ) ; } if ( stateMachine == null ) throw new UnknownStateMachine ( "State machine with id: " + stateMachineInstanceId + " or correlation id " + correlationId + " not found" ) ; Event event = eventsDAO . findBySMIdAndName ( stateMachineInstanceId , eventData . getName ( ) ) ; if ( event == null ) throw new IllegalEventException ( "Event with stateMachineId: " + stateMachineInstanceId + ", event name: " + eventData . getName ( ) + " not found" ) ; event . setStatus ( Event . EventStatus . triggered ) ; event . setEventData ( eventData . getData ( ) ) ; event . setEventSource ( eventData . getEventSource ( ) ) ; eventsDAO . updateEvent ( event ) ; Context context = new RAMContext ( System . currentTimeMillis ( ) , null , stateMachine ) ; final Set < State > dependantStates = context . getDependantStates ( eventData . getName ( ) ) ; logger . debug ( "These states {} depend on event {}" , dependantStates , eventData . getName ( ) ) ; Set < State > executableStates = getExecutableStates ( dependantStates , stateMachineInstanceId ) ; logger . debug ( "These states {} are now unblocked after event {}" , executableStates , eventData . getName ( ) ) ; executeStates ( stateMachineInstanceId , executableStates ) ; return executableStates ; }
retrieves the states which are dependant on this event and starts the execution of eligible states ( whose all dependencies are met ) .
