Example usage for org.springframework.remoting.httpinvoker HttpInvokerProxyFactoryBean HttpInvokerProxyFactoryBean

List of usage examples for org.springframework.remoting.httpinvoker HttpInvokerProxyFactoryBean HttpInvokerProxyFactoryBean

Introduction

In this page you can find the example usage for org.springframework.remoting.httpinvoker HttpInvokerProxyFactoryBean HttpInvokerProxyFactoryBean.

Prototype

HttpInvokerProxyFactoryBean

Source Link

Usage

From source file:org.demo.demo.config.ApplicationConfig.java

@Bean
public HttpInvokerProxyFactoryBean myService() {
    HttpInvokerProxyFactoryBean factory = new HttpInvokerProxyFactoryBean();
    factory.setServiceUrl("/svc/dummy");
    factory.setServiceInterface(MyService.class);
    return factory;
}

From source file:almira.sample.client.ListCatapults.java

static HttpInvokerProxyFactoryBean getFactoryBeanInstance(String serviceUrl) {
    HttpInvokerProxyFactoryBean fb = new HttpInvokerProxyFactoryBean();
    fb.setServiceInterface(ObjectQueryService.class);
    fb.setServiceUrl(serviceUrl);/*from w w  w.  j  ava  2s  . com*/
    fb.afterPropertiesSet();
    return fb;
}

From source file:com.ish.client.ClientAppConfig.java

@Bean
public HttpInvokerProxyFactoryBean httpInvokerProxy() throws Exception {
    HttpInvokerProxyFactoryBean proxyFactory = new HttpInvokerProxyFactoryBean();
    proxyFactory.setServiceUrl("https://localhost:8443/rpc/account");
    proxyFactory.setServiceInterface(AccountService.class);
    proxyFactory.setHttpInvokerRequestExecutor(http2InvokerRequestExecutor());
    return proxyFactory;
}

From source file:org.apache.servicemix.http.endpoints.SerializedMarshalerTest.java

public void testUsingSpringHttpRemoting() throws Exception {
    final Person person = new PersonImpl("Hunter", "Thompson", 67);

    // Create a consumer endpoint
    HttpConsumerEndpoint ep = new HttpConsumerEndpoint();
    ep.setService(new QName("urn:HttpConsumer", "HttpConsumer"));
    ep.setEndpoint("HttpConsumer");
    ep.setLocationURI("http://localhost:8192/service/");
    ep.setTargetService(new QName("urn:HttpInvoker", "Endpoint"));

    // Configure the SerializedMarshaler and specifiy it on the endpoint
    SerializedMarshaler marshaler = new SerializedMarshaler();
    marshaler.setDefaultMep(MessageExchangeSupport.IN_OUT);
    ep.setMarshaler(marshaler);//from  w w  w  . j av a 2  s  .  c om

    // Add the endpoint to the component and activate it
    HttpComponent component = new HttpComponent();
    component.setEndpoints(new HttpEndpointType[] { ep });
    container.activateComponent(component, "HttpConsumer");

    // Dummy up a component as a receiver and route it to urn:HttpInvoker/Endpoint
    TransformComponentSupport rmiComponent = new TransformComponentSupport() {
        protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out)
                throws MessagingException {
            try {
                // Deserialize rmi invocation
                XStream xstream = new XStream(new DomDriver());
                SourceTransformer st = new SourceTransformer();
                Object rmi = xstream.fromXML(st.toString(in.getContent()));

                DefaultRemoteInvocationExecutor executor = new DefaultRemoteInvocationExecutor();
                Object result = executor.invoke((RemoteInvocation) rmi, person);

                // Convert result to an rmi invocation
                RemoteInvocationResult rmiResult = new RemoteInvocationResult(result);
                out.setContent(new StringSource(xstream.toXML(rmiResult)));
            } catch (Exception e) {
                throw new MessagingException(e);
            }

            return true;
        }
    };
    ActivationSpec asReceiver = new ActivationSpec("rmiComponent", rmiComponent);
    asReceiver.setService(new QName("urn:HttpInvoker", "Endpoint"));
    container.activateComponent(asReceiver);

    // Start the JBI container
    container.start();

    // Set up the Spring bean to call into the URL specified for the consumer endpoint
    HttpInvokerProxyFactoryBean pfb = new HttpInvokerProxyFactoryBean();
    pfb.setServiceInterface(Person.class);
    pfb.setServiceUrl("http://localhost:8192/service/");
    pfb.setHttpInvokerRequestExecutor(new SimpleHttpInvokerRequestExecutor());
    pfb.afterPropertiesSet();

    // Grab the object via the proxy factory bean
    Person test = (Person) pfb.getObject();

    // Test getters
    assertEquals("Hunter", test.getGivenName());
    assertEquals("Thompson", test.getSurName());
    assertEquals(67, test.getAge());

    // Test setters
    test.setGivenName("John");
    test.setSurName("Doe");
    test.setAge(34);

    assertEquals(person.getGivenName(), "John");
    assertEquals(person.getSurName(), "Doe");
    assertEquals(person.getAge(), 34);
}

From source file:de.scoopgmbh.copper.monitoring.client.context.ApplicationContext.java

protected void connect(final String serverAdressParam, final String user, final String password) {
    boolean secureConnect = StringUtils.hasText(user) && StringUtils.hasText(password);
    String serverAdress = serverAdressParam;
    if (!serverAdress.endsWith("/")) {
        serverAdress = serverAdress + "/";
    }/*from w  w w.  j ava  2  s .  c om*/

    final LoginService loginService;
    final CommonsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new CommonsHttpInvokerRequestExecutor();
    DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(10, false);
    httpInvokerRequestExecutor.getHttpClient().getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            retryHandler);
    httpInvokerRequestExecutor.getHttpClient().getParams().setSoTimeout(1000 * 60 * 5);
    {
        HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();
        httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "copperMonitoringService");
        httpInvokerProxyFactoryBean.setServiceInterface(LoginService.class);
        httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "loginService");
        httpInvokerProxyFactoryBean.afterPropertiesSet();
        httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
        loginService = (LoginService) httpInvokerProxyFactoryBean.getObject();
    }

    final String sessionId;
    if (secureConnect) {
        try {
            sessionId = loginService.doLogin(user, password);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    } else {
        sessionId = "";
    }

    if (sessionId == null) {
        getIssueReporterSingleton().reportWarning("Invalid user/password", null, new Runnable() {
            @Override
            public void run() {
                createLoginForm().show();
            }
        });
    } else {
        HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();
        httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "copperMonitoringService");
        httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class);
        RemoteInvocationFactory remoteInvocationFactory = secureConnect
                ? new SecureRemoteInvocationFactory(sessionId)
                : new DefaultRemoteInvocationFactory();
        httpInvokerProxyFactoryBean.setRemoteInvocationFactory(remoteInvocationFactory);
        httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
        httpInvokerProxyFactoryBean.afterPropertiesSet();
        final CopperMonitoringService copperMonitoringService = (CopperMonitoringService) httpInvokerProxyFactoryBean
                .getObject();

        final String serverAdressFinal = serverAdress;
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                setGuiCopperDataProvider(copperMonitoringService, serverAdressFinal, sessionId);
            }
        });
    }
}

From source file:org.geoserver.geofence.servicetest.MainTest.java

public void instantiateAndRunSpringRemoting() {
    HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();
    httpInvokerProxyFactoryBean.setServiceInterface(org.geoserver.geofence.services.RuleReaderService.class);
    httpInvokerProxyFactoryBean.setServiceUrl("http://localhost:9191/geofence/remoting/RuleReader");
    httpInvokerProxyFactoryBean.afterPropertiesSet();
    RuleReaderService rrs = (RuleReaderService) httpInvokerProxyFactoryBean.getObject();

    RuleFilter filter1 = new RuleFilter(SpecialFilterType.DEFAULT, true).setUser("pippo").setInstance("gs1")
            .setService("WMS");
    AccessInfo accessInfo = rrs.getAccessInfo(filter1);
    LOGGER.info(accessInfo);// www  . j  av a2s .c o m

    RuleFilter filter2 = new RuleFilter(SpecialFilterType.DEFAULT, true).setUser("pippo").setInstance("gs1")
            .setService("WCS");
    AccessInfo accessInfo2 = rrs.getAccessInfo(filter2);
    LOGGER.info(accessInfo2);
}

From source file:it.geosolutions.geofence.servicetest.MainTest.java

public void instantiateAndRunSpringRemoting() {
    HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();
    httpInvokerProxyFactoryBean.setServiceInterface(it.geosolutions.geofence.services.RuleReaderService.class);
    httpInvokerProxyFactoryBean.setServiceUrl("http://localhost:9191/geofence/remoting/RuleReader");
    httpInvokerProxyFactoryBean.afterPropertiesSet();
    RuleReaderService rrs = (RuleReaderService) httpInvokerProxyFactoryBean.getObject();

    RuleFilter filter1 = new RuleFilter(SpecialFilterType.DEFAULT, true).setUser("pippo").setInstance("gs1")
            .setService("WMS");
    AccessInfo accessInfo = rrs.getAccessInfo(filter1);
    LOGGER.info(accessInfo);/*  w w  w . j av  a  2s  .  c o m*/

    RuleFilter filter2 = new RuleFilter(SpecialFilterType.DEFAULT, true).setUser("pippo").setInstance("gs1")
            .setService("WCS");
    AccessInfo accessInfo2 = rrs.getAccessInfo(filter2);
    LOGGER.info(accessInfo2);
}

From source file:org.copperengine.monitoring.client.context.ApplicationContext.java

protected void connect(final String serverAddressParam, final String user, final String password) {
    boolean secureConnect = StringUtils.hasText(user) && StringUtils.hasText(password);
    String serverAddress = serverAddressParam;
    if (!serverAddress.endsWith("/")) {
        serverAddress = serverAddress + "/";
    }/*from  ww  w.j  a  va2 s  .co  m*/

    final LoginService loginService;
    final CommonsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new CommonsHttpInvokerRequestExecutor();
    DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(10, false);
    httpInvokerRequestExecutor.getHttpClient().getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            retryHandler);
    httpInvokerRequestExecutor.getHttpClient().getParams().setSoTimeout(1000 * 60 * 5);
    {
        HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();
        httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "copperMonitoringService");
        httpInvokerProxyFactoryBean.setServiceInterface(LoginService.class);
        httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "loginService");
        httpInvokerProxyFactoryBean.afterPropertiesSet();
        httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
        loginService = (LoginService) httpInvokerProxyFactoryBean.getObject();
    }

    final String sessionId;
    if (secureConnect) {
        try {
            sessionId = loginService.doLogin(user, password);
        } catch (RemoteException e) {
            throw new RuntimeException(e);
        }
    } else {
        sessionId = "";
    }

    if (sessionId == null) {
        getIssueReporterSingleton().reportWarning("Invalid user/password", null, new Runnable() {
            @Override
            public void run() {
                createLoginForm().show();
            }
        });
    } else {
        HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean();
        httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "copperMonitoringService");
        httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class);
        RemoteInvocationFactory remoteInvocationFactory = secureConnect
                ? new SecureRemoteInvocationFactory(sessionId)
                : new DefaultRemoteInvocationFactory();
        httpInvokerProxyFactoryBean.setRemoteInvocationFactory(remoteInvocationFactory);
        httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
        httpInvokerProxyFactoryBean.afterPropertiesSet();
        final CopperMonitoringService copperMonitoringService = (CopperMonitoringService) httpInvokerProxyFactoryBean
                .getObject();

        final String serverAddressFinal = serverAddress;
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                setGuiCopperDataProvider(copperMonitoringService, serverAddressFinal, sessionId);
            }
        });
    }
}

From source file:org.kuali.rice.kew.config.ThinClientResourceLoader.java

protected Object getServiceProxy(Class serviceInterface, String endpointParam, String secureEndpointParam) {
    HttpInvokerProxyFactoryBean proxyFactory = new HttpInvokerProxyFactoryBean();
    String serviceUrl = ConfigContext.getCurrentContextConfig().getProperty(endpointParam);
    if (StringUtils.isEmpty(serviceUrl)) {
        throw new IllegalArgumentException(
                "The " + endpointParam + " configuration parameter was not defined but is required.");
    }//www .  j av  a 2 s .c  om
    proxyFactory.setServiceUrl(serviceUrl);
    proxyFactory.setServiceInterface(serviceInterface);
    String secureProp = ConfigContext.getCurrentContextConfig().getProperty(secureEndpointParam);
    Boolean secureIt = null;
    secureIt = secureProp == null || Boolean.valueOf(secureProp);
    KSBHttpInvokerRequestExecutor executor = new KSBHttpInvokerRequestExecutor(getHttpClient());
    executor.setSecure(secureIt);
    proxyFactory.setHttpInvokerRequestExecutor(executor);
    proxyFactory.afterPropertiesSet();
    return proxyFactory.getObject();
}

From source file:org.openflamingo.web.viz.VizController.java

/**
 * Remote File System Service .//from w ww.  j a va 2s. co  m
 *
 * @return Remote Workflow Engine Service
 */
private FileSystemService getFileSystemService(String url) {
    HttpInvokerProxyFactoryBean factoryBean = new HttpInvokerProxyFactoryBean();
    factoryBean.setServiceUrl(url);
    factoryBean.setServiceInterface(FileSystemService.class);
    HttpComponentsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new HttpComponentsHttpInvokerRequestExecutor();
    factoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
    factoryBean.afterPropertiesSet();
    return (FileSystemService) factoryBean.getObject();
}