Reputation: 1953
I want to execute some code before any request matching :
@PreMatching
public class PreMatchingFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
System.out.println("I am here");
}
}
Unfortunately, whatever the request, the console never write the sysout message. Did I miss something ?
Upvotes: 0
Views: 661
Reputation: 209052
You still need to explicitly register it or have it scanned for with the @Provider
annotation. @PreMatching
isn't a replacement for @Provider
.
If you are package scanning for resource classes (@Path
annotated classes), then the @Provider
annotation will also be picked up if it is in a package or sub-packages listed in the package(s) to scan.
Upvotes: 2