Example usage for org.springframework.statemachine.config.configuration StateMachineHandlerApplicationListener BEAN_NAME

List of usage examples for org.springframework.statemachine.config.configuration StateMachineHandlerApplicationListener BEAN_NAME

Introduction

In this page you can find the example usage for org.springframework.statemachine.config.configuration StateMachineHandlerApplicationListener BEAN_NAME.

Prototype

String BEAN_NAME

To view the source code for org.springframework.statemachine.config.configuration StateMachineHandlerApplicationListener BEAN_NAME.

Click Source Link

Usage

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

@SuppressWarnings("unchecked")
@Override//  ww  w.  ja va 2 s .  c om
public void afterPropertiesSet() throws Exception {
    if (!(beanFactory instanceof ListableBeanFactory)) {
        log.info("Beanfactory is not instance of ListableBeanFactory, was " + beanFactory
                + " thus Disabling handlers.");
        return;
    }
    if (beanFactory.containsBean(StateMachineHandlerApplicationListener.BEAN_NAME)) {
        this.stateMachineHandlerApplicationListener = beanFactory.getBean(
                StateMachineHandlerApplicationListener.BEAN_NAME, StateMachineHandlerApplicationListener.class);
    }
    for (StateMachineHandler<? extends Annotation, S, E> handler : beanFactory
            .getBeansOfType(StateMachineHandler.class).values()) {
        Annotation annotation = handler.getAnnotation();
        Annotation metaAnnotation = handler.getMetaAnnotation();
        WithStateMachine withStateMachine = AnnotationUtils.findAnnotation(handler.getBeanClass(),
                WithStateMachine.class);
        String statemachineBeanName = withStateMachine.name();
        String key = metaAnnotation.annotationType().getName() + statemachineBeanName;
        List<CacheEntry> list = cache.get(key);
        if (list == null) {
            list = new ArrayList<>();
            cache.put(key, list);
        }
        list.add(new CacheEntry(handler, annotation, metaAnnotation));
    }
}