當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。