本文整理汇总了Java中org.glassfish.jersey.client.JerseyInvocation.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java JerseyInvocation.Builder方法的具体用法?Java JerseyInvocation.Builder怎么用?Java JerseyInvocation.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.glassfish.jersey.client.JerseyInvocation
的用法示例。
在下文中一共展示了JerseyInvocation.Builder方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildAuthorisedClient
import org.glassfish.jersey.client.JerseyInvocation; //导入方法依赖的package包/类
private JerseyInvocation.Builder buildAuthorisedClient(String url) {
final JerseyClient client = createClient();
return client.target(url)
.request()
.property(HTTP_AUTHENTICATION_BASIC_USERNAME, authService + "/service")
.property(HTTP_AUTHENTICATION_BASIC_PASSWORD, basicPassword);
}
示例2: request
import org.glassfish.jersey.client.JerseyInvocation; //导入方法依赖的package包/类
@Override
public JerseyInvocation.Builder request() {
checkNotClosed();
//TODO
//return new JerseyInvocation.Builder(getUri(), config.snapshot());
throw new NotImplementedException();
}
示例3: getThing
import org.glassfish.jersey.client.JerseyInvocation; //导入方法依赖的package包/类
private Response getThing(NewCookie sessionCookie) {
JerseyInvocation.Builder request = getPath().request();
if (sessionCookie != null) {
request.cookie(sessionCookie);
}
return request.get();
}
示例4: mockFeedClientRequest
import org.glassfish.jersey.client.JerseyInvocation; //导入方法依赖的package包/类
private FeedClient mockFeedClientRequest(String json) throws URISyntaxException {
FlexCredentials flexCredentials = new FlexCredentials("appId", "appKey");
JerseyClient jerseyClient = Mockito.mock(JerseyClient.class);
JerseyWebTarget jerseyWebTarget = Mockito.mock(JerseyWebTarget.class);
JerseyInvocation.Builder builder = Mockito.mock(JerseyInvocation.Builder.class);
Mockito.when(jerseyClient.target(Matchers.any(URI.class))).thenReturn(jerseyWebTarget);
Mockito.when(jerseyWebTarget.request(Matchers.any(MediaType.class))).thenReturn(builder);
Mockito.when(builder.get(String.class)).thenReturn(json);
return new FeedClient(flexCredentials, uri, jerseyClient);
}
示例5: setUp
import org.glassfish.jersey.client.JerseyInvocation; //导入方法依赖的package包/类
@Before
public void setUp() {
configureBean();
clientBuilder = spy(ClientBuilder.newBuilder());
JerseyClient client = mock(JerseyClient.class);
JerseyWebTarget listTarget = mock(JerseyWebTarget.class);
JerseyInvocation.Builder builder = mock(JerseyInvocation.Builder.class);
getInvocation = mock(JerseyInvocation.class);
JerseyInvocation postInvocation = mock(JerseyInvocation.class);
listResponse = mock(Response.class);
runResponse = mock(Response.class);
doReturn(listTarget).when(client).target(anyString());
doReturn(listTarget).when(listTarget).queryParam("job_id", configBean.databricksConfigBean.jobId);
doReturn(builder).when(listTarget).request(MediaType.APPLICATION_JSON_TYPE);
doReturn(getInvocation).when(builder).buildGet();
doReturn(listResponse).when(getInvocation).invoke();
doReturn(postInvocation).when(builder).buildPost(any());
doReturn(runResponse).when(postInvocation).invoke();
doReturn(builder).when(listTarget).request();
doReturn(postInvocation).when(builder)
.buildPost(Entity.json((
new RunJarJobJson(configBean.databricksConfigBean.jobId, configBean.databricksConfigBean.jarParams))));
doReturn(client).when(clientBuilder).build();
}
示例6: method
import org.glassfish.jersey.client.JerseyInvocation; //导入方法依赖的package包/类
protected Response method(ApplicationFullName targetApplication, String name, Entity<?> entity) {
int port = LoadBalancer.getInstance().getPort(targetApplication);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("method(" + targetApplication + ", " + name + "): port: " + port);
}
long startAt = -1;
if (port > 0) {
UriBuilder uriBuilder = targetUri
.clone()
.scheme("http")
.host("localhost")
.port(port);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("method(" + targetApplication + ", " + name + "): URI: " + uriBuilder.build());
}
try {
JerseyInvocation.Builder request = client.target(uriBuilder.build()).request();
for (MediaType accept : acceptMediaTypes) {
request = request.accept(accept);
}
JerseyInvocation invocation;
if (entity == null) {
invocation = request.build(name);
} else {
invocation = request.build(name, entity);
}
startAt = System.currentTimeMillis();
Response response = invocation.invoke();
if (isResponseCodeAcceptable(response.getStatus())) {
return response;
}
} catch (WebApplicationException wExc) {
if (isResponseCodeAcceptable(wExc.getResponse().getStatus())) {
throw wExc;
}
} catch (Exception e) {
//TODO: Provide support for balancing to another endpoint (another endpoint of the same cluster).
LOGGER.warn("Cannot reach application " + targetApplication + " on port " + port, e);
} finally {
if (startAt > 0) {
LoadBalancer.getInstance().updateStats(targetApplication, port, System.currentTimeMillis() - startAt);
}
}
}
return null;
}
示例7: invocation
import org.glassfish.jersey.client.JerseyInvocation; //导入方法依赖的package包/类
@Override
public JerseyInvocation.Builder invocation(Link link) {
return client.invocation(link);
}