Example usage for org.springframework.integration.dsl.context IntegrationFlowContext registration

List of usage examples for org.springframework.integration.dsl.context IntegrationFlowContext registration

Introduction

In this page you can find the example usage for org.springframework.integration.dsl.context IntegrationFlowContext registration.

Prototype

IntegrationFlowRegistrationBuilder registration(IntegrationFlow integrationFlow);

Source Link

Document

Associate provided IntegrationFlow with an IntegrationFlowRegistrationBuilder for additional options and farther registration in the application context.

Usage

From source file:org.springframework.batch.integration.partition.RemotePartitioningWorkerStepBuilder.java

/**
 * Create an {@link IntegrationFlow} with a {@link StepExecutionRequestHandler}
 * configured as a service activator listening to the input channel and replying
 * on the output channel.//  w  w  w  .  j a va 2s . c  o m
 */
private void configureWorkerIntegrationFlow() {
    Assert.notNull(this.inputChannel, "An InputChannel must be provided");
    Assert.notNull(this.jobExplorer, "A JobExplorer must be provided");

    if (this.stepLocator == null) {
        BeanFactoryStepLocator beanFactoryStepLocator = new BeanFactoryStepLocator();
        beanFactoryStepLocator.setBeanFactory(this.beanFactory);
        this.stepLocator = beanFactoryStepLocator;
    }
    if (this.outputChannel == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("The output channel is set to a NullChannel. "
                    + "The master step must poll the job repository for workers status.");
        }
        this.outputChannel = new NullChannel();
    }

    StepExecutionRequestHandler stepExecutionRequestHandler = new StepExecutionRequestHandler();
    stepExecutionRequestHandler.setJobExplorer(this.jobExplorer);
    stepExecutionRequestHandler.setStepLocator(this.stepLocator);

    StandardIntegrationFlow standardIntegrationFlow = IntegrationFlows.from(this.inputChannel)
            .handle(stepExecutionRequestHandler, SERVICE_ACTIVATOR_METHOD_NAME).channel(this.outputChannel)
            .get();
    IntegrationFlowContext integrationFlowContext = this.beanFactory.getBean(IntegrationFlowContext.class);
    integrationFlowContext.registration(standardIntegrationFlow).autoStartup(false).register();
}