Search in sources :

Example 31 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomSourceExtractorAndMessageFactory.

@Test
public void simpleGatewayWithCustomSourceExtractorAndMessageFactory() {
    AbstractEndpoint endpoint = context.getBean("gatewayWithCustomSourceExtractorAndMessageFactory", AbstractEndpoint.class);
    SourceExtractor<?> sourceExtractor = (SourceExtractor<?>) context.getBean("sourceExtractor");
    assertEquals(EventDrivenConsumer.class, endpoint.getClass());
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
    DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
    assertEquals(sourceExtractor, accessor.getPropertyValue("sourceExtractor"));
    accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
    WebServiceMessageFactory factory = (WebServiceMessageFactory) context.getBean("messageFactory");
    assertEquals(factory, accessor.getPropertyValue("messageFactory"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) WebServiceMessageFactory(org.springframework.ws.WebServiceMessageFactory) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) SourceExtractor(org.springframework.ws.client.core.SourceExtractor) Test(org.junit.Test)

Example 32 with AbstractEndpoint

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

the class WebServiceOutboundGatewayParserTests method simpleGatewayWithOrder.

@Test
public void simpleGatewayWithOrder() {
    AbstractEndpoint endpoint = this.context.getBean("gatewayWithOrderAndAutoStartupFalse", AbstractEndpoint.class);
    Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
    assertEquals(99, new DirectFieldAccessor(gateway).getPropertyValue("order"));
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 33 with AbstractEndpoint

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

the class IntegrationMBeanExporter method registerEndpoints.

private void registerEndpoints() {
    String[] names = this.applicationContext.getBeanNamesForType(AbstractEndpoint.class);
    Set<String> endpointNames = new HashSet<>();
    for (String name : names) {
        if (!this.beansByEndpointName.values().contains(name)) {
            AbstractEndpoint endpoint = this.applicationContext.getBean(name, AbstractEndpoint.class);
            String beanKey;
            name = endpoint.getComponentName();
            String source;
            if (name.startsWith("_org.springframework.integration")) {
                name = getInternalComponentName(name);
                source = "internal";
            } else {
                name = endpoint.getComponentName();
                source = "endpoint";
            }
            if (!matches(this.componentNamePatterns, name)) {
                continue;
            }
            if (endpointNames.contains(name)) {
                int count = 0;
                String unique = name + "#" + count;
                while (endpointNames.contains(unique)) {
                    unique = name + "#" + (++count);
                }
                name = unique;
            }
            endpointNames.add(name);
            beanKey = getEndpointBeanKey(endpoint, name, source);
            ObjectName objectName = registerBeanInstance(new ManagedEndpoint(endpoint), beanKey);
            if (logger.isInfoEnabled()) {
                logger.info("Registered endpoint without MessageSource: " + objectName);
            }
        }
    }
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) HashSet(java.util.HashSet) ObjectName(javax.management.ObjectName)

Example 34 with AbstractEndpoint

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

the class MongoDbOutboundChannelAdapterParserTests method testInt3024PollerAndRequestHandlerAdviceChain.

@Test
public void testInt3024PollerAndRequestHandlerAdviceChain() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("outbound-adapter-parser-config.xml", this.getClass());
    AbstractEndpoint endpoint = context.getBean("pollableAdapter", AbstractEndpoint.class);
    assertThat(endpoint, Matchers.instanceOf(PollingConsumer.class));
    MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
    assertTrue(AopUtils.isAopProxy(handler));
    List<?> advisors = TestUtils.getPropertyValue(handler, "h.advised.advisors", List.class);
    assertThat(TestUtils.getPropertyValue(advisors.get(0), "advice"), Matchers.instanceOf(RequestHandlerRetryAdvice.class));
    context.close();
}
Also used : AbstractEndpoint(org.springframework.integration.endpoint.AbstractEndpoint) PollingConsumer(org.springframework.integration.endpoint.PollingConsumer) RequestHandlerRetryAdvice(org.springframework.integration.handler.advice.RequestHandlerRetryAdvice) MessageHandler(org.springframework.messaging.MessageHandler) MongoDbStoringMessageHandler(org.springframework.integration.mongodb.outbound.MongoDbStoringMessageHandler) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) 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