本文整理汇总了Java中javax.enterprise.inject.spi.Bean.getQualifiers方法的典型用法代码示例。如果您正苦于以下问题:Java Bean.getQualifiers方法的具体用法?Java Bean.getQualifiers怎么用?Java Bean.getQualifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.enterprise.inject.spi.Bean
的用法示例。
在下文中一共展示了Bean.getQualifiers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServices
import javax.enterprise.inject.spi.Bean; //导入方法依赖的package包/类
/**
* Retrieves the services that are available for use with the description for each service.
* The Services are determined by looking up all of the implementations of the
* Customer Service interface that are using the DataService qualifier annotation.
* The DataService annotation contains the service name and description information.
* @return Map containing a list of services available and a description of each one.
*/
public Map<String,String> getServices (){
TreeMap<String,String> services = new TreeMap<String,String>();
logger.fine("Getting CustomerService Impls");
Set<Bean<?>> beans = beanManager.getBeans(CustomerService.class,new AnnotationLiteral<Any>() {
private static final long serialVersionUID = 1L;});
for (Bean<?> bean : beans) {
for (Annotation qualifer: bean.getQualifiers()){
if(DataService.class.getName().equalsIgnoreCase(qualifer.annotationType().getName())){
DataService service = (DataService) qualifer;
logger.fine(" name="+service.name()+" description="+service.description());
services.put(service.name(), service.description());
}
}
}
return services;
}
示例2: serviceExporterBean
import javax.enterprise.inject.spi.Bean; //导入方法依赖的package包/类
private SyntheticBean<?> serviceExporterBean(Bean<?> context, CamelServiceExporterDefinition exporter, URL url) {
// TODO: replace with CreationException
requireNonNull(exporter.getServiceRef(),
() -> format("Missing [%s] attribute for imported bean [%s] from resource [%s]",
"serviceRef", Objects.toString(exporter.getId(), "export"), url));
Class<?> type;
if (exporter.getServiceInterface() != null) {
type = exporter.getServiceInterface();
} else {
Bean<?> bean = manager.resolve(manager.getBeans(exporter.getServiceRef()));
if (bean != null) {
type = bean.getBeanClass();
} else {
requireNonNull(exporter.getServiceInterface(),
() -> format("Missing [%s] attribute for imported bean [%s] from resource [%s]",
"serviceInterface", Objects.toString(exporter.getId(), "export"), url));
type = exporter.getServiceInterface();
}
}
Set<Type> types = new HashSet<>(manager.createAnnotatedType(type).getTypeClosure());
// Weld does not add Object.class for interfaces as they do not extend Object.class.
// Though let's add it so that it's possible to lookup by bean type Object.class
// beans whose bean class is an interface (for startup beans).
types.add(Object.class);
return new XmlServiceExporterBean<>(manager,
new SyntheticAnnotated(type, types, APPLICATION_SCOPED, ANY, STARTUP,
hasId(exporter) ? NamedLiteral.of(exporter.getId()) : DEFAULT),
type, bean ->
"imported bean [" + Objects.toString(exporter.getId(), "export") + "] "
+ "from resource [" + url + "] "
+ "with qualifiers " + bean.getQualifiers(),
context, exporter);
}
示例3: eventHandler
import javax.enterprise.inject.spi.Bean; //导入方法依赖的package包/类
public static HandlerInfo eventHandler(final Bean<?> bean) {
return new HandlerInfo(bean, bean.getQualifiers(), true);
}
示例4: commandHandler
import javax.enterprise.inject.spi.Bean; //导入方法依赖的package包/类
public static HandlerInfo commandHandler(final Bean<?> bean) {
return new HandlerInfo(bean, bean.getQualifiers(), false);
}