Search in sources :

Example 1 with FlowDiscoveryCDIExtension

use of com.sun.faces.flow.FlowDiscoveryCDIExtension in project mojarra by eclipse-ee4j.

the class JavaFlowLoaderHelper method loadFlows.

synchronized void loadFlows(FacesContext context, FlowHandler flowHandler) throws IOException {
    BeanManager beanManager = getCdiBeanManager(context);
    FlowDiscoveryCDIExtension flowDiscoveryCDIExtension = CdiUtils.getBeanReference(beanManager, FlowDiscoveryCDIExtension.class);
    if (flowDiscoveryCDIExtension == null) {
        if (LOGGER.isLoggable(SEVERE)) {
            LOGGER.log(SEVERE, "Unable to obtain {0} from CDI implementation.  Flows described with {1} are unavailable.", new String[] { FlowDiscoveryCDIExtension.class.getName(), FlowDefinition.class.getName() });
        }
        return;
    }
    List<Producer<Flow>> flowProducers = flowDiscoveryCDIExtension.getFlowProducers();
    if (!flowProducers.isEmpty()) {
        enableClientWindowModeIfNecessary(context);
    }
    WebConfiguration config = WebConfiguration.getInstance();
    for (Producer<Flow> flowProducer : flowProducers) {
        Flow toAdd = flowProducer.produce(beanManager.<Flow>createCreationalContext(null));
        if (toAdd == null) {
            LOGGER.log(SEVERE, "Flow producer method {0}() returned null.  Ignoring.", flowProducer.toString());
        } else {
            flowHandler.addFlow(context, toAdd);
            config.setHasFlows(true);
        }
    }
}
Also used : Producer(jakarta.enterprise.inject.spi.Producer) FlowDiscoveryCDIExtension(com.sun.faces.flow.FlowDiscoveryCDIExtension) Util.getCdiBeanManager(com.sun.faces.util.Util.getCdiBeanManager) BeanManager(jakarta.enterprise.inject.spi.BeanManager) FlowDefinition(jakarta.faces.flow.builder.FlowDefinition) WebConfiguration(com.sun.faces.config.WebConfiguration) Flow(jakarta.faces.flow.Flow)

Aggregations

WebConfiguration (com.sun.faces.config.WebConfiguration)1 FlowDiscoveryCDIExtension (com.sun.faces.flow.FlowDiscoveryCDIExtension)1 Util.getCdiBeanManager (com.sun.faces.util.Util.getCdiBeanManager)1 BeanManager (jakarta.enterprise.inject.spi.BeanManager)1 Producer (jakarta.enterprise.inject.spi.Producer)1 Flow (jakarta.faces.flow.Flow)1 FlowDefinition (jakarta.faces.flow.builder.FlowDefinition)1