本文整理汇总了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);
}
}
}
}
示例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);
}
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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()));
}
示例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);
}
示例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);
}