当前位置: 首页>>代码示例>>Java>>正文


Java Bean.getQualifiers方法代码示例

本文整理汇总了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;
}
 
开发者ID:ibmruntimes,项目名称:acmeair-modular,代码行数:24,代码来源:ServiceLocator.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:37,代码来源:XmlCdiBeanFactory.java

示例3: eventHandler

import javax.enterprise.inject.spi.Bean; //导入方法依赖的package包/类
public static HandlerInfo eventHandler(final Bean<?> bean) {
	return new HandlerInfo(bean, bean.getQualifiers(), true);
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:4,代码来源:HandlerInfo.java

示例4: commandHandler

import javax.enterprise.inject.spi.Bean; //导入方法依赖的package包/类
public static HandlerInfo commandHandler(final Bean<?> bean) {
	return new HandlerInfo(bean, bean.getQualifiers(), false);
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi,代码行数:4,代码来源:HandlerInfo.java


注:本文中的javax.enterprise.inject.spi.Bean.getQualifiers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。