當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncResponse類代碼示例

本文整理匯總了Java中javax.ws.rs.container.AsyncResponse的典型用法代碼示例。如果您正苦於以下問題:Java AsyncResponse類的具體用法?Java AsyncResponse怎麽用?Java AsyncResponse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AsyncResponse類屬於javax.ws.rs.container包,在下文中一共展示了AsyncResponse類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: async

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@ApiOperation(value = "displays openid config of google async",
    hidden = true)
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/async")
public void async(@Suspended final AsyncResponse asyncResponse) throws InterruptedException,
    ExecutionException {

    final Future<Response> futureResponseFromClient = jaxrsClient.target("https://accounts.google.com/.well-known/openid-configuration").request().header(javax.ws.rs.core.HttpHeaders.USER_AGENT, "curl/7.55.1").async().get();

    final Response responseFromClient = futureResponseFromClient.get();
    try {
        final String object = responseFromClient.readEntity(String.class);
        asyncResponse.resume(object);
    } finally {
        responseFromClient.close();
    }
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:19,代碼來源:HelloResource.java

示例2: hello3

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@Path("3")
@GET
public void hello3(@Suspended final AsyncResponse asyncResponse,
	      // Inject the Vertx instance
	      @Context Vertx vertx){
	System.err.println("Creating client");
	HttpClientOptions options = new HttpClientOptions();
	options.setSsl(true);
	options.setTrustAll(true);
	options.setVerifyHost(false);
	HttpClient client = vertx.createHttpClient(options);
	client.getNow(443,
			"www.google.com", 
			"/robots.txt", 
			resp -> {
				System.err.println("Got response");
				resp.bodyHandler(body -> {
					System.err.println("Got body");
					asyncResponse.resume(Response.ok(body.toString()).build());
				});
			});
	System.err.println("Created client");
}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:24,代碼來源:MyResource.java

示例3: asyncGet

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@GET
@Path("/simple")
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {

	new Thread(new Runnable() {
		@Override
		public void run() {
			String result = veryExpensiveOperation();
			asyncResponse.resume(result);
		}

		private String veryExpensiveOperation() {
			return new MagicNumber(3) + "";
		}
	}).start();
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:17,代碼來源:AsyncResource.java

示例4: hello6

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@Path("6")
@GET
public void hello6(@Suspended final AsyncResponse asyncResponse,
	      // Inject the Vertx instance
	      @Context Vertx vertx){
	io.vertx.rxjava.core.Vertx rxVertx = io.vertx.rxjava.core.Vertx.newInstance(vertx);
	System.err.println("Creating client");
	WebClientOptions options = new WebClientOptions();
	options.setSsl(true);
	options.setTrustAll(true);
	options.setVerifyHost(false);
	WebClient client = WebClient.create(rxVertx, options);
	Single<HttpResponse<io.vertx.rxjava.core.buffer.Buffer>> responseHandler = client.get(443,
			"www.google.com", 
			"/robots.txt").rxSend();

	responseHandler.subscribe(body -> {
		System.err.println("Got body");
		asyncResponse.resume(Response.ok(body.body().toString()).build());
	});
	
	System.err.println("Created client");
}
 
開發者ID:FroMage,項目名稱:redpipe,代碼行數:24,代碼來源:MyResource.java

示例5: getDashboards

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
/**
 * 根據配置得到所有dashboards
 */
@GET
@Path("dashboard/getdashboards")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
@SuppressWarnings("unchecked")
public void getDashboards(@Suspended AsyncResponse response) {

    CacheManager cacheManager = this.cm;
    String result = dashboardManagement.getDashboards(cacheManager);
    Map resultMap = new HashMap();
    String codeString = "00";
    String msgString = "獲取配置信息成功";
    if (StringHelper.isEmpty(result)) {
        codeString = "01";
        msgString = "獲取配置信息失敗或配置信息不存在";
    }
    resultMap.put("code", codeString);
    resultMap.put("msg", msgString);
    resultMap.put("data", result);
    String resultMsg = JSONHelper.toString(resultMap);
    response.resume(resultMsg);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:25,代碼來源:GrafanaRestService.java

示例6: delApp

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@POST
@Path("delApp")
public void delApp(AppEntity appEntity, @Suspended AsyncResponse response) throws Exception {

    String id = appEntity.getAppid();
    String ctime = df.format(new Date());
    Map<String, Object> update = new HashMap<String, Object>();
    Map<String, Object> set = new HashMap<String, Object>();
    Map<String, Object> modify = new HashMap<String, Object>();
    Map<String, Object> where = new HashMap<String, Object>();

    where.put("appid", id);
    modify.put("where", where);
    set.put("state", 0);
    set.put("operationtime", ctime);
    set.put("operationuser", request.getSession(false).getAttribute("apphub.gui.session.login.user.id"));
    update.put("set", set);
    modify.put("update", update);

    Map<String, Object> jsonRequest = createHttpMapRequest(bussinessTypeModify, modify);
    Map<String, String> callBackInput = createInput(appEntity.getAppid(), null, "delete");
    manageHttpAsyncClientPost(manageTypeApp, jsonRequest, new AppHttpCallBack(response, callBackInput));
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:24,代碼來源:ManageRestService.java

示例7: addApp

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@POST
@Path("addApp")
public void addApp(AppEntity appEntity, @Suspended AsyncResponse response) throws Exception {

    Map<String, Object> data = new HashMap<String, Object>();

    String appurl = XSSFilter(appEntity.getAppurl());
    String id = XSSFilter(appEntity.getAppid());
    String configpath = XSSFilter(appEntity.getConfigpath());
    String ctime = df.format(new Date());

    data.put("appid", id);
    data.put("appurl", appurl);
    data.put("configpath", configpath);
    data.put("state", 1);
    data.put("createtime", ctime);
    data.put("operationtime", ctime);
    data.put("operationuser", request.getSession(false).getAttribute("apphub.gui.session.login.user.id"));

    Map<String, Object> jsonRequest = createHttpMapRequest(bussinessTypeCreate, data);
    Map<String, String> callBackInput = createInput(id, appurl, "create");
    callBackInput.put("configpath", configpath);
    manageHttpAsyncClientPost(manageTypeApp, jsonRequest, new AppHttpCallBack(response, callBackInput));

}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:26,代碼來源:ManageRestService.java

示例8: addGroup

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@POST
@Path("addGroup")
public void addGroup(GroupEntity groupEntity, @Suspended AsyncResponse response) throws Exception {

    String groupId = XSSFilter(groupEntity.getGroupid());
    String appIds = XSSFilter(groupEntity.getAppids());
    String time = df.format(new Date());
    Map<String, Object> data = new HashMap<String, Object>();
    data.put("groupid", groupId);
    data.put("appids", appIds);
    data.put("state", 1);
    data.put("createtime", time);
    data.put("operationtime", time);
    data.put("operationuser", request.getSession(false).getAttribute("apphub.gui.session.login.user.id"));

    Map<String, Object> jsonRequest = createHttpMapRequest(bussinessTypeCreate, data);
    Map<String, String> callBackInput = createInput(groupId, appIds, "create");
    manageHttpAsyncClientPost(manageTypeGroup, jsonRequest, new GroupHttpCallBack(response, callBackInput));
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:20,代碼來源:ManageRestService.java

示例9: loadAppIPLinkList

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
/**
 * 應用監控:獲取應用的IPLink
 * 
 * @param data
 *            a json string ["[email protected]://127.0.0.1:8090/apphub","[email protected]://127.0.0.1:9090/testapp"]
 * @param response
 */
@POST
@Path("profile/q/iplink")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void loadAppIPLinkList(String data, @Suspended AsyncResponse response) {

    UAVHttpMessage message = new UAVHttpMessage();

    message.setIntent("iplnk");

    message.putRequest("appgpids", data);

    LoadAppIPLinkListCB callback = new LoadAppIPLinkListCB();
    callback.setResponse(response);

    this.doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/cache/q", message, callback);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:24,代碼來源:GodEyeRestService.java

示例10: loadMonitorDataFromCache

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
/**
 * 
 * 從緩存查詢最近1min的MonitorData
 * 
 * @param data
 * @param response
 */
private void loadMonitorDataFromCache(String data, @Suspended AsyncResponse response, String cacheKey) {

    UAVHttpMessage message = new UAVHttpMessage();

    message.setIntent("monitor");

    message.putRequest("cache.query.json", data);

    LoadMonitorDataFromCacheCB callback = new LoadMonitorDataFromCacheCB();
    callback.setCacheKey(cacheKey);
    callback.setData(data);
    callback.setGodeyeCacheRegion(godeyeCacheRegion);
    callback.setGodeyeFilterGroupCacheRegion(godeyeFilterGroupCacheRegion);
    callback.setResponse(response);

    this.doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/cache/q", message, callback);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:25,代碼來源:GodEyeRestService.java

示例11: getAppLog

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
/**
 * 顯示當前app的最近實現的日誌信息, 默認查詢指定時間內的日誌記錄
 * 
 * @return
 */
@GET
@Path("log/q/hm/{appid}")
@Deprecated
public void getAppLog(@PathParam("appid") String appid, @QueryParam("timespan") String timespan,
        @QueryParam("psize") String pagesize, @Suspended AsyncResponse response) {

    try {

        // 默認:5分鍾
        long timeLength = DataConvertHelper.toLong(timespan, 1000 * 60 * 5);
        // 默認不傳limit
        StringBuilder data = new StringBuilder("{\"appid\":\"").append(appid).append("\", \"endtime\":")
                .append(System.currentTimeMillis() - timeLength);
        if (pagesize != null && StringHelper.isNumeric(pagesize)) {
            data.append(",\"psize\":").append(Long.parseLong(pagesize));
        }
        data.append("}");
        queryAppLog(data.toString(), response);
    }
    catch (Exception e) {
        logger.err(this, "Error:" + e.getMessage(), e);
    }
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:29,代碼來源:GodEyeRestService.java

示例12: noitifyStrategyQuery

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@SuppressWarnings({ "unchecked" })
@POST
@Path("notify/q/stgy/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyStrategyQuery(String data, @Suspended AsyncResponse response) throws Exception {

    Map<String, Object> params = JSONHelper.toObject(data, Map.class);
    int pagesize = (int) params.get("pagesize");
    int pageindex = (int) params.get("pageindex");
    Map<String, String> strategyMap = new HashMap<String, String>();
    strategyMap.put("keys", String.valueOf(params.get("inputValue")));
    // 封裝http請求數據
    UAVHttpMessage message = new UAVHttpMessage();
    message.putRequest("body", JSONHelper.toString(strategyMap));
    message.setIntent("strategy.query");

    NoitifyStrategyQuery callback = new NoitifyStrategyQuery();
    callback.setResponse(response);
    callback.setPageindex(pageindex);
    callback.setPagesize(pagesize);

    doHttpPost("uav.app.godeye.notify.strategy.http.addr", "/rtntf/oper", message, callback);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:24,代碼來源:GodEyeRestService.java

示例13: noitifyStrategyGet

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@POST
@Path("notify/get/stgy/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyStrategyGet(String data, @Suspended AsyncResponse response) throws Exception {

    Map<String, String> strategyMap = new HashMap<String, String>();
    strategyMap.put("keys", data);
    // 封裝http請求數據
    UAVHttpMessage message = new UAVHttpMessage();
    message.putRequest("body", JSONHelper.toString(strategyMap));
    message.setIntent("strategy.query");

    NoitifyStrategyGetCB callback = new NoitifyStrategyGetCB();
    callback.setResponse(response);
    doHttpPost("uav.app.godeye.notify.strategy.http.addr", "/rtntf/oper", message, callback);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:17,代碼來源:GodEyeRestService.java

示例14: noitifyStrategyRemove

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@POST
@Path("notify/del/stgy/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyStrategyRemove(String data, @Suspended AsyncResponse response) throws Exception {

    // 封裝http請求數據
    UAVHttpMessage message = new UAVHttpMessage();
    message.putRequest("body", data);
    message.setIntent("strategy.remove");

    NoitifyStrategyRemoveCB callback = new NoitifyStrategyRemoveCB();
    callback.setResponse(response);
    callback.setData(data);

    doHttpPost("uav.app.godeye.notify.strategy.http.addr", "/rtntf/oper", message, callback);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:17,代碼來源:GodEyeRestService.java

示例15: groupFilterRemove

import javax.ws.rs.container.AsyncResponse; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@POST
@Path("filter/group/remove")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void groupFilterRemove(String data, @Suspended AsyncResponse response) {

    Map<String, Object> param = JSONHelper.toObject(data, Map.class);
    String emailListStr = String.valueOf(param.get("emailListName"));
    String resultMsg = "{\"code\":\"00\",\"msg\":\"刪除成功\"}";

    Map<String, String> esistsMap = cm.getHash(godeyeFilterGroupCacheRegion, godeyeFilterGroupCacheRegionKey,
            emailListStr);
    if (esistsMap.get(emailListStr) != null) {
        cm.delHash(godeyeFilterGroupCacheRegion, godeyeFilterGroupCacheRegionKey, emailListStr);
    }
    else {
        resultMsg = "{\"code\":\"01\",\"msg\":\"郵箱組不存在\"}";
    }

    response.resume(resultMsg);
}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:22,代碼來源:GodEyeRestService.java


注:本文中的javax.ws.rs.container.AsyncResponse類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。