processBeanImpl(event);
}
private <T> void processBeanImpl(ProcessBean<T> event)
{
Annotated annotated = event.getAnnotated();
Bean<T> bean = event.getBean();
if (annotated == null) {
return;
}
if (! (bean instanceof EjbGeneratedBean)
&& (annotated.isAnnotationPresent(Stateful.class)
|| annotated.isAnnotationPresent(Stateless.class)
|| annotated.isAnnotationPresent(Singleton.class)
|| annotated.isAnnotationPresent(MessageDriven.class)
|| annotated.isAnnotationPresent(JmsMessageListener.class))) {
EjbManager ejbContainer = EjbManager.create();
if (bean instanceof ManagedBeanImpl<?>) {
// XXX: shouldn't reach processBeanImpl
if (true)
throw new IllegalStateException(String.valueOf(annotated));
ManagedBeanImpl<T> mBean = (ManagedBeanImpl<T>) bean;
AnnotatedType<T> annType = mBean.getAnnotatedType();
ejbContainer.createBean(annType, mBean.getInjectionTarget());
if (event instanceof ProcessBeanImpl<?>)
((ProcessBeanImpl<?>) event).veto();
}
}
if (annotated.isAnnotationPresent(Jndi.class)) {
Jndi jndi = annotated.getAnnotation(Jndi.class);
String jndiName = jndi.value();
if ("".equals(jndiName)) {
jndiName = bean.getBeanClass().getSimpleName();
}
JndiBeanProxy<T> proxy = new JndiBeanProxy<T>(_cdiManager, bean);
if (log.isLoggable(Level.FINE))
log.fine("bind to JNDI '" + jndiName + "' for " + bean);
try {
com.caucho.naming.Jndi.bindDeepShort(jndiName, proxy);
} catch (Exception e) {
log.log(Level.FINE, e.toString(), e);
}
}
if (annotated.isAnnotationPresent(ManagedBean.class)){
registerManagedBean(annotated, bean);
}
if (annotated.isAnnotationPresent(MBean.class)) {
MBean mbean = annotated.getAnnotation(MBean.class);
String mbeanName = mbean.value();
if ("".equals(mbeanName))
mbeanName = "type=" + bean.getBeanClass().getSimpleName();
AnnotatedType<?> annType = (AnnotatedType<?>) annotated;
try {
Jmx.registerContext(new BeanMBean(_cdiManager, bean, annType), mbeanName);
} catch (Exception e) {
log.log(Level.FINE, e.toString(), e);
}
}
if (annotated.isAnnotationPresent(BamService.class)) {
BamService service = annotated.getAnnotation(BamService.class);
HempBroker broker = HempBroker.getCurrent();
broker.addStartupActor(event.getBean(), service.name(),
service.threadMax());
}
if (annotated.isAnnotationPresent(AdminService.class)) {
AdminService service = annotated.getAnnotation(AdminService.class);
Server server = Server.getCurrent();
if (server == null) {
throw new ConfigException(L