Example usage for org.springframework.statemachine.processor StateMachineHandler getAnnotation

List of usage examples for org.springframework.statemachine.processor StateMachineHandler getAnnotation

Introduction

In this page you can find the example usage for org.springframework.statemachine.processor StateMachineHandler getAnnotation.

Prototype

public Annotation getAnnotation() 

Source Link

Document

Gets the annotation.

Usage

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

@SuppressWarnings("unchecked")
@Override//from   ww  w .  j  a  v a  2  s  . co  m
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));
    }
}