AnnotatedType<X> rawAnnType = getRawAnnotatedType();
AnnotatedType<X> annType = getAnnotatedType();
AnnotatedType<X> extAnnType = createExternalAnnotatedType(annType, localApiList);
InjectManager moduleBeanManager = InjectManager.create();
ManagedBeanImpl<X> mBean
= new ManagedBeanImpl<X>(getInjectManager(), getAnnotatedType(), true);
mBean.introspect();
InjectionTarget<X> target = mBean.getInjectionTarget();
target = moduleBeanManager.processInjectionTarget(target, getRawAnnotatedType());
mBean.setInjectionTarget(target);
Class<?> baseApi = annType.getJavaClass();
Set<Type> apiList = new LinkedHashSet<Type>();
AnnotatedType<X> baseType = getLocalBean();
if (baseType != null) {
BaseType sourceApi = moduleBeanManager.createSourceBaseType(baseType.getBaseType());
apiList.addAll(sourceApi.getTypeClosure(moduleBeanManager));
}
if (localApiList != null) {
for (AnnotatedType<? super X> api : localApiList) {
baseApi = api.getJavaClass();
BaseType sourceApi = moduleBeanManager.createSourceBaseType(api.getJavaClass());
apiList.addAll(sourceApi.getTypeClosure(moduleBeanManager));
}
}
apiList.add(Object.class);
// ioc/024p
/*
if (remoteApiList != null) {
for (AnnotatedType<? super X> api : remoteApiList) {
if (baseApi == null)
baseApi = api.getJavaClass();
BaseType sourceApi = moduleBeanManager.createSourceBaseType(api.getJavaClass());
apiList.addAll(sourceApi.getTypeClosure(moduleBeanManager));
}
}
*/
if (baseApi == null)
throw new NullPointerException();
_bean = (Bean<X>) createBean(mBean, baseApi, apiList, extAnnType);
// CDI TCK requires the rawAnnType, not the processed one
ProcessSessionBeanImpl process
= new ProcessSessionBeanImpl(moduleBeanManager,
_bean,
rawAnnType,
getEJBName(),
getSessionBeanType());
moduleBeanManager.addBean(_bean, process);
if (! moduleBeanManager.isSpecialized(annType.getJavaClass())) {
moduleBeanManager.addProduces(_bean, extAnnType);
}
for (AnnotatedType<?> localApi : getLocalApi()) {
registerLocalSession(moduleBeanManager, localApi.getJavaClass());
}