@ Override protected < T > T instantiateClass ( Class < T > clazz ) throws Throwable { // Get the current BeanManager for this module. If one doesn't exist it is because // the module isn't CDI enabled and we fall back to the original behavior. ManagedObject < T > mo = null ; if ( releasableFactory != null ) { mo = releasableFactory . createValidationReleasable ( clazz ) ; } if ( mo != null ) { if ( releasables == null ) { releasables = new LinkedList < ValidationReleasable < ? > > ( ) ; } // Save off the context under which the class was created as a CDI managed // bean so it can be cleaned up upon stopping the module. //releasables.add(mo); return mo . getObject ( ) ; } else { return super . instantiateClass ( clazz ) ; } }
Override the base implementation so that when a class is instantiated it is done so as a CDI managed bean .