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

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

Introduction

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

Prototype

public T getMetaAnnotation() 

Source Link

Document

Gets the meta annotation.

Usage

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

@SuppressWarnings("unchecked")
@Override/*ww w . j  av  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));
    }
}