0

I have some interceptors that are used for debugging (performance, logging of method usage, etc) our JavaEE applications.

In production system I don't want those interceptors to be enabled by default but I want to have the possibility to enable them at runtime (=without a re-deploy). Is there any portable way to do this independet of the CDI implementation? If not, is there any WELD specific way to do this?

My only solution would be a global flag that must be used by those interceptors but that still has the overhead of entering the interceptor and evaluating the flag just for nothing.

grubi
  • 155
  • 2
  • 16

1 Answers1

2

This is one of the things that CDI/Weld do when they bootstrap. E.g. for an interceptor you effectively need to create a "wrapping proxy" which will handle whatever extra work you have on interceptor. Therefore, the answer is - no, you cannot do that at runtime.

However, your approach with kind of a flag is perfectly fine. The overhead of having an interceptor proxy (which does nothing) is really so tiny you should not notice. I would probably go with this approach.

Siliarus
  • 6,393
  • 1
  • 14
  • 30