Search in sources :

Example 21 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class AbstractMethodAnnotationPostProcessor method createEndpoint.

protected AbstractEndpoint createEndpoint(MessageHandler handler, Method method, List<Annotation> annotations) {
    AbstractEndpoint endpoint = null;
    String inputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, getInputChannelAttribute(), String.class);
    if (StringUtils.hasText(inputChannelName)) {
        MessageChannel inputChannel;
        try {
            inputChannel = this.channelResolver.resolveDestination(inputChannelName);
        } catch (DestinationResolutionException e) {
            if (e.getCause() instanceof NoSuchBeanDefinitionException) {
                inputChannel = new DirectChannel();
                this.beanFactory.registerSingleton(inputChannelName, inputChannel);
                inputChannel = (MessageChannel) this.beanFactory.initializeBean(inputChannel, inputChannelName);
            } else {
                throw e;
            }
        }
        Assert.notNull(inputChannel, "failed to resolve inputChannel '" + inputChannelName + "'");
        endpoint = doCreateEndpoint(handler, inputChannel, annotations);
    }
    return endpoint;
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) MessageChannel(org.springframework.messaging.MessageChannel) DirectChannel(org.springframework.integration.channel.DirectChannel) DestinationResolutionException(org.springframework.messaging.core.DestinationResolutionException) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException)

Example 22 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomRequestCallback.

@Test
public void simpleGatewayWithCustomRequestCallback() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomRequestCallback", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
    assertEquals(callback, accessor.getPropertyValue("requestCallback"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) WebServiceMessageCallback(org.springframework.ws.client.core.WebServiceMessageCallback) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 23 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomFaultMessageResolver.

@Test
public void simpleGatewayWithCustomFaultMessageResolver() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomFaultMessageResolver", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
    FaultMessageResolver resolver = (FaultMessageResolver) context.getBean("faultMessageResolver");
    assertEquals(resolver, accessor.getPropertyValue("faultMessageResolver"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) FaultMessageResolver(org.springframework.ws.client.core.FaultMessageResolver) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 24 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithDestinationProvider.

@Test
public void simpleGatewayWithDestinationProvider() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithDestinationProvider", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    StubDestinationProvider stubProvider = (StubDestinationProvider) context.getBean("destinationProvider");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    assertEquals("Wrong DestinationProvider", stubProvider, accessor.getPropertyValue("destinationProvider"));
    assertNull(accessor.getPropertyValue("uri"));
    Object destinationProviderObject = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate")).getPropertyValue("destinationProvider");
    assertEquals("Wrong DestinationProvider", stubProvider, destinationProviderObject);
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 25 with AbstractEndpoint

use of org.springframework.integration.endpoint.AbstractEndpoint in project spring-integration by spring-projects.

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithIgnoreEmptyResponses.

@Test
public void simpleGatewayWithIgnoreEmptyResponses() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithIgnoreEmptyResponsesFalseAndRequiresReplyTrue", AbstractEndpoint.class);
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    assertEquals(Boolean.FALSE, accessor.getPropertyValue("ignoreEmptyResponses"));
    assertEquals(Boolean.TRUE, accessor.getPropertyValue("requiresReply"));
    assertEquals(Boolean.FALSE, accessor.getPropertyValue("extractPayload"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Aggregations

AbstractEndpoint (org.springframework.integration.endpoint.AbstractEndpoint)34 Test (org.junit.Test)28 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)19 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)7 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)6 MessageHandler (org.springframework.messaging.MessageHandler)5 Marshaller (org.springframework.oxm.Marshaller)4 Unmarshaller (org.springframework.oxm.Unmarshaller)4 WebServiceMessageFactory (org.springframework.ws.WebServiceMessageFactory)4 PollingConsumer (org.springframework.integration.endpoint.PollingConsumer)3 WebServiceMessageCallback (org.springframework.ws.client.core.WebServiceMessageCallback)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)2 DirectChannel (org.springframework.integration.channel.DirectChannel)2 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)2 ReactiveStreamsConsumer (org.springframework.integration.endpoint.ReactiveStreamsConsumer)2 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)2 PollableChannel (org.springframework.messaging.PollableChannel)2 SubscribableChannel (org.springframework.messaging.SubscribableChannel)2 SourceExtractor (org.springframework.ws.client.core.SourceExtractor)2