Step 1 of 4: Choose Issues

Cancel

Key Summary Description
JBIDE-17575

JBIDE-16329 Support JAX-RS annotations on bean properties

@PathParam and a-like annotations can also be applied on class bean properties. These annotations should be discovered and validation should take those elements into account.

Until now we only supported fields/

JBIDE-17391

JBIDE-16329 Provide JAX-RS Resource fields type validation

From JAX-RS 1.1 spec (chap 3.2):

1. Primitive types.
2. Types that have a constructor that accepts a single String argument.
3. Types that have a static method named valueOf or fromString with a single String argument that return an instance of the type. If both methods are present then valueOf MUST be used unless the type is an enum in which case fromString MUST be used.
4. List<T>, Set<T>, or SortedSet<T>, where T satisfies 2 or 3 above.

JAX-RS 2.0 introduced the notion of ParamConverterProvider:

Valid parameter types for each of the above annotations are listed in the corresponding Javadoc, however in general (excluding @Context) the following types are supported:
1. Types for which a ParamConverter is available via a registered ParamConverterProvider. See Javadoc for these classes for more information.
2. Primitive types.
3. Types that have a constructor that accepts a single String argument.
4. Types that have a static method named valueOf or fromString with a single String argument that return an instance of the type. If both methods are present then valueOf MUST be used unless the type is an enum in which case fromString MUST be used1.
5. List<T>, Set<T>, or SortedSet<T>, where T satisfies 3 or 4 above.

JBIDE-16829

JBIDE-16329 Provide hyperlink navigation between Filter/Interceptors and other resources

When a Filter or Interceptor is annotated with a user-defined name binding annotation (ie, an annotation itself annotated with @NameBinding), then some hyperlink navigation on this annotation should let the user navigate to the associated resources/resource methods/application that have the same user-defined annotation.

Eg:

@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(value = RetentionPolicy.RUNTIME)
@NameBinding
public @interface CustomInterceptorBinding {

}

and

@ApplicationPath("/app")
@CustomInterceptorBinding 
public class RestApplication extends Application {

}

and

@Provider
@CustomInterceptorBinding
public class CustomResponseFilterWithBinding implements ContainerResponseFilter {

	@Override
	public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
			throws IOException {
		responseContext.getHeaders().add("Cache-Control", "no-cache");
	}
	
}

In that case, ctrl (or cmd) + click on CustomInterceptorBinding should allow for navigation between all those 3 elements

JBIDE-16826

JBIDE-16329 Provide support for new @ConstrainedTo JAX-RS Annotation

See JAX-RS Spec Appendix A (p66):

ConstrainedTo

Can be used to restrict the applicability of a provider to just the Client API or just the Server API. If omitted, a provider can be used in either context.

JBIDE-16825

JBIDE-16329 Provide support for new @BeanParam JAX-RS Annotation

See JAX-RS Spec Appendix A (p66):

BeanParam

Can be used to inject a user-defined bean whose fields and properties may be annotated with JAX-RS param annotations.

For example:

public class MyBeanParam {
    @PathParam("p")
    private String pathParam;
 
    @MatrixParam("m")
    @Encoded
    @DefaultValue("default")
    private String matrixParam;
 
    @HeaderParam("header")
    private String headerParam;
 
    private String queryParam;
 
    public MyBeanParam(@QueryParam("q") String queryParam) {
        this.queryParam = queryParam;
    }
 
    public String getPathParam() {
        return pathParam;
    }
    ...
}

then

@POST
public void post(@BeanParam MyBeanParam beanParam, String entity) {
    final String pathParam = beanParam.getPathParam(); // contains injected path parameter "p"
    ...
}
JBIDE-16824

JBIDE-16329 Provide support for new @NameBinding JAX-RS Annotation

See JAX-RS Spec Appendix A (p66):

NameBinding

Meta-annotation to create annotations for binding filters or interceptors to resource methods and applications. Name binding is only supported as part of the Server API.

JBIDE-16823

JBIDE-16329 Provide support for new @Suspended JAX-RS Annotation

See JAX-RS Spec Appendix A (p66):

Suspended

Indicates that a resource method is asynchronous. I.e., that it does not produce a response upon returning. JAX-RS implementations will suspend the incoming connection until a response becomes available.

JBIDE-16763

JBIDE-16329 Add support for JAX-RS ParamConverterProvider

From the spec:

Valid parameter types for each of the above annotations are listed in the corresponding Javadoc, however in general (excluding @Context) the following types are supported:
1. Types for which a ParamConverter is available via a registered ParamConverterProvider. See Javadoc for these classes for more information.
2. Primitive types.
3. Types that have a constructor that accepts a single String argument.
4. Types that have a static method named valueOf or fromString with a single String argument that return an instance of the type. If both methods are present then valueOf MUST be used unless the type is an enum in which case fromString MUST be used1.
5. List<T>, Set<T>, or SortedSet<T>, where T satisfies 3 or 4 above.

JBIDE-16754

JBIDE-16329 Provide support for new @PreMatching JAX-RS Annotation

See JAX-RS Spec Appendix A (p66):

PreMatching

Global binding annotation that can be applied to a container filter to indicate that it should be applied globally and before the resource method is matched.

JBIDE-16753

JBIDE-16329 Provide support for server-side Filters and Interceptors

(See JAX-RS 2.0 spec., Chap.6)

Filters and Interceptors interfaces

As far as server-side JAX-RS is concerned, 4 types of interceptors should be support in the tooling:

public interface ContainerRequestFilter {
    void filter(ContainerRequestContext requestContext) throws IOException;
}
public interface ContainerResponseFilter {
    void filter(ContainerRequestContext requestContext,
        ContainerResponseContext responseContext) throws IOException;
}

public interface ReaderInterceptor {
    Object aroundReadFrom(ReaderInterceptorContext context)
throws java.io.IOException, javax.ws.rs.WebApplicationException;

public interface WriterInterceptor {
    void aroundWriteTo(WriterInterceptorContext context)
        throws java.io.IOException, javax.ws.rs.WebApplicationException;

User-defined Interceptors should implement one or more of those interfaces and should be annotated with @Provider to be automatically discovered. Without such annotation, they should be configured in the Application

Optionally, user-defined ContainerRequestFilter can also be annotated with @PreMatching to indicate that it should be executed upon receiving a client request but before a resource method is matched

Binding

Global binding is the default type of binding. A filter or interceptor that has no annotations is assumed to be bound globally, i.e. it applies to all the resource methods in an application. Like any other provider, a filter or interceptor can be registered manually (e.g., via Application or Configuration) or be discovered automatically. Note that for a filter or interceptor to be automatically discovered it MUST be annotated with @Provider.

A filter or interceptor can be associated with a resource class or method by declaring a new binding annota- tion à la CDI. These annotations are declared using the JAX-RS meta-annotation @NameBinding and are used to decorate both the filter (or interceptor) and the resource method or resource class.

For example:

@Provider
@Logged
class LoggingFilter implements ContainerRequestFilter,
                                  ContainerResponseFilter {
    ...
}

@Path("/")
public class MyResourceClass {

    @Logged
    @GET
    @Produces("text/plain")
    @Path("{name}")
    public String hello(@PathParam("name") String name) {
      ...
    }
}

@NameBinding
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Logged { }

In this particular case, the binding annotation should be detected (same way as HTTP Methods) and the tooling should provide a way to navigate between the resource class or resource method and the associated/bound provider.

Binding annotations can also be applied to resource classes and Application subclasses. Binding annota- tions that decorate resource classes apply to all resource methods defined in them.

In that case,

JBIDE-16752

JBIDE-16329 Provide validation for JAX-RS 2.0 Interceptors and Filters (with Name Binding)

Interceptor bindings

A filter or interceptor class can be decorated with multiple binding annotations. In this case, in accordance with the semantics described in CDI, all those annotations must be present in the resource class or method for the binding to be established. For example, if LoggingFilter is defined as follows:

@Provider
@Logged @Verbose
class LoggingFilter implements ContainerRequestFilter,
                                  ContainerResponseFilter {
...
}

then method hello above must be annotated with both @Logged and @Verbose for the binding to be in effect.

Binding annotations can also be applied to resource classes and Application subclasses. Binding annotations that decorate resource classes apply to all resource methods defined in them.

This means that validation should not report an error if binding annotation are found on Filters and Resource classes, Resource methods and the Application subclass (if defined)

JBIDE-15592

JBIDE-16329 Provide JAX-RS Parameters type validation

From JAX-RS 1.1 spec (chap 3.2):

1. Primitive types.
2. Types that have a constructor that accepts a single String argument.
3. Types that have a static method named valueOf or fromString with a single String argument that return an instance of the type. If both methods are present then valueOf MUST be used unless the type is an enum in which case fromString MUST be used.
4. List<T>, Set<T>, or SortedSet<T>, where T satisfies 2 or 3 above.

JAX-RS 2.0 introduced the notion of ParamConverterProvider:

Valid parameter types for each of the above annotations are listed in the corresponding Javadoc, however in general (excluding @Context) the following types are supported:
1. Types for which a ParamConverter is available via a registered ParamConverterProvider. See Javadoc for these classes for more information.
2. Primitive types.
3. Types that have a constructor that accepts a single String argument.
4. Types that have a static method named valueOf or fromString with a single String argument that return an instance of the type. If both methods are present then valueOf MUST be used unless the type is an enum in which case fromString MUST be used1.
5. List<T>, Set<T>, or SortedSet<T>, where T satisfies 3 or 4 above.

Cancel