protected void createInterceptorsAndInstance ( CallbackContextHelper contextHelper ) throws InvocationTargetException { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "createInterceptorsAndInstance : " + contextHelper ) ; BeanMetaData bmd = home . beanMetaData ; ManagedObjectFactory < ? > managedObjectFactory = bmd . ivEnterpriseBeanFactory ; if ( managedObjectFactory != null ) { try { ivEjbManagedObjectContext = managedObjectFactory . createContext ( ) ; } catch ( ManagedObjectException e ) { throw ExceptionUtil . EJBException ( "AroundConstruct interceptors for the " + bmd . enterpriseBeanName + " bean in the " + bmd . _moduleMetaData . ivName + " module in the " + bmd . _moduleMetaData . ivAppName + " application resulted in an exception being thrown from the ManagedObjectFactory.createContext() method" , e ) ; } } InterceptorMetaData imd = bmd . ivInterceptorMetaData ; if ( imd != null && ! bmd . managedObjectManagesInjectionAndInterceptors ) { createInterceptors ( imd ) ; if ( bmd . ivCallbackKind == CallbackKind . InvocationContext ) { InterceptorProxy [ ] aroundConstructProxies = imd . ivAroundConstructInterceptors ; if ( aroundConstructProxies != null ) { InvocationContextImpl < ? > context = callAroundConstructInterceptors ( aroundConstructProxies , contextHelper ) ; // If InvocationContext.proceed() was not called, the bean's // constructor was never called and ivEjbInstance will be null. if ( ivEjbInstance == null ) { // If the interceptor swallowed an exception from // proceed(), we re-throw it now to give a better // error message than a generic "failed to create". if ( context . ivAroundConstructException != null ) { Throwable t = context . ivAroundConstructException . getCause ( ) ; if ( t == null ) { // Don't lose the application exception if it doesn't happen to be nested t = context . ivAroundConstructException ; } throw ExceptionUtil . EJBException ( "AroundConstruct interceptors for the " + bmd . enterpriseBeanName + " bean in the " + bmd . _moduleMetaData . ivName + " module in the " + bmd . _moduleMetaData . ivAppName + " application resulted in an exception being thrown from the constructor of the " + bmd . enterpriseBeanClassName + " class." , t ) ; } // Otherwise, the interceptor must not have called proceed(). throw new EJBException ( "AroundConstruct interceptors for the " + bmd . enterpriseBeanName + " bean in the " + bmd . _moduleMetaData . ivName + " module in the " + bmd . _moduleMetaData . ivAppName + " application did not call InvocationContext.proceed()" ) ; } } } } // If no @AroundConstructor interceptor, create the instance now. if ( ivEjbInstance == null ) { createInstance ( ) ; } if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "createInterceptorsAndInstance" ) ; }
Method for creating interceptors prior to the creation of the bean instance in case