本文整理匯總了Java中javax.ws.rs.container.AsyncResponse.resume方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncResponse.resume方法的具體用法?Java AsyncResponse.resume怎麽用?Java AsyncResponse.resume使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ws.rs.container.AsyncResponse
的用法示例。
在下文中一共展示了AsyncResponse.resume方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: 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();
}
}
示例3: 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);
}
示例4: asyncLocalSpan
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
/**
* Async endpoint which creates local span.
* @param asyncResponse holds state of the asynchronous processing
*/
@GET
@Path(REST_ASYNC_LOCAL_SPAN)
@Produces(MediaType.TEXT_PLAIN)
public void asyncLocalSpan(@Suspended final AsyncResponse asyncResponse) {
finishChildSpan(startChildSpan(REST_LOCAL_SPAN));
asyncResponse.resume(Response.ok().build());
}
示例5: groupFilterEdit
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@POST
@Path("filter/group/edit")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void groupFilterEdit(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) {
Map<String, Object> old = JSONHelper.toObject(esistsMap.get(emailListStr), Map.class);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String timeStr = simpleDateFormat.format(new Date());
HttpSession session = request.getSession(false);
String user = "";
if (session != null) {
user = String.valueOf(session.getAttribute("apphub.gui.session.login.user.id"));
}
Map<String, Object> saveInfo = new HashMap<String, Object>();
saveInfo.put("emailListName", emailListStr);
saveInfo.put("groupList", param.get("groupList"));
saveInfo.put("createTime", old.get("createTime"));
saveInfo.put("operationTime", timeStr);
saveInfo.put("operationUser", user);
saveInfo.put("state", old.get("state"));
cm.delHash(godeyeFilterGroupCacheRegion, godeyeFilterGroupCacheRegionKey, emailListStr);
cm.putHash(godeyeFilterGroupCacheRegion, godeyeFilterGroupCacheRegionKey, emailListStr,
JSONHelper.toString(saveInfo));
}
response.resume(resultMsg);
}
示例6: suspend
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
@ApiOperation(value = "displays hello world after 2 seconds")
@GET
@Path("/suspend")
@Produces(MediaType.TEXT_PLAIN)
public void suspend(@Suspended final AsyncResponse asyncResponse) throws InterruptedException {
Thread.sleep(2000);
asyncResponse.resume(Response.ok("hello").build());
}
示例7: upload
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
@ApiOperation(value = "upload a file")
@POST
@Path("/upload")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public void upload(
final MultipartFormDataInput input,
@Suspended final AsyncResponse asyncResponse) throws IOException {
final JsonObject json = new JsonObject();
final Map<String, List<InputPart>> uploadForm = input.getFormDataMap();
final List<InputPart> inputParts = uploadForm.get("uploadedFile");
for (final InputPart inputPart : inputParts) {
final MultivaluedMap<String, String> header = inputPart.getHeaders();
final String fileName = getFileName(header);
//fromJson the uploaded file to inputstream
final InputStream inputStream = inputPart.getBody(InputStream.class, null);
int c = 0;
while (inputStream.read() != -1) {
++c;
}
json.add(fileName, new JsonPrimitive(c));
}
asyncResponse.resume(json);
}
示例8: suspend
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
@ApiOperation(value = "displays hello world after a given amount of seconds seconds")
@GET
@Path("/suspend/{seconds}")
@Produces(MediaType.TEXT_PLAIN)
public void suspend(@Suspended final AsyncResponse asyncResponse,
@PathParam("seconds") final int seconds) throws InterruptedException {
Thread.sleep(seconds * 1000L);
asyncResponse.resume(Response.ok("hello").build());
}
示例9: loadUserManageInfo
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
/**
* 獲取主頁用戶管理信息
*
* @return
*/
@GET
@Path("loadUserManageInfo")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void loadUserManageInfo(@Suspended AsyncResponse response) {
String result = "";
String userGroup = String
.valueOf(request.getSession(false).getAttribute("apphub.gui.session.login.user.group"));
Map<String, String> manageGroup = cm.getHashAll("apphub.gui.cache", "manage.group");
// 授權匹配
if (manageGroup.containsKey(userGroup)) {
Map<String, String> userManageInfo = new HashMap<String, String>();
String[] userManAppids = manageGroup.get(userGroup).split(",");
for (String appid : userManAppids) {
Map<String, String> appinfo = cm.getHash("apphub.gui.cache", "manage.app", appid);
userManageInfo.putAll(appinfo);
}
result = JSONHelper.toString(userManageInfo);
}
logger.info(this, "\r\nloadUserManageInfo\r\nuserGroup:" + userGroup + "\r\nmanageGroup:" + manageGroup
+ " \r\nresult:" + result);
response.resume(result);
}
示例10: createDashboards
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
public void createDashboards(String configString, String contextPath, HttpServletRequest request, CacheManager cm,
AsyncResponse response) {
List<Map> configs = JSONHelper.toObjectArray(configString, Map.class);
Map<String, Object> valueObjNewMap = getValueObjNewMap(configs);
int countFailed = 0;
List<String> listFailed = new ArrayList<String>();
for (String appgroupName : valueObjNewMap.keySet()) {
String orgId = getOrCreateOrgId(contextPath, appgroupName);
Map<String, List> appidNewMap = (Map) valueObjNewMap.get(appgroupName);
for (Map.Entry<String, List> entry : appidNewMap.entrySet()) {
boolean createFd = callGrafanaDashBoardCreate(entry, request, contextPath, cm, appgroupName, orgId);
if (createFd) {
countFailed++;
String strFailed = appgroupName + "___" + entry.getKey();
listFailed.add(strFailed);
}
}
}
Map<String, String> resultMap = new HashMap<String, String>();
String msgFailed = JSONHelper.toString(listFailed);
String msgString = "有" + countFailed + "個dashboard創建失敗";
resultMap.put("code", "00");
resultMap.put("msg", msgString);
resultMap.put("data", msgFailed);
String resultMsg = JSONHelper.toString(resultMap);
response.resume(resultMsg);
}
示例11: deleteDashboard
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void deleteDashboard(String data, CacheManager cm, final AsyncResponse response) {
Map<String, String> dataMap = JSONHelper.toObject(data, Map.class);
String orgName = dataMap.get("appgroup");
String dashboardName = dataMap.get("appid");
String orgGroupKey = orgName + "___" + dashboardName;
Map<String, String> orgIdMap = getRetCodeAndOrgId(orgName);
String resultMsg = "{\"code\":\"00\",\"msg\":\"該dashboard所屬的org不存在,僅刪除配置信息\"}";
if (orgIdMap.get("retCode").equals("404")) {
cm.delHash(STORE_REGION_GODCOMPASSCACHE, STORE_KEY_GRAFANACONFIG, orgGroupKey);
if (response != null) {
response.resume(resultMsg);
}
}
else if (orgIdMap.get("retCode").equals("200")) {
Map<String, String> deleteHeader = new HashMap<String, String>();
deleteHeader.put("X-Grafana-Org-Id", orgIdMap.get("orgId"));
HttpResponse resDel = grafanaClient.doHttp("delete", "/api/dashboards/db/" + dashboardName.toLowerCase(),
null, deleteHeader, null);
if (resDel.getStatusLine().getStatusCode() == 200) {
resultMsg = "{\"code\":\"00\",\"msg\":\"刪除dashboard成功\"}";
cm.delHash(STORE_REGION_GODCOMPASSCACHE, STORE_KEY_GRAFANACONFIG, orgGroupKey);
}
else if (resDel.getStatusLine().getStatusCode() == 404) {
resultMsg = "{\"code\":\"00\",\"msg\":\"該dashboard不存在,僅刪除配置信息\"}";
cm.delHash(STORE_REGION_GODCOMPASSCACHE, STORE_KEY_GRAFANACONFIG, orgGroupKey);
}
if (response != null) {
response.resume(resultMsg);
}
}
}
示例12: groupFilterQuery
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
@GET
@Path("filter/group/query")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void groupFilterQuery(@Suspended AsyncResponse response) {
Map<String, String> resultMap = cm.getHashAll(godeyeFilterGroupCacheRegion, godeyeFilterGroupCacheRegionKey);
response.resume(JSONHelper.toString(resultMap));
}
示例13: loadAppProfileList
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
/**
* 應用服務監控:全網應用Profile SnapShot
*
* @return
*/
@GET
@Path("profile/q/cache")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void loadAppProfileList(@QueryParam("fkey") String fkey, @QueryParam("fvalue") String fvalue,
@Suspended AsyncResponse response) {
UAVHttpMessage message = new UAVHttpMessage();
message.setIntent("profile");
if (StringHelper.isEmpty(fkey) || StringHelper.isEmpty(fvalue)) {
String groups = getUserGroupsByFilter(request);
if ("NOMAPPING".equals(groups)) {
response.resume("{\"rs\":\"{}\"}");
}
else if ("ALL".equals(groups)) {
loadAppProfileListFromHttp(message, response);
}
else {
message.putRequest("fkey", "appgroup");
message.putRequest("fvalue", groups);
loadAppProfileListFromHttp(message, response);
}
}
else {
message.putRequest("fkey", fkey);
message.putRequest("fvalue", fvalue);
loadAppProfileListFromHttp(message, response);
}
}
示例14: loadUavNetworkInfo
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
/**
* 應用容器監控+UAV節點信息
*
* @return
*/
@GET
@Path("node/q/cache")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void loadUavNetworkInfo(@QueryParam("fkey") String fkey, @QueryParam("fvalue") String fvalue,
@Suspended AsyncResponse response) {
UAVHttpMessage message = new UAVHttpMessage();
message.setIntent("node");
if (StringHelper.isEmpty(fkey) || StringHelper.isEmpty(fvalue)) {
String groups = getUserGroupsByFilter(request);
if ("NOMAPPING".equals(groups)) {
response.resume("{\"rs\":\"{}\"}");
}
else if ("ALL".equals(groups)) {
loadUavNetworkInfoFromHttp(message, response);
}
else {
message.putRequest("fkey", "group");
message.putRequest("fvalue", groups);
loadUavNetworkInfoFromHttp(message, response);
}
}
else {
message.putRequest("fkey", fkey);
message.putRequest("fvalue", fvalue);
loadUavNetworkInfoFromHttp(message, response);
}
}
示例15: ping
import javax.ws.rs.container.AsyncResponse; //導入方法依賴的package包/類
@GET
public void ping(@Suspended AsyncResponse response) {
response.setTimeout(1, TimeUnit.NANOSECONDS);
System.out.println(".");
response.resume("Java EE 8 is crazy fast!");
}