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

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

Introduction

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

Prototype

@Override
    public void afterPropertiesSet() 

Source Link

Usage

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   ww w . ja v  a2  s  .  c  o  m*/
    fb.afterPropertiesSet();
    return fb;
}

From source file:org.jdal.remoting.httpinvoker.HttpInvokerRemoteReference.java

/**
 * {@inheritDoc}/*  w  w w  .j  a  va 2 s. c  o  m*/
 */
@Override
public RemoteClient createRemoteClient() {
    HttpInvokerProxyFactoryBean factoryBean = new HttpInvokerProxyFactoryBean();
    factoryBean.setServiceUrl(getServiceUrl());
    factoryBean.setServiceInterface(getServiceInterface());
    factoryBean.setCodebaseUrl(codebaseUrl);
    factoryBean.afterPropertiesSet();

    return (RemoteClient) factoryBean.getObject();
}

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);// w  ww  .  jav  a2 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: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);/*  w w  w.  j ava2  s.  co 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);/*from w w w .j  a va 2  s  . 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: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 + "/";
    }//ww  w.  j  a  v a  2 s .c o  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(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.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 + "/";
    }//ww  w .  ja v a 2 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.");
    }//from   w  w w  . java 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 ./*w  w w .  j av a  2 s.  c o 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();
}