public <T> Map<Interceptor<?>, Object> createInterceptorInstances(BeanInterceptorInfo interceptorInfo, CreationalContextImpl<T> creationalContextImpl) { Map<Interceptor<?>,Object> interceptorInstances = new HashMap<>(); if (interceptorInfo != null) { // apply interceptorInfo // create EJB-style interceptors for (Interceptor interceptorBean : interceptorInfo.getEjbInterceptors()) { creationalContextImpl.putContextual(interceptorBean); interceptorInstances.put(interceptorBean, interceptorBean.create(creationalContextImpl)); } // create CDI-style interceptors for (Interceptor interceptorBean : interceptorInfo.getCdiInterceptors()) { creationalContextImpl.putContextual(interceptorBean); interceptorInstances.put(interceptorBean, interceptorBean.create(creationalContextImpl)); } for (Interceptor interceptorBean : interceptorInfo.getConstructorCdiInterceptors()) { creationalContextImpl.putContextual(interceptorBean); interceptorInstances.put(interceptorBean, interceptorBean.create(creationalContextImpl)); } } return interceptorInstances; }
public T createNewPojo(final CreationalContext<T> creationalContext) { final CreationalContextImpl<T> ccImpl = CreationalContextImpl.class.cast(creationalContext); // super.produce(cc) will not work since we need the unproxied instance - decorator case final Map<javax.enterprise.inject.spi.Interceptor<?>, Object> interceptorInstances = super.createInterceptorInstances(ccImpl); final InterceptorResolutionService.BeanInterceptorInfo interceptorInfo = super.getInterceptorInfo(); if (interceptorInfo != null) { final Map<Constructor<?>, InterceptorResolutionService.BusinessMethodInterceptorInfo> constructorInterceptorInfos = interceptorInfo.getConstructorInterceptorInfos(); if (!constructorInterceptorInfos.isEmpty()) { // were missed by OWB final javax.enterprise.inject.spi.Interceptor<?>[] ejbInterceptors = constructorInterceptorInfos.values().iterator().next().getEjbInterceptors(); if (null != ejbInterceptors) { for (final javax.enterprise.inject.spi.Interceptor interceptorBean : ejbInterceptors) { if (!interceptorInstances.containsKey(interceptorBean)) { ccImpl.putContextual(interceptorBean); interceptorInstances.put(interceptorBean, interceptorBean.create(ccImpl)); } } } } } final T produce = super.produce(interceptorInstances, ccImpl); if (produce == null) { // user didnt call ic.proceed() in @AroundConstruct return super.newInstance(ccImpl); } return (T) produce; }
interceptorInstance = interceptor.create(creationalContext);