This commit is contained in:
Lucio Lelii 2018-10-26 09:07:23 +00:00
parent c0d2028156
commit 9681f66694
2 changed files with 32 additions and 7 deletions

View File

@ -26,14 +26,10 @@ public class TargetFactory implements TargetFactoryDSL.AtClause{
} }
public GXWebTargetAdapterRequest at(String address) { public GXWebTargetAdapterRequest getAsGxRest(String address) {
try{ 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")); String resourceAddress = address.substring(0, address.indexOf("/service"));
@ -64,8 +60,31 @@ public class TargetFactory implements TargetFactoryDSL.AtClause{
} }
public WebTarget at(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");
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 GXWebTargetAdapterRequest at(EndpointReference endpoint){ public WebTarget at(EndpointReference endpoint){
return at(new JaxRSEndpointReference(endpoint).address); return at(new JaxRSEndpointReference(endpoint).address);
} }

View File

@ -29,8 +29,14 @@ public interface TargetFactoryDSL {
* @param address the address * @param address the address
* @return the stub * @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);
} }
} }