/** * Obtain a {@link MessagingTemplate} with its default destination set to the input channel * of the {@link IntegrationFlow} for provided {@code flowId}. * <p> Any {@link IntegrationFlow} bean (not only manually registered) can be used for this method. * <p> If {@link IntegrationFlow} doesn't start with the {@link MessageChannel}, the * {@link IllegalStateException} is thrown. * @param flowId the bean name to obtain the input channel from * @return the {@link MessagingTemplate} instance */ public MessagingTemplate messagingTemplateFor(String flowId) { return this.registry.get(flowId).getMessagingTemplate(); }
private IntegrationFlowRegistrationBuilder(IntegrationFlow integrationFlow) { this.integrationFlowRegistration = new IntegrationFlowRegistration(integrationFlow); this.integrationFlowRegistration.setBeanFactory(IntegrationFlowContext.this.beanFactory); this.integrationFlowRegistration.setIntegrationFlowContext(IntegrationFlowContext.this); }
public IntegrationFlowRegistrationBuilder id(String id) { this.integrationFlowRegistration.setId(id); return this; }
private void register(IntegrationFlowRegistrationBuilder builder) { IntegrationFlow integrationFlow = builder.integrationFlowRegistration.getIntegrationFlow(); String flowId = builder.integrationFlowRegistration.getId(); if (flowId == null) { flowId = generateBeanName(integrationFlow, null); builder.id(flowId); } IntegrationFlow theFlow = (IntegrationFlow) registerBean(integrationFlow, flowId, null); builder.integrationFlowRegistration.setIntegrationFlow(theFlow); for (Map.Entry<Object, String> entry : builder.additionalBeans.entrySet()) { registerBean(entry.getKey(), entry.getValue(), flowId); } if (builder.autoStartup) { builder.integrationFlowRegistration.start(); } this.registry.put(flowId, builder.integrationFlowRegistration); }
this.beanFactory.getBean(flowRegistration.getId() + BeanFactoryHandler.class.getName() + "#0", BeanFactoryHandler.class); assertSame(additionalBean, bean); assertSame(this.beanFactory, bean.beanFactory); MessagingTemplate messagingTemplate = flowRegistration.getMessagingTemplate(); messagingTemplate.setReceiveTimeout(10000); flowRegistration.destroy(); assertFalse(this.beanFactory.containsBean(flowRegistration.getId())); assertFalse(this.beanFactory.containsBean(flowRegistration.getId() + ".input")); assertFalse(this.beanFactory.containsBean(flowRegistration.getId() + BeanFactoryHandler.class.getName() + "#0"));
/** * Obtain a {@link MessagingTemplate} with its default destination set to the input channel * of the {@link IntegrationFlow}. * <p> Any {@link IntegrationFlow} bean (not only manually registered) can be used for this method. * <p> If {@link IntegrationFlow} doesn't start with the {@link MessageChannel}, the * {@link IllegalStateException} is thrown. * @return the {@link MessagingTemplate} instance */ public MessagingTemplate getMessagingTemplate() { if (this.messagingTemplate == null) { synchronized (this) { if (this.messagingTemplate == null) { this.messagingTemplate = new MessagingTemplate(getInputChannel()) { @Override public Message<?> receive() { return receiveAndConvert(Message.class); } @Override public <T> T receiveAndConvert(Class<T> targetClass) { throw new UnsupportedOperationException("The 'receive()/receiveAndConvert()' " + "isn't supported on the 'IntegrationFlow' input channel."); } }; this.messagingTemplate.setBeanFactory(this.beanFactory); } } } return this.messagingTemplate; }
private void register(IntegrationFlowRegistrationBuilder builder) { IntegrationFlow integrationFlow = builder.integrationFlowRegistration.getIntegrationFlow(); String flowId = builder.integrationFlowRegistration.getId(); if (flowId == null) { flowId = generateBeanName(integrationFlow, null); builder.id(flowId); } IntegrationFlow theFlow = (IntegrationFlow) registerBean(integrationFlow, flowId, null); builder.integrationFlowRegistration.setIntegrationFlow(theFlow); for (Map.Entry<Object, String> entry : builder.additionalBeans.entrySet()) { registerBean(entry.getKey(), entry.getValue(), flowId); } if (builder.autoStartup) { builder.integrationFlowRegistration.start(); } this.registry.put(flowId, builder.integrationFlowRegistration); }
/** * Obtain a {@link MessagingTemplate} with its default destination set to the input channel * of the {@link IntegrationFlow}. * <p> Any {@link IntegrationFlow} bean (not only manually registered) can be used for this method. * <p> If {@link IntegrationFlow} doesn't start with the {@link MessageChannel}, the * {@link IllegalStateException} is thrown. * @return the {@link MessagingTemplate} instance */ public MessagingTemplate getMessagingTemplate() { if (this.messagingTemplate == null) { synchronized (this) { if (this.messagingTemplate == null) { this.messagingTemplate = new MessagingTemplate(getInputChannel()) { @Override public Message<?> receive() { return receiveAndConvert(Message.class); } @Override public <T> T receiveAndConvert(Class<T> targetClass) { throw new UnsupportedOperationException("The 'receive()/receiveAndConvert()' " + "isn't supported on the 'IntegrationFlow' input channel."); } }; this.messagingTemplate.setBeanFactory(this.beanFactory); } } } return this.messagingTemplate; }
private IntegrationFlowRegistrationBuilder(IntegrationFlow integrationFlow) { this.integrationFlowRegistration = new IntegrationFlowRegistration(integrationFlow); this.integrationFlowRegistration.setBeanFactory(IntegrationFlowContext.this.beanFactory); this.integrationFlowRegistration.setIntegrationFlowContext(IntegrationFlowContext.this); }
/** * Obtain a {@link MessagingTemplate} with its default destination set to the input channel * of the {@link IntegrationFlow} for provided {@code flowId}. * <p> Any {@link IntegrationFlow} bean (not only manually registered) can be used for this method. * <p> If {@link IntegrationFlow} doesn't start with the {@link MessageChannel}, the * {@link IllegalStateException} is thrown. * @param flowId the bean name to obtain the input channel from * @return the {@link MessagingTemplate} instance */ public MessagingTemplate messagingTemplateFor(String flowId) { return this.registry.get(flowId).getMessagingTemplate(); }
public IntegrationFlowRegistrationBuilder id(String id) { this.integrationFlowRegistration.setId(id); return this; }