Search in sources :

Example 1 with IServiceTunnelContentHandler

use of org.eclipse.scout.rt.shared.servicetunnel.IServiceTunnelContentHandler in project scout.rt by eclipse.

the class HttpServiceTunnelTest method getTestContentHandler.

private IServiceTunnelContentHandler getTestContentHandler() {
    return new IServiceTunnelContentHandler() {

        @Override
        public void writeResponse(OutputStream out, ServiceTunnelResponse msg) throws IOException {
        }

        @Override
        public void writeRequest(OutputStream out, ServiceTunnelRequest msg) throws IOException {
        }

        @Override
        public ServiceTunnelResponse readResponse(InputStream in) throws IOException, ClassNotFoundException {
            ByteArrayInputStream bi = (ByteArrayInputStream) in;
            ObjectInputStream in2 = new ObjectInputStream(bi);
            Object o = in2.readObject();
            return (ServiceTunnelResponse) o;
        }

        @Override
        public ServiceTunnelRequest readRequest(InputStream in) throws IOException, ClassNotFoundException {
            return null;
        }

        @Override
        public void initialize() {
        }

        @Override
        public String getContentType() {
            return null;
        }
    };
}
Also used : IServiceTunnelContentHandler(org.eclipse.scout.rt.shared.servicetunnel.IServiceTunnelContentHandler) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectInputStream(java.io.ObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) ServiceTunnelRequest(org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelRequest) ServiceTunnelResponse(org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelResponse) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with IServiceTunnelContentHandler

use of org.eclipse.scout.rt.shared.servicetunnel.IServiceTunnelContentHandler in project scout.rt by eclipse.

the class ServiceTunnelServletCall method run.

@Override
public void run() {
    try {
        URL url = new URL(m_serverUrl + "/process");
        final IServiceTunnelContentHandler contentHandler = BEANS.get(IServiceTunnelContentHandler.class);
        contentHandler.initialize();
        // 
        HttpRequestFactory requestFactory = BEANS.get(HttpServiceTunnelTransportManager.class).getHttpRequestFactory();
        HttpRequest req = requestFactory.buildPostRequest(new GenericUrl(url), new HttpContent() {

            @Override
            public void writeTo(OutputStream out) throws IOException {
                contentHandler.writeRequest(out, m_req);
            }

            @Override
            public boolean retrySupported() {
                return false;
            }

            @Override
            public String getType() {
                return null;
            }

            @Override
            public long getLength() throws IOException {
                return 0;
            }
        });
        req.getHeaders().setAuthorization("Basic " + Base64Utility.encode("admin:manager".getBytes()));
        HttpResponse resp = req.execute();
        m_res = contentHandler.readResponse(resp.getContent());
    } catch (Throwable e) {
        m_res = new ServiceTunnelResponse(e);
    }
}
Also used : IServiceTunnelContentHandler(org.eclipse.scout.rt.shared.servicetunnel.IServiceTunnelContentHandler) HttpRequest(com.google.api.client.http.HttpRequest) HttpRequestFactory(com.google.api.client.http.HttpRequestFactory) OutputStream(java.io.OutputStream) HttpServiceTunnelTransportManager(org.eclipse.scout.rt.shared.servicetunnel.http.HttpServiceTunnelTransportManager) HttpResponse(com.google.api.client.http.HttpResponse) GenericUrl(com.google.api.client.http.GenericUrl) IOException(java.io.IOException) URL(java.net.URL) HttpContent(com.google.api.client.http.HttpContent) ServiceTunnelResponse(org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelResponse)

Example 3 with IServiceTunnelContentHandler

use of org.eclipse.scout.rt.shared.servicetunnel.IServiceTunnelContentHandler in project scout.rt by eclipse.

the class ServiceTunnelServlet method createContentHandler.

/**
 * Create the (reusable) content handler (soap, xml, binary) for marshalling scout remote service calls
 * <p>
 * This method is part of the protected api and can be overridden.
 */
protected IServiceTunnelContentHandler createContentHandler() {
    IServiceTunnelContentHandler e = BEANS.get(IServiceTunnelContentHandler.class);
    e.initialize();
    return e;
}
Also used : IServiceTunnelContentHandler(org.eclipse.scout.rt.shared.servicetunnel.IServiceTunnelContentHandler)

Aggregations

IServiceTunnelContentHandler (org.eclipse.scout.rt.shared.servicetunnel.IServiceTunnelContentHandler)3 OutputStream (java.io.OutputStream)2 ServiceTunnelResponse (org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelResponse)2 GenericUrl (com.google.api.client.http.GenericUrl)1 HttpContent (com.google.api.client.http.HttpContent)1 HttpRequest (com.google.api.client.http.HttpRequest)1 HttpRequestFactory (com.google.api.client.http.HttpRequestFactory)1 HttpResponse (com.google.api.client.http.HttpResponse)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 URL (java.net.URL)1 ServiceTunnelRequest (org.eclipse.scout.rt.shared.servicetunnel.ServiceTunnelRequest)1 HttpServiceTunnelTransportManager (org.eclipse.scout.rt.shared.servicetunnel.http.HttpServiceTunnelTransportManager)1