当前位置: 首页>>代码示例>>Java>>正文


Java Invocation.Builder方法代码示例

本文整理汇总了Java中javax.ws.rs.client.Invocation.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java Invocation.Builder方法的具体用法?Java Invocation.Builder怎么用?Java Invocation.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.client.Invocation的用法示例。


在下文中一共展示了Invocation.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClientBuilder

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
/**
 * Gets a client web resource builder.
 *
 * @param localUrl the URL to access remote resource
 * @return web resource builder
 */
public Invocation.Builder getClientBuilder(String localUrl) {
    log.info("URL: {}", localUrl);
    Client client = ClientBuilder.newClient();
    WebTarget wt = client.target(localUrl);
    return wt.request(UTF_8);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:RestClient.java

示例2: deleteConcept

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
public void deleteConcept(Concept concept) throws OEClientException {
	logger.info("deleteConcept entry: {} {} {}", concept.getUri());

	String url = getResourceURL(concept.getUri());
	logger.info("deleteConcept - URL: {}", url);

	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("mode", "empty");

	Invocation.Builder invocationBuilder = getInvocationBuilder(url, queryParameters);

	Response response = invocationBuilder.delete();

	if (response.getStatus() == 204) {
		return;
	}

	logger.warn(response.readEntity(String.class));
	throw new OEClientException(
			String.format("%s Response received\n%s", response.getStatus(), response.getEntity().toString()));
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:22,代码来源:OEClientReadWrite.java

示例3: getNetworks

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
/**
 * Returns network information stored in Neutron.
 *
 * @return List of OpenstackNetwork
 */
public Collection<OpenstackNetwork> getNetworks() {

    Invocation.Builder builder = getClientBuilder(neutronUrl + URI_NETWORKS);
    String response = builder.accept(MediaType.APPLICATION_JSON_TYPE).
            header(HEADER_AUTH_TOKEN, getToken()).get(String.class);

    log.debug("networks response:" + response);

    ObjectMapper mapper = new ObjectMapper();
    List<OpenstackNetwork> openstackNetworks = Lists.newArrayList();
    try {
        ObjectNode node = (ObjectNode) mapper.readTree(response);
        ArrayNode networkList = (ArrayNode) node.path(PATH_NETWORKS);
        OpenstackNetworkCodec networkCodec = new OpenstackNetworkCodec();
        networkList.forEach(n -> openstackNetworks.add(networkCodec.decode((ObjectNode) n, null)));
    } catch (IOException e) {
        log.warn("getNetworks()", e);
    }

    openstackNetworks.removeAll(Collections.singleton(null));
    openstackNetworks.forEach(n -> log.debug("network ID: {}", n.id()));

    return openstackNetworks;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:OpenstackInterfaceManager.java

示例4: sendRequest

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
public Response sendRequest(String url, String requestType) {
    Client client = ClientBuilder.newClient();
    System.out.println("Testing " + url);
    WebTarget target = client.target(url);
    Invocation.Builder invoBuild = target.request();
    Response response = invoBuild.build(requestType).invoke();
    return response;
}
 
开发者ID:WASdev,项目名称:sample.metrics,代码行数:9,代码来源:EndpointHelper.java

示例5: main

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
public static void main(String[] args)
		throws IOException, URISyntaxException {
	Client client = ClientBuilder.newClient();
	// GET http://api.geonames.org/searchJSON?...
	WebTarget target = client.target("http://api.geonames.org/searchJSON")
			.queryParam("q", "kabupaten garut")
			.queryParam("username", "ceefour");
	Invocation.Builder invocationBuilder = target.request(MediaType.APPLICATION_JSON);
	GeonamesSearchResult searchResult = invocationBuilder.get(GeonamesSearchResult.class);
	LOG.info("Body (GeonamesSearchResult): {}", searchResult);
	for (Geoname child : searchResult.getGeonames()) {
		LOG.info("Place: {} ({}, {})",
				child.getToponymName(), child.getLat(), child.getLng());
	}
}
 
开发者ID:ceefour,项目名称:java-web-services-training,代码行数:16,代码来源:GetGeonamesApplication.java

示例6: testCanUseApiToRequestUserId

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
@Test
public void testCanUseApiToRequestUserId() {
    final Invocation.Builder b = generateRequest(RULE, HTTP_USERS_PATH + "/current");

    final Response response = b.get();

    assertThat(response.getStatus()).isEqualTo(OK);
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:9,代码来源:TestGuestAuth.java

示例7: sendRequestJson

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
/**
 * Helper method for sending requests with a json payload.
 *
 * @param url the url to call
 * @param requestType the http method to invoke
 * @param json the json payload to send
 * @return the response from the server
 */
public Response sendRequestJson(String url, String requestType, String json) {
  String method = "sendRequestJson";
  logger.entering(clazz, method);
  logger.fine("  url: " + url);
  logger.fine("  requestType: " + requestType);
  logger.fine("  json: " + json);

  String jwt = null;
  try {
    jwt = new JWTVerifier().createJWT("fred");
  } catch (Throwable t) {
    throw new RuntimeException(t);
  }

  Client client = ClientBuilder.newClient();
  WebTarget target = client.target(url);
  Invocation.Builder invoBuild = target.request(MediaType.APPLICATION_JSON_TYPE);

  // Allowing for null payload to get a 400 response code
  Entity<String> data;
  if (null == json || json.isEmpty()) {
    data = Entity.entity("", MediaType.APPLICATION_JSON_TYPE);
  } else {
    data = Entity.entity(json, MediaType.APPLICATION_JSON_TYPE);
  }

  invoBuild.header(HttpHeaders.AUTHORIZATION, "Bearer " + jwt);
  Response response = invoBuild.build(requestType, data).invoke();

  logger.exiting(
      clazz,
      method,
      "\n\n- - - - - Exiting " + method + " with: " + response.readEntity(String.class) + "\n\n");
  return response;
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:44,代码来源:OccasionResourceTest.java

示例8: get

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
/**
 * Execute a GET REST method
 *
 * @return the response
 */
@PublicAtsApi
public RestResponse get() {

    // execute GET
    Invocation.Builder invocationBuilder = constructInvocationBuilder("GET from");
    RestResponse response = new RestResponse(invocationBuilder.get());

    logRESTResponse(response);
    initInternalVariables();

    // return response
    return response;
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:19,代码来源:RestClient.java

示例9: getAllModels

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
public Collection<Model> getAllModels() throws OEClientException {
	logger.info("getAllModels entry");
	
	String url = getApiURL() + "/sys/sys:Model/rdf:instance";
	logger.info("getAllModels URL: {}", url);
	Map<String, String> queryParameters = new HashMap<String, String>();
	queryParameters.put("properties", "meta:displayName,meta:graphUri");

	Invocation.Builder invocationBuilder = getInvocationBuilder(url, queryParameters);

	Date startDate = new Date();
	logger.info("getAllModels making call  : {}", startDate.getTime());
	Response response = invocationBuilder.get();
	logger.info("getAllModels call complete: {}", startDate.getTime());

	logger.info("getAllModels - status: {}", response.getStatus());

	if (response.getStatus() == 200) {
		String stringResponse = response.readEntity(String.class);
		if (logger.isInfoEnabled()) logger.info("getAllModels: jsonResponse {}", stringResponse);
		JsonObject jsonResponse = JSON.parse(stringResponse);
		JsonArray jsonArray = jsonResponse.get("@graph").getAsArray();
		Collection<Model> models = new ArrayList<Model>();
		Iterator<JsonValue> jsonValueIterator = jsonArray.iterator();
		while (jsonValueIterator.hasNext()) {
			JsonObject modelObject = jsonValueIterator.next().getAsObject();
			models.add(new Model(modelObject));
		}
		return models;
	} else {
		throw new OEClientException(String.format("Error(%d) %s from server", response.getStatus(), response.getStatusInfo().toString()));
	}
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:34,代码来源:OEClientReadOnly.java

示例10: testAcceptsCredentialsHardCodedByTheCustomAuthScheme

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
@Test
public void testAcceptsCredentialsHardCodedByTheCustomAuthScheme() {
    final Invocation.Builder b = generateRequest(RULE, HTTP_USERS_PATH + "/current");
    authenticate(b, USERNAME_IN_CONFIG_TEMPLATE, PASSWORD_IN_CONFIG_TEMPLATE);

    final Response response = b.get();

    assertThat(response.getStatus()).isEqualTo(OK);
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:10,代码来源:TestCustomAuth.java

示例11: deleteRest

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
/**
 * Performs a REST DELETE operation on the base
 * XOS REST URI with an optional additional URI.
 *
 * @param uri optional additional URI
 * @deprecated in Cardinal Release
 */
@Deprecated
private void deleteRest(String uri) {
    Invocation.Builder builder = getClientBuilder(uri);
    Response response = builder.delete();

    if (response.getStatus() != HTTP_NO_CONTENT) {
        log.info("REST DELETE request returned error code {}",
                response.getStatus());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OnosXosIntegrationManager.java

示例12: resetDbWithResponse

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
/**
 * Resets Syndesis database.
 *
 * @return HTTP response code
 */
public int resetDbWithResponse() {
	log.info("Resetting syndesis DB.");

	final Invocation.Builder invocation = client
			.target(getEndpointUrl())
			.request(MediaType.APPLICATION_JSON)
			.header("X-Forwarded-User", "pista")
			.header("X-Forwarded-Access-Token", "kral");
	int responseCode = invocation.get().getStatus();
	log.debug("Reset endpoint reponse: {}", responseCode);
	return responseCode;
}
 
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:18,代码来源:TestSupport.java

示例13: getByName

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
@Override
public Optional<Application> getByName(String applicationName) {
    Invocation.Builder builder = client
            .target(APPLICATIONS_URL)
            .queryParam("filter[name]", applicationName)
            .request(APPLICATION_JSON_TYPE);
    return getPageable(builder, ApplicationList.class)
            .filter(application -> application.getName().equals(applicationName))
            .getSingle();
}
 
开发者ID:ocadotechnology,项目名称:newrelic-alerts-configurator,代码行数:11,代码来源:DefaultApplicationsApi.java

示例14: put

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
protected final <T, S> Result<T> put(Invocation.Builder resource, S representation, Class<T> clazz, String token) {
	if (isNotBlank(token)) {
		resource.header("Authorization", "Bearer " + token);
	}

	Response response = resource.put(Entity.entity(representation, APPLICATION_JSON));
	if (response.getStatus() == 200) {
		return Result.accept(response.getStatus(), response.readEntity(clazz));
	}

	return Result.reject(response.getStatus(), null, response.readEntity(ErrorsRepresentation.class).getErrors());
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:13,代码来源:RestClient.java

示例15: deleteResource

import javax.ws.rs.client.Invocation; //导入方法依赖的package包/类
public String deleteResource(URI resourcePath) throws Exception {
    final Invocation.Builder requestBuilder = getRequestBuilder(resourcePath);
    return deleteResource(resourcePath.getPath(), requestBuilder);
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:5,代码来源:RestBaseClient.java


注:本文中的javax.ws.rs.client.Invocation.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。