Search in sources :

Example 1 with ContextOperation

use of ee.jakarta.tck.ws.rs.api.rs.ext.interceptor.ContextOperation in project jaxrs-api by eclipse-ee4j.

the class Resource method genericResponse.

@GET
@Path("{id}")
public Response genericResponse(@PathParam("id") String path) {
    ContextOperation op = ContextOperation.valueOf(path.toUpperCase());
    ResponseBuilder builder = createResponseBuilderWithHeader(op);
    switch(op) {
        case GETANNOTATIONS:
            Annotation[] annotations = ContextOperation.class.getAnnotations();
            builder = builder.entity(TemplateInterceptorBody.ENTITY, annotations);
            break;
        case GETMEDIATYPE:
            builder = builder.type(MediaType.APPLICATION_JSON_TYPE);
            break;
        case SETTYPE:
            ByteArrayInputStream bais = new ByteArrayInputStream(TemplateInterceptorBody.ENTITY.getBytes());
            Reader reader = new InputStreamReader(bais);
            builder = builder.entity(reader);
            break;
        default:
            break;
    }
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ContextOperation(ee.jakarta.tck.ws.rs.api.rs.ext.interceptor.ContextOperation) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Annotation(java.lang.annotation.Annotation) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Aggregations

ContextOperation (ee.jakarta.tck.ws.rs.api.rs.ext.interceptor.ContextOperation)1 GET (jakarta.ws.rs.GET)1 Path (jakarta.ws.rs.Path)1 Response (jakarta.ws.rs.core.Response)1 ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 Annotation (java.lang.annotation.Annotation)1