What are Interceptors in Java EE?

Interceptors are used to implement cross-cutting concerns, such as logging, auditing, and security, from the business logic. In Java EE 5, Interceptors were allowed only on EJBs. In Java EE 6, Interceptors became a new specification of its own, abstracted at a higher level so that it can be more generically applied to a broader … Read more

Spring HandlerInterceptor vs Servlet Filters

The org.springframework.web.servlet.HanderInterceptor Interface JavaDoc itself has a two paragraphs that discuss this question: HandlerInterceptor is basically similar to a Servlet 2.3 Filter, but in contrast to the latter it just allows custom pre-processing with the option of prohibiting the execution of the handler itself, and custom post-processing. Filters are more powerful, for example they allow … Read more

Angular 4.3 HttpClient : Intercept response

I recently made an HttpInterceptor in order to resolve cyclical references in some JSON on the client side, essentially replacing any object with a $ref property with the object in the JSON that has a matching $id property. (This is the output you get if Json.Net is configured with PreserveReferencesHandling.Objects and ReferenceLoopHandling.Ignore). The answers here … Read more

Add multiple HTTP Interceptors to Angular Application

Http doesn’t allow to have more than one custom implementation. But as @estus mentioned the Angular team has added a new HttpClient service recently (release 4.3) which supports multiple interceptors concept. You don’t need to extend the HttpClient as you do with the old Http. You can provide an implementation for HTTP_INTERCEPTORS instead which can … Read more

How to intercept all AJAX requests made by different JS libraries

This type of function hooking is perfectly safe and is done regularly on other methods for other reasons. And, the only performance impact is really only one extra function call for each .open() plus whatever code you execute yourself which is probably immaterial when a networking call is involved. In IE, this won’t catch any … Read more