git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/common/common-jaxrs-client/1.0@173839 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c0d2028156
commit
9681f66694
|
@ -26,14 +26,10 @@ public class TargetFactory implements TargetFactoryDSL.AtClause{
|
|||
}
|
||||
|
||||
|
||||
public GXWebTargetAdapterRequest at(String address) {
|
||||
public GXWebTargetAdapterRequest getAsGxRest(String address) {
|
||||
|
||||
try{
|
||||
|
||||
Client client = ClientBuilder.newClient()
|
||||
.property(ClientProperties.FOLLOW_REDIRECTS, Boolean.FALSE)
|
||||
.property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024*1024).property(ClientProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, -1)
|
||||
.property(ClientProperties.REQUEST_ENTITY_PROCESSING, "CHUNKED");
|
||||
|
||||
/*
|
||||
String resourceAddress = address.substring(0, address.indexOf("/service"));
|
||||
|
@ -64,8 +60,31 @@ public class TargetFactory implements TargetFactoryDSL.AtClause{
|
|||
|
||||
}
|
||||
|
||||
public WebTarget at(String address) {
|
||||
|
||||
public GXWebTargetAdapterRequest at(EndpointReference endpoint){
|
||||
try{
|
||||
|
||||
Client client = ClientBuilder.newClient()
|
||||
.property(ClientProperties.FOLLOW_REDIRECTS, Boolean.FALSE)
|
||||
.property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024*1024).property(ClientProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, -1)
|
||||
.property(ClientProperties.REQUEST_ENTITY_PROCESSING, "CHUNKED");
|
||||
|
||||
|
||||
WebTarget webTarget = client.target(address).path(target.path());
|
||||
|
||||
webTarget.register(new JaxRSRequestFilter(target));
|
||||
|
||||
return webTarget;
|
||||
|
||||
}catch (Exception e) {
|
||||
log.error("error building service",e);
|
||||
throw new RuntimeException("error building service",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public WebTarget at(EndpointReference endpoint){
|
||||
return at(new JaxRSEndpointReference(endpoint).address);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,14 @@ public interface TargetFactoryDSL {
|
|||
* @param address the address
|
||||
* @return the stub
|
||||
*/
|
||||
GXWebTargetAdapterRequest at(String address);
|
||||
GXWebTargetAdapterRequest getAsGxRest(String address);
|
||||
|
||||
/**
|
||||
* Returns a stub for a service endpoint at a given address.
|
||||
* @param address the address
|
||||
* @return the stub
|
||||
*/
|
||||
WebTarget at(String address);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue