@Override protected void afterDestroyInstance(final Object instance) { if (instance instanceof Proxy) { final Proxy<?> proxy = (Proxy<?>) instance; final Object rawInstance = proxy.unwrap(); instances.values().remove(rawInstance); proxy.clearInstance(); } else { throw new IllegalArgumentException("Cannot destroy ApplicationScoped bean without reference to proxy."); } } }