Is it possible to destroy a CDI scope?

Posted by Matt Ball on Stack Overflow See other posts from Stack Overflow or by Matt Ball
Published on 2011-06-23T19:16:21Z Indexed on 2011/06/24 16:22 UTC
Read the original article Hit count: 278

Filed under:
|
|
|

I'm working on a Java EE application, primarily JAX-RS with a JSF admin console, that uses CDI/Weld for dependency injection with @ApplicationScoped objects. Minor debugging issues aside, CDI has worked beautifully for this project.

Now I need some very coarse-grained control over CDI-injected object lifecycles. I need the ability to:

  • Remove an injected object from the application context, or
  • Destroy/delete/clear/reset/remove the entire application context, or
  • Define my own @ScopeType and implementing Context in which I could provide methods to perform one of the two above tasks.

I'm fully aware that this is across, if not against, the grain of CDI and dependency injection in general. I just want to know

  • Is this remotely possible?
  • If yes, what is the easiest/simplest/quickest/foolproofiest way to get the job done?

© Stack Overflow or respective owner

Related posts about java

Related posts about java-ee