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


Java WebResource.queryParam方法代码示例

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


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

示例1: getParameterMap

import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
/**
 * Copies all parameter values from the given HTTPServletRequest to a new
 * Jersey WebResource, using the given WebResource as a basis.
 *
 * @param request
 *     The HttpServletRequest to copy parameters from.
 *
 * @param resource
 *     The WebResource to use as a basis.
 *
 * @return
 *     A new WebResource identical to the provided WebResource, but with
 *     query parameters copied from the given HttpServletRequest.
 */
@SuppressWarnings("unchecked") // getParameterMap() is defined as returning Map<String, String[]>
private WebResource copyParameters(HttpServletRequest request, WebResource resource) {

    // Get explicitly-typed parameter map
    Map<String, String[]> parameterMap = (Map<String, String[]>)
            request.getParameterMap();

    // For each parameter
    for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {

        // Add each name/value pair
        String name = entry.getKey();
        for (String value : entry.getValue())
            resource = resource.queryParam(name, value);

    }

    return resource;

}
 
开发者ID:glyptodon,项目名称:guacamole-auth-callback,代码行数:35,代码来源:CallbackService.java

示例2: constructWebResource

import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
private WebResource constructWebResource(WebResource r, String... paths) {
  WebResource rt = r;
  for (String path : paths) {
    rt = rt.path(path);
  }
  if (isAuthenticationEnabled()) {
    rt = rt.queryParam("user.name", webserviceUserName);
  }
  return rt;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestRMWebServicesAppsModification.java

示例3: testSingleAppKill

import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
@Test(timeout = 120000)
public void testSingleAppKill() throws Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  String[] mediaTypes =
      { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML };
  MediaType[] contentTypes =
      { MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_XML_TYPE };
  for (String mediaType : mediaTypes) {
    for (MediaType contentType : contentTypes) {
      RMApp app = rm.submitApp(CONTAINER_MB, "", webserviceUserName);
      amNodeManager.nodeHeartbeat(true);

      AppState targetState =
          new AppState(YarnApplicationState.KILLED.toString());

      Object entity;
      if (contentType.equals(MediaType.APPLICATION_JSON_TYPE)) {
        entity = appStateToJSON(targetState);
      } else {
        entity = targetState;
      }
      ClientResponse response =
          this
            .constructWebResource("apps", app.getApplicationId().toString(),
              "state").entity(entity, contentType).accept(mediaType)
            .put(ClientResponse.class);

      if (!isAuthenticationEnabled()) {
        assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
        continue;
      }
      assertEquals(Status.ACCEPTED, response.getClientResponseStatus());
      if (mediaType.equals(MediaType.APPLICATION_JSON)) {
        verifyAppStateJson(response, RMAppState.FINAL_SAVING,
          RMAppState.KILLED, RMAppState.KILLING, RMAppState.ACCEPTED);
      } else {
        verifyAppStateXML(response, RMAppState.FINAL_SAVING,
          RMAppState.KILLED, RMAppState.KILLING, RMAppState.ACCEPTED);
      }

      String locationHeaderValue =
          response.getHeaders().getFirst(HttpHeaders.LOCATION);
      Client c = Client.create();
      WebResource tmp = c.resource(locationHeaderValue);
      if (isAuthenticationEnabled()) {
        tmp = tmp.queryParam("user.name", webserviceUserName);
      }
      response = tmp.get(ClientResponse.class);
      assertEquals(Status.OK, response.getClientResponseStatus());
      assertTrue(locationHeaderValue.endsWith("/ws/v1/cluster/apps/"
          + app.getApplicationId().toString() + "/state"));

      while (true) {
        Thread.sleep(100);
        response =
            this
              .constructWebResource("apps",
                app.getApplicationId().toString(), "state").accept(mediaType)
              .entity(entity, contentType).put(ClientResponse.class);
        assertTrue((response.getClientResponseStatus() == Status.ACCEPTED)
            || (response.getClientResponseStatus() == Status.OK));
        if (response.getClientResponseStatus() == Status.OK) {
          assertEquals(RMAppState.KILLED, app.getState());
          if (mediaType.equals(MediaType.APPLICATION_JSON)) {
            verifyAppStateJson(response, RMAppState.KILLED);
          } else {
            verifyAppStateXML(response, RMAppState.KILLED);
          }
          break;
        }
      }
    }
  }

  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:78,代码来源:TestRMWebServicesAppsModification.java


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