當前位置: 首頁>>代碼示例>>Java>>正文


Java ApplicationContext.getBeansWithAnnotation方法代碼示例

本文整理匯總了Java中org.springframework.context.ApplicationContext.getBeansWithAnnotation方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationContext.getBeansWithAnnotation方法的具體用法?Java ApplicationContext.getBeansWithAnnotation怎麽用?Java ApplicationContext.getBeansWithAnnotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.context.ApplicationContext的用法示例。


在下文中一共展示了ApplicationContext.getBeansWithAnnotation方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initJobHandlerRepository

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
private static void initJobHandlerRepository(ApplicationContext applicationContext){
    // init job handler action
    Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class);

    if (serviceBeanMap!=null && serviceBeanMap.size()>0) {
        for (Object serviceBean : serviceBeanMap.values()) {
            if (serviceBean instanceof IJobHandler){
                String name = serviceBean.getClass().getAnnotation(JobHandler.class).value();
                IJobHandler handler = (IJobHandler) serviceBean;
                if (loadJobHandler(name) != null) {
                    throw new RuntimeException("xxl-job jobhandler naming conflicts.");
                }
                registJobHandler(name, handler);
            }
        }
    }
}
 
開發者ID:mmwhd,項目名稱:stage-job,代碼行數:18,代碼來源:XxlJobExecutor.java

示例2: setApplicationContext

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
       XxlJobExecutor.applicationContext = applicationContext;

       // init job handler action
       Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHander.class);

       if (serviceBeanMap!=null && serviceBeanMap.size()>0) {
           for (Object serviceBean : serviceBeanMap.values()) {
               if (serviceBean instanceof IJobHandler){
                   String name = serviceBean.getClass().getAnnotation(JobHander.class).value();
                   IJobHandler handler = (IJobHandler) serviceBean;
                   registJobHandler(name, handler);
               }
           }
       }
}
 
開發者ID:kevinKaiF,項目名稱:xxl-job,代碼行數:18,代碼來源:XxlJobExecutor.java

示例3: doFilter

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void doFilter(ServletRequest req, ServletResponse res,
        FilterChain filterChain) throws IOException, ServletException {
    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) res;

    ApplicationContext ctx = ApplicationContextHelper
            .getApplicationContext();
    Map<String, Object> map = ctx.getBeansWithAnnotation(Path.class);

    for (Object object : map.values()) {
        Class clz = object.getClass();

        for (Method method : clz.getDeclaredMethods()) {
            if (this.matches(request, method)) {
                Map<String, String> parameters = parseBody(request
                        .getInputStream());
                this.invokeMethod(request, response, object, method,
                        parameters);

                return;
            }
        }
    }

    filterChain.doFilter(req, res);
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:27,代碼來源:RestFilter.java

示例4: refresh

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void refresh(ApplicationContext applicationContext)
{
	handleMessageServiceMapping = new HashMap<String, HandleMessageService>();

	Map<String, Object> beans = applicationContext.getBeansWithAnnotation(HandleMessageProtocol.class);

	for (Object bean : beans.values()) {

		if (!(bean instanceof HandleMessageService)) {
			continue;
		}

		HandleMessageProtocol tmp = null;

		tmp = bean.getClass().getAnnotation(HandleMessageProtocol.class);

		addHandleMessageService(tmp.id(), (HandleMessageService) bean);

	}
}
 
開發者ID:yanghao0518,項目名稱:cstruct-parser,代碼行數:21,代碼來源:AbstractDispatchCenterService.java

示例5: setApplicationContext

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    Map<String,Object> lionServiceMap = applicationContext.getBeansWithAnnotation(LionService.class);
    if(lionServiceMap != null){
        for (Object serviceBean : lionServiceMap.values()) {
            String interfaceName = serviceBean.getClass().getAnnotation(LionService.class).value().getName();
            serverHandlerMap.put(interfaceName, serviceBean);
        }
    }
}
 
開發者ID:islittlechen,項目名稱:lionrpc,代碼行數:10,代碼來源:LionServer.java

示例6: setApplicationContext

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext)
        throws BeansException {
    Map<String, Object> serviceMap = applicationContext.getBeansWithAnnotation(RpcService.class);
    if (MapUtils.isNotEmpty(serviceMap)) {
        for (Object bean : serviceMap.values()) {
            String interfaceName = bean.getClass().getAnnotation(RpcService.class).value().getName();
            handlerMap.put(interfaceName, bean);
        }
    }
}
 
開發者ID:tinylcy,項目名稱:buddha,代碼行數:11,代碼來源:RpcServer.java

示例7: onBootstrap

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
@Override
protected void onBootstrap(ApplicationEvent event)
{
    logger.info("Bootstapping the API");
    ContextRefreshedEvent refreshEvent = (ContextRefreshedEvent)event;
    ApplicationContext ac = refreshEvent.getApplicationContext();
    Map<String, Object> entityResourceBeans = ac.getBeansWithAnnotation(EntityResource.class);
    Map<String, Object> relationResourceBeans = ac.getBeansWithAnnotation(RelationshipResource.class);
    apiDictionary.setDictionary(ResourceDictionaryBuilder.build(entityResourceBeans.values(), relationResourceBeans.values()));
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:11,代碼來源:ApiBootstrap.java

示例8: setApplicationContext

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	resourceBuilders=applicationContext.getBeansOfType(ResourceBuilder.class).values();
	providers=applicationContext.getBeansOfType(ResourceProvider.class).values();
	this.applicationContext=applicationContext;
	applicationContext.getBeansWithAnnotation(SuppressWarnings.class);
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:7,代碼來源:AbstractBuilder.java

示例9: onApplicationEvent

import org.springframework.context.ApplicationContext; //導入方法依賴的package包/類
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
    ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
    Map<String, Object> converterBeans = applicationContext.getBeansWithAnnotation(Converter.class);
    ConverterContext.initialize(converterProperties, converterBeans);
}
 
開發者ID:liaochong,項目名稱:spring-boot-starter-converter,代碼行數:7,代碼來源:ConverterStartListener.java


注:本文中的org.springframework.context.ApplicationContext.getBeansWithAnnotation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。