当前位置: 首页>>代码示例>>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;未经允许,请勿转载。