javax.ws.rs.core.Context类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中javax.ws.rs.core.Context类的一些代码示例,展示了Context类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context类的具体详情如下:
包路径:javax.ws.rs.core.Context
类名称:Context

Context介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

@DELETE
@Path("{taskId}/results/{bufferId}")
@Produces(MediaType.APPLICATION_JSON)
public void abortResults(@PathParam("taskId") TaskId taskId, @PathParam("bufferId") OutputBufferId bufferId, @Context UriInfo uriInfo)
{
  requireNonNull(taskId, "taskId is null");
  requireNonNull(bufferId, "bufferId is null");
  taskManager.abortTaskResults(taskId, bufferId);
}

代码示例来源:origin: apache/incubator-druid

@POST
@Path("/stop")
public Response stop(@Context final HttpServletRequest req)
{
 authorizationCheck(req, Action.WRITE);
 stopGracefully();
 return Response.status(Response.Status.OK).build();
}

代码示例来源:origin: prestodb/presto

@GET
@Produces(MediaType.APPLICATION_JSON)
public List<TaskInfo> getAllTaskInfo(@Context UriInfo uriInfo)
{
  List<TaskInfo> allTaskInfo = taskManager.getAllTaskInfo();
  if (shouldSummarize(uriInfo)) {
    allTaskInfo = ImmutableList.copyOf(transform(allTaskInfo, TaskInfo::summarize));
  }
  return allTaskInfo;
}

代码示例来源:origin: apache/incubator-dubbo

@GET
  @Path("swagger")
  public Response getListingJson(@Context Application app, @Context ServletConfig sc,
                  @Context HttpHeaders headers, @Context UriInfo uriInfo) throws JsonProcessingException;
}

代码示例来源:origin: apache/incubator-druid

@POST
@Path("/offsets/end")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response setEndOffsetsHTTP(
  Map<Integer, Long> offsets,
  @Context final HttpServletRequest req
) throws InterruptedException
{
 authorizationCheck(req, Action.WRITE);
 return setEndOffsets(offsets);
}

代码示例来源:origin: apache/storm

@POST
@Path("/{func}") 
public String post(@PathParam("func") String func, String args, @Context HttpServletRequest request) throws Exception {
  meterHttpRequests.mark();
  return responseDuration.time(() -> drpc.executeBlocking(func, args));
}

代码示例来源:origin: prestodb/presto

@GET
  public Response redirectIndexHtml(
      @HeaderParam(X_FORWARDED_PROTO) String proto,
      @Context UriInfo uriInfo)
  {
    if (isNullOrEmpty(proto)) {
      proto = uriInfo.getRequestUri().getScheme();
    }

    return Response.status(MOVED_PERMANENTLY)
        .location(uriInfo.getRequestUriBuilder().scheme(proto).path("/ui/").build())
        .build();
  }
}

代码示例来源:origin: Graylog2/graylog2-server

@GET
public Response root(@Context HttpHeaders httpHeaders) throws IOException {
  final String index = index(httpHeaders);
  return Response.ok(index, MediaType.TEXT_HTML_TYPE)
      .header(HttpHeaders.CONTENT_LENGTH, index.length())
      .build();
}

代码示例来源:origin: jersey/jersey

@Path("start")
@POST
public Response post(@DefaultValue("0") @QueryParam("testSources") int testSources, @Context Sse sse) {
  final Process process = new Process(testSources, sse);
  processes.put(process.getId(), process);
  Executors.newSingleThreadExecutor().execute(process);
  final URI processIdUri = UriBuilder.fromResource(DomainResource.class).path("process/{id}").build(process.getId());
  return Response.created(processIdUri).build();
}

代码示例来源:origin: Graylog2/graylog2-server

@GET
public Response getIndex(@Context ContainerRequest request, @Context HttpHeaders headers) {
  final URI originalLocation = request.getRequestUri();
  if (originalLocation.getPath().endsWith("/")) {
    return get(request, headers, originalLocation.getPath());
  }
  final URI redirect = UriBuilder.fromPath(originalLocation.getPath() + "/").build();
  return Response.temporaryRedirect(redirect).build();
}

代码示例来源:origin: apache/incubator-dubbo

@Service
public class DubboSwaggerApiListingResource extends BaseApiListingResource implements DubboSwaggerService {

  @Context
  ServletContext context;

  @Override
  public Response getListingJson(Application app, ServletConfig sc,
                  HttpHeaders headers, UriInfo uriInfo)  throws JsonProcessingException {
    Response response =  getListingJsonResponse(app, context, sc, headers, uriInfo);
    response.getHeaders().add("Access-Control-Allow-Origin", "*");
    response.getHeaders().add("Access-Control-Allow-Headers", "x-requested-with, ssi-token");
    response.getHeaders().add("Access-Control-Max-Age", "3600");
    response.getHeaders().add("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,OPTIONS");
    return response;
  }
}

代码示例来源:origin: com.sun.jersey/jersey-server

@Override
  public Injectable<Injectable> getInjectable(ComponentContext ic, Context a, Type c) {
    if (c instanceof ParameterizedType) {
      ParameterizedType pt = (ParameterizedType)c;
      if (pt.getRawType() == Injectable.class) {
        if (pt.getActualTypeArguments().length == 1) {
          final Injectable<?> i = injectableFactory.getInjectable(
              a.annotationType(),
              ic,
              a,
              pt.getActualTypeArguments()[0],
              ComponentScope.PERREQUEST_UNDEFINED_SINGLETON);
          if (i == null)
            return null;
          return new Injectable<Injectable>() {
            @Override
            public Injectable getValue() {
              return i;
            }
          };
        }
      }
    }
    return null;
  }
});

代码示例来源:origin: apache/incubator-druid

@Override
@POST
@Path("/stop")
public Response stop(@Context final HttpServletRequest req)
{
 authorizationCheck(req, Action.WRITE);
 stopGracefully();
 return Response.status(Response.Status.OK).build();
}

代码示例来源:origin: apache/incubator-druid

@GET
@ResourceFilters(StateResourceFilter.class)
@Produces(MediaType.APPLICATION_JSON)
public Status doGet(
  @Context final HttpServletRequest req
)
{
 return new Status(Initialization.getLoadedImplementations(DruidModule.class));
}

代码示例来源:origin: apache/incubator-dubbo

@GET
  @Path("swagger")
  public Response getListingJson(@Context Application app, @Context ServletConfig sc,
                  @Context HttpHeaders headers, @Context UriInfo uriInfo) throws JsonProcessingException;
}

代码示例来源:origin: apache/incubator-druid

@Path("/chat/{id}")
 public Object doTaskChat(@PathParam("id") String handlerId, @Context HttpHeaders headers)
 {
  if (taskId != null) {
   List<String> requestTaskId = headers.getRequestHeader(TASK_ID_HEADER);
   if (requestTaskId != null && !requestTaskId.contains(StringUtils.urlEncode(taskId))) {
    return null;
   }
  }

  final Optional<ChatHandler> handler = handlers.get(handlerId);

  if (handler.isPresent()) {
   return handler.get();
  }

  return null;
 }
}

代码示例来源:origin: apache/incubator-dubbo

@Service
public class DubboSwaggerApiListingResource extends BaseApiListingResource implements DubboSwaggerService {

  @Context
  ServletContext context;

  @Override
  public Response getListingJson(Application app, ServletConfig sc,
                  HttpHeaders headers, UriInfo uriInfo)  throws JsonProcessingException {
    Response response =  getListingJsonResponse(app, context, sc, headers, uriInfo);
    response.getHeaders().add("Access-Control-Allow-Origin", "*");
    response.getHeaders().add("Access-Control-Allow-Headers", "x-requested-with, ssi-token");
    response.getHeaders().add("Access-Control-Max-Age", "3600");
    response.getHeaders().add("Access-Control-Allow-Methods","GET,POST,PUT,DELETE,OPTIONS");
    return response;
  }
}

代码示例来源:origin: apache/incubator-druid

@GET
@Path("/runningTasks")
@Produces(MediaType.APPLICATION_JSON)
public Response getRunningTasks(
  @QueryParam("type") String taskType,
  @Context final HttpServletRequest req
)
{
 return getTasks("running", null, null, null, taskType, req);
}

代码示例来源:origin: apache/incubator-druid

@Override
@POST
@Path("/resume")
public Response resumeHTTP(@Context final HttpServletRequest req) throws InterruptedException
{
 authorizationCheck(req, Action.WRITE);
 resume();
 return Response.status(Response.Status.OK).build();
}

代码示例来源:origin: neo4j/neo4j

@GET
@Produces( MediaType.APPLICATION_JSON )
public Response getDiscoveryDocument( @Context UriInfo uriInfo )
{
  return outputFormat.ok(
      new DiscoveryRepresentation( new DiscoverableURIs.Builder( uris ).overrideAbsolutesFromRequest( uriInfo.getBaseUri() ).build() ) );
}

相关文章

微信公众号

最新文章

更多