Removing specific CDI managed beans from session

CDI 1.1 introduced an AlterableContext interface with a destroy(Bean<T>) method.

Get the session context via beanManager.getContext(SessionScoped.class), downcast to AlterableContext and then invoke destroy() with the appropriate bean type.

Leave a Comment