}
if (enterpriseBean.getEjbClass() == null) {
enterpriseBean.setEjbClass(beanClass.get());
}
if (enterpriseBean instanceof SessionBean) {
SessionBean sessionBean = (SessionBean) enterpriseBean;
sessionBean.setSessionType(SessionType.SINGLETON);
if (singleton.mappedName() != null) {
sessionBean.setMappedName(singleton.mappedName());
}
}
LegacyProcessor.process(beanClass.get(), enterpriseBean);
}
for (Annotated<Class<?>> beanClass : finder.findMetaAnnotatedClasses(Stateless.class)) {
if (beanClass.isAnnotationPresent(Specializes.class)) {
managedClasses.remove(beanClass.get().getName());
specializingClasses.add(beanClass.get());
continue;
}
Stateless stateless = beanClass.getAnnotation(Stateless.class);
String ejbName = getEjbName(stateless, beanClass.get());
if (!isValidEjbAnnotationUsage(Stateless.class, beanClass, ejbName, ejbModule)) continue;
EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName);
if (enterpriseBean == null) {
enterpriseBean = new StatelessBean(ejbName, beanClass.get());
ejbJar.addEnterpriseBean(enterpriseBean);
}
if (enterpriseBean.getEjbClass() == null) {
enterpriseBean.setEjbClass(beanClass.get());
}
if (enterpriseBean instanceof SessionBean) {
SessionBean sessionBean = (SessionBean) enterpriseBean;
sessionBean.setSessionType(SessionType.STATELESS);
if (stateless.mappedName() != null) {
sessionBean.setMappedName(stateless.mappedName());
}
}
LegacyProcessor.process(beanClass.get(), enterpriseBean);
}
// The Specialization code is good, but it possibly needs to be moved to after the full processing of the bean
// the plus is that it would get the required interfaces. The minus is that it would get all the other items
// Possibly study alternatives. Alternatives might have different meta data completely while it seems Specializing beans inherit all meta-data
// Anyway.. the qualifiers aren't getting inherited, so we need to fix that
for (Annotated<Class<?>> beanClass : finder.findMetaAnnotatedClasses(Stateful.class)) {
if (beanClass.isAnnotationPresent(Specializes.class)) {
managedClasses.remove(beanClass.get().getName());
specializingClasses.add(beanClass.get());
continue;
}
Stateful stateful = beanClass.getAnnotation(Stateful.class);
String ejbName = getEjbName(stateful, beanClass.get());
if (!isValidEjbAnnotationUsage(Stateful.class, beanClass, ejbName, ejbModule)) continue;
EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName);
if (enterpriseBean == null) {
enterpriseBean = new StatefulBean(ejbName, beanClass.get());
ejbJar.addEnterpriseBean(enterpriseBean);
}
if (enterpriseBean.getEjbClass() == null) {
enterpriseBean.setEjbClass(beanClass.get());
}
if (enterpriseBean instanceof SessionBean) {
SessionBean sessionBean = (SessionBean) enterpriseBean;
// TODO: We might be stepping on an xml override here
sessionBean.setSessionType(SessionType.STATEFUL);
if (stateful.mappedName() != null) {
sessionBean.setMappedName(stateful.mappedName());
}
}
LegacyProcessor.process(beanClass.get(), enterpriseBean);
}
for (Annotated<Class<?>> beanClass : finder.findMetaAnnotatedClasses(ManagedBean.class)) {
if (beanClass.isAnnotationPresent(Specializes.class)) {
managedClasses.remove(beanClass.get().getName());
specializingClasses.add(beanClass.get());
continue;
}
ManagedBean managed = beanClass.getAnnotation(ManagedBean.class);
String ejbName = getEjbName(managed, beanClass.get());
// TODO: this is actually against the spec, but the requirement is rather silly
// (allowing @Stateful and @ManagedBean on the same class)
// If the TCK doesn't complain we should discourage it
if (!isValidEjbAnnotationUsage(ManagedBean.class, beanClass, ejbName, ejbModule)) continue;
EnterpriseBean enterpriseBean = ejbJar.getEnterpriseBean(ejbName);
if (enterpriseBean == null) {
enterpriseBean = new org.apache.openejb.jee.ManagedBean(ejbName, beanClass.get());
ejbJar.addEnterpriseBean(enterpriseBean);
}
if (enterpriseBean.getEjbClass() == null) {
enterpriseBean.setEjbClass(beanClass.get());
}
if (enterpriseBean instanceof SessionBean) {
SessionBean sessionBean = (SessionBean) enterpriseBean;
sessionBean.setSessionType(SessionType.MANAGED);
final TransactionType transactionType = sessionBean.getTransactionType();
if (transactionType == null) sessionBean.setTransactionType(TransactionType.BEAN);
}
}
for (Annotated<Class<?>> beanClass : finder.findMetaAnnotatedClasses(MessageDriven.class)) {