本文整理汇总了Java中javax.annotation.ManagedBean类的典型用法代码示例。如果您正苦于以下问题:Java ManagedBean类的具体用法?Java ManagedBean怎么用?Java ManagedBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ManagedBean类属于javax.annotation包,在下文中一共展示了ManagedBean类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindAllManagedBeans
import javax.annotation.ManagedBean; //导入依赖的package包/类
/**
* Binds all classes annotated with ManagedBean in the given package.
*
* @param packageName - the name of the package to search in
*/
private void bindAllManagedBeans(String packageName) {
Iterable<Class<?>> managedBeanClasses =
new Reflections(packageName).getTypesAnnotatedWith(ManagedBean.class);
for (Class<?> managedBeanClass : managedBeanClasses) {
bind(managedBeanClass).to(managedBeanClass);
}
}
示例2: getSessionType
import javax.annotation.ManagedBean; //导入依赖的package包/类
private SessionType getSessionType(final Class<?> clazz) {
if (clazz.isAnnotationPresent(Stateful.class)) {
return SessionType.STATEFUL;
}
if (clazz.isAnnotationPresent(Stateless.class)) {
return SessionType.STATELESS;
}
if (clazz.isAnnotationPresent(Singleton.class)) {
return SessionType.SINGLETON;
}
if (clazz.isAnnotationPresent(ManagedBean.class)) {
return SessionType.MANAGED;
}
return null;
}
示例3: isIgnoredReferenceType
import javax.annotation.ManagedBean; //导入依赖的package包/类
private boolean isIgnoredReferenceType(final String typeName, final ClassLoader loader) {
if (ignoredReferenceTypes.contains(typeName)) {
return true;
} else if (loader != null) {
try {
final Class<?> type = loader.loadClass(typeName);
return type.isAnnotationPresent(ManagedBean.class);
} catch (final ClassNotFoundException e) {
// ignore
}
}
return false;
}
示例4: updateContext
import javax.annotation.ManagedBean; //导入依赖的package包/类
public void updateContext(Collection<Class> classes) {
if (beanFactory != null) {
boolean needToRefreshRemotingContext = false;
for (Class clazz : classes) {
Service serviceAnnotation = (Service) clazz.getAnnotation(Service.class);
ManagedBean managedBeanAnnotation = (ManagedBean) clazz.getAnnotation(ManagedBean.class);
Component componentAnnotation = (Component) clazz.getAnnotation(Component.class);
Controller controllerAnnotation = (Controller) clazz.getAnnotation(Controller.class);
String beanName = null;
if (serviceAnnotation != null) {
beanName = serviceAnnotation.value();
} else if (managedBeanAnnotation != null) {
beanName = managedBeanAnnotation.value();
} else if (componentAnnotation != null) {
beanName = componentAnnotation.value();
} else if (controllerAnnotation != null) {
beanName = controllerAnnotation.value();
}
if (StringUtils.isNotBlank(beanName)) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(clazz);
Scope scope = (Scope) clazz.getAnnotation(Scope.class);
if (scope != null) {
beanDefinition.setScope(scope.value());
}
beanFactory.registerBeanDefinition(beanName, beanDefinition);
}
if (StringUtils.isNotBlank(beanName)) {
needToRefreshRemotingContext = true;
}
}
if (needToRefreshRemotingContext) {
ApplicationContext remotingContext = RemotingContextHolder.getRemotingApplicationContext();
if (remotingContext != null && remotingContext instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) remotingContext).refresh();
}
}
}
}
示例5: getEjbName
import javax.annotation.ManagedBean; //导入依赖的package包/类
private String getEjbName(final ManagedBean managed, final Class<?> beanClass) {
return managed.value().isEmpty() ? beanClass.getSimpleName() : managed.value();
}
示例6: isEJB
import javax.annotation.ManagedBean; //导入依赖的package包/类
private static boolean isEJB(final Class<?> clazz) {
return clazz.isAnnotationPresent(Stateless.class)
|| clazz.isAnnotationPresent(Singleton.class)
|| clazz.isAnnotationPresent(ManagedBean.class) // what a weird idea!
|| clazz.isAnnotationPresent(Stateful.class); // what another weird idea!
}