@Override public void start(final StartContext context) throws StartException { final ClassLoader cl = SecurityActions.getContextClassLoader(); try { SecurityActions.setContextClassLoader(classLoader); final BeanManagerImpl beanManager = this.beanManager.getValue(); for (final Class<?> interceptor : interceptorClasses) { interceptorInjections.put( interceptor, WeldEEInjection.createWeldEEInjection(interceptor, null, beanManager)); } if (ejbName != null) { EjbDescriptor<Object> descriptor = beanManager.getEjbDescriptor(ejbName); bean = beanManager.getBean(descriptor); } injectionTarget = WeldEEInjection.createWeldEEInjection(componentClass, bean, beanManager); } finally { SecurityActions.setContextClassLoader(cl); } }
@Override public ManagedReference getReference() { final BeanManagerImpl beanManager = this.beanManager.getValue(); final CreationalContext<?> ctx; if (bean == null) { ctx = beanManager.createCreationalContext(null); } else { ctx = beanManager.createCreationalContext(bean); } final Object instance = injectionTarget.produce(ctx); return new WeldManagedReference(ctx, instance, injectionTarget, interceptorInjections); }