public ManagedObject injectAndPostConstruct ( final Object target ) throws InjectionException { final String METHOD_NAME = "injectAndPostConstruct" ; if ( TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { logger . entering ( CLASS_NAME , METHOD_NAME , target ) ; } // PI30335: split inject logic from injectAndPostConstruct ManagedObject r = inject ( target ) ; // after injection then PostConstruct annotated methods on the host object needs to be invoked. Throwable t = this . invokeAnnotTypeOnObjectAndHierarchy ( target , ANNOT_TYPE . POST_CONSTRUCT ) ; if ( null != t ) { // log exception - and process InjectionExceptions so the error will be returned to the client as an error. if ( TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { logger . logp ( Level . FINE , CLASS_NAME , METHOD_NAME , "Exception caught during post construct processing: " + t ) ; } if ( t instanceof InjectionException ) { InjectionException ie = ( InjectionException ) t ; throw ie ; } else { // According to spec, can't proceed if invoking PostContruct(s) threw exceptions RuntimeException re = new RuntimeException ( t ) ; throw re ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { logger . exiting ( CLASS_NAME , METHOD_NAME , r ) ; } return r ; }
This method injects the target object then immediately performs PostConstruct operations