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;
}
};
}
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);
}
}
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;
}
Aggregations