Example usage for org.springframework.integration.gateway GatewayProxyFactoryBean getObject

List of usage examples for org.springframework.integration.gateway GatewayProxyFactoryBean getObject

Introduction

In this page you can find the example usage for org.springframework.integration.gateway GatewayProxyFactoryBean getObject.

Prototype

@Override
    public Object getObject() 

Source Link

Usage

From source file:org.acme.echo.module.ModuleGatewayRequestExchanger.java

@Override
public void afterPropertiesSet() throws Exception {
    GatewayProxyFactoryBean gatewayFactory = new GatewayProxyFactoryBean();
    String requestChannel = "echoStartChannel"; // we might want to get from some module.properties file
    String replyChannel = "echoEndChannel";
    gatewayFactory.setDefaultRequestChannel(moduleContext.getBean(requestChannel, MessageChannel.class));
    gatewayFactory.setDefaultReplyChannel(moduleContext.getBean(replyChannel, MessageChannel.class));
    gatewayFactory.afterPropertiesSet();
    requestReplyExchanger = (RequestReplyExchanger) gatewayFactory.getObject();
}

From source file:org.springframework.integration.handler.AsyncHandlerTests.java

@Test
public void testGateway() throws Exception {
    this.whichTest = 0;
    GatewayProxyFactoryBean gpfb = new GatewayProxyFactoryBean(Foo.class);
    gpfb.setBeanFactory(mock(BeanFactory.class));
    DirectChannel input = new DirectChannel();
    gpfb.setDefaultRequestChannel(input);
    gpfb.setDefaultReplyTimeout(10000L);
    gpfb.afterPropertiesSet();/*ww  w. j  a  va  2  s  .c om*/
    Foo foo = (Foo) gpfb.getObject();
    this.handler.setOutputChannel(null);
    EventDrivenConsumer consumer = new EventDrivenConsumer(input, this.handler);
    consumer.afterPropertiesSet();
    consumer.start();
    this.latch.countDown();
    String result = foo.exchange("foo");
    assertEquals("reply", result);
}

From source file:org.springframework.integration.handler.AsyncHandlerTests.java

@Test
public void testGatewayWithException() throws Exception {
    this.whichTest = 0;
    GatewayProxyFactoryBean gpfb = new GatewayProxyFactoryBean(Foo.class);
    gpfb.setBeanFactory(mock(BeanFactory.class));
    DirectChannel input = new DirectChannel();
    gpfb.setDefaultRequestChannel(input);
    gpfb.setDefaultReplyTimeout(10000L);
    gpfb.afterPropertiesSet();//  w w  w  . j a  v a2 s .c  o m
    Foo foo = (Foo) gpfb.getObject();
    this.handler.setOutputChannel(null);
    EventDrivenConsumer consumer = new EventDrivenConsumer(input, this.handler);
    consumer.afterPropertiesSet();
    consumer.start();
    this.latch.countDown();
    try {
        foo.exchange("foo");
    } catch (MessagingException e) {
        assertThat(e.getClass().getSimpleName(), equalTo("RuntimeException"));
        assertThat(e.getMessage(), equalTo("foo"));
    }
}

From source file:org.springframework.integration.handler.MethodInvokingMessageProcessorTests.java

@Test
public void gatewayTest() throws Exception {
    GatewayProxyFactoryBean gwFactoryBean = new GatewayProxyFactoryBean();
    gwFactoryBean.afterPropertiesSet();/* ww w.ja v a2s .c o m*/
    Object target = gwFactoryBean.getObject();
    // just instantiate a helper with a simple target; we're going to invoke getTargetClass with reflection
    MessagingMethodInvokerHelper helper = new MessagingMethodInvokerHelper(new TestErrorService(), "error",
            true);

    Method method = MessagingMethodInvokerHelper.class.getDeclaredMethod("getTargetClass", Object.class);
    method.setAccessible(true);
    Object result = method.invoke(helper, target);
    assertSame(RequestReplyExchanger.class, result);
}