Example usage for org.springframework.statemachine StateContext getSource

List of usage examples for org.springframework.statemachine StateContext getSource

Introduction

In this page you can find the example usage for org.springframework.statemachine StateContext getSource.

Prototype

State<S, E> getSource();

Source Link

Document

Gets the source state of this context.

Usage

From source file:org.springframework.statemachine.processor.StateMachineHandlerCallHelper.java

public void callOnStateChanged(String stateMachineId, StateContext<S, E> stateContext) {
    List<StateMachineHandler<? extends Annotation, S, E>> handlersList = new ArrayList<StateMachineHandler<? extends Annotation, S, E>>();
    String cacheKey = OnStateChanged.class.getName() + stateMachineId;
    List<CacheEntry> list = getCacheEntries(cacheKey);
    if (list == null) {
        return;/*w  w  w. j  a v a2 s .co m*/
    }
    for (CacheEntry entry : list) {
        if (annotationHandlerSourceTargetMatch(
                (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "source"),
                (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "target"), entry.annotation,
                stateContext.getSource(), stateContext.getTarget())) {
            handlersList.add(entry.handler);
        }
    }
    getStateMachineHandlerResults(handlersList, stateContext);
}

From source file:org.springframework.statemachine.processor.StateMachineHandlerCallHelper.java

public void callOnStateEntry(String stateMachineId, StateContext<S, E> stateContext) {
    List<StateMachineHandler<? extends Annotation, S, E>> handlersList = new ArrayList<StateMachineHandler<? extends Annotation, S, E>>();
    String cacheKey = OnStateEntry.class.getName() + stateMachineId;
    List<CacheEntry> list = getCacheEntries(cacheKey);
    if (list == null) {
        return;//from ww  w .ja  v a2  s  .co  m
    }
    for (CacheEntry entry : list) {
        if (annotationHandlerSourceTargetMatch(
                (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "source"),
                (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "target"), entry.annotation,
                stateContext.getSource(), stateContext.getTarget())) {
            handlersList.add(entry.handler);
        }
    }
    getStateMachineHandlerResults(handlersList, stateContext);
}

From source file:org.springframework.statemachine.processor.StateMachineHandlerCallHelper.java

public void callOnStateExit(String stateMachineId, StateContext<S, E> stateContext) {
    List<StateMachineHandler<? extends Annotation, S, E>> handlersList = new ArrayList<StateMachineHandler<? extends Annotation, S, E>>();
    String cacheKey = OnStateExit.class.getName() + stateMachineId;
    List<CacheEntry> list = getCacheEntries(cacheKey);
    if (list == null) {
        return;/*from ww w.  j  a v  a2  s .  com*/
    }
    for (CacheEntry entry : list) {
        if (annotationHandlerSourceTargetMatch(
                (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "source"),
                (String[]) AnnotationUtils.getValue(entry.metaAnnotation, "target"), entry.annotation,
                stateContext.getSource(), stateContext.getTarget())) {
            handlersList.add(entry.handler);
        }
    }
    getStateMachineHandlerResults(handlersList, stateContext);
}

From source file:org.springframework.statemachine.support.StateMachineObjectSupport.java

protected void notifyStateChanged(StateContext<S, E> stateContext) {
    try {//from   ww  w . jav  a  2 s . c o m
        stateMachineHandlerCallHelper.callOnStateChanged(getBeanName(), stateContext);
        stateListener.stateChanged(stateContext.getSource(), stateContext.getTarget());
        stateListener.stateContext(stateContext);
        if (contextEventsEnabled) {
            StateMachineEventPublisher eventPublisher = getStateMachineEventPublisher();
            if (eventPublisher != null) {
                eventPublisher.publishStateChanged(this, stateContext.getSource(), stateContext.getTarget());
            }
        }
    } catch (Throwable e) {
        log.warn("Error during notifyStateChanged", e);
    }
}

From source file:org.springframework.statemachine.support.StateMachineObjectSupport.java

protected void notifyStateExited(StateContext<S, E> stateContext) {
    try {//from  ww w  .j  a v  a2s.  com
        stateMachineHandlerCallHelper.callOnStateExit(getBeanName(), stateContext);
        stateListener.stateExited(stateContext.getSource());
        stateListener.stateContext(stateContext);
        if (contextEventsEnabled) {
            StateMachineEventPublisher eventPublisher = getStateMachineEventPublisher();
            if (eventPublisher != null) {
                eventPublisher.publishStateExited(this, stateContext.getSource());
            }
        }
    } catch (Throwable e) {
        log.warn("Error during notifyStateExited", e);
    }
}