/** * If the provided instance contains a bean name rather than an object instance, * the bean name is resolved before a {@link HandlerMethod} is created and returned. */ public HandlerMethod createWithResolvedBean() { Object handler = this.bean; if (this.bean instanceof String) { Assert.state(this.beanFactory != null, "Cannot resolve bean name without BeanFactory"); String beanName = (String) this.bean; handler = this.beanFactory.getBean(beanName); } return new HandlerMethod(this, handler); }
/** * Create a HandlerMethod instance from an Object handler that is either a handler * instance or a String-based bean name. */ protected HandlerMethod createHandlerMethod(Object handler, Method method) { HandlerMethod handlerMethod; if (handler instanceof String) { ApplicationContext context = getApplicationContext(); Assert.state(context != null, "ApplicationContext is required for resolving handler bean names"); String beanName = (String) handler; handlerMethod = new HandlerMethod(beanName, context.getAutowireCapableBeanFactory(), method); } else { handlerMethod = new HandlerMethod(handler, method); } return handlerMethod; }
/** * If the provided instance contains a bean name rather than an object instance, * the bean name is resolved before a {@link HandlerMethod} is created and returned. */ public HandlerMethod createWithResolvedBean() { Object handler = this.bean; if (this.bean instanceof String) { Assert.state(this.beanFactory != null, "Cannot resolve bean name without BeanFactory"); String beanName = (String) this.bean; handler = this.beanFactory.getBean(beanName); } return new HandlerMethod(this, handler); }
/** * Create a HandlerMethod instance from an Object handler that is either a handler * instance or a String-based bean name. */ protected HandlerMethod createHandlerMethod(Object handler, Method method) { HandlerMethod handlerMethod; if (handler instanceof String) { ApplicationContext context = getApplicationContext(); Assert.state(context != null, "ApplicationContext is required for resolving handler bean names"); String beanName = (String) handler; handlerMethod = new HandlerMethod(beanName, context.getAutowireCapableBeanFactory(), method); } else { handlerMethod = new HandlerMethod(handler, method); } return handlerMethod; }
/** * If the provided instance contains a bean name rather than an object instance, * the bean name is resolved before a {@link HandlerMethod} is created and returned. */ public HandlerMethod createWithResolvedBean() { Object handler = this.bean; if (this.bean instanceof String) { Assert.state(this.beanFactory != null, "Cannot resolve bean name without BeanFactory"); String beanName = (String) this.bean; handler = this.beanFactory.getBean(beanName); } return new HandlerMethod(this, handler); }
/** * If the provided instance contains a bean name rather than an object instance, * the bean name is resolved before a {@link HandlerMethod} is created and returned. */ public HandlerMethod createWithResolvedBean() { Object handler = this.bean; if (this.bean instanceof String) { Assert.state(this.beanFactory != null, "Cannot resolve bean name without BeanFactory"); String beanName = (String) this.bean; handler = this.beanFactory.getBean(beanName); } return new HandlerMethod(this, handler); }
/** * Create a HandlerMethod instance from an Object handler that is either a handler * instance or a String-based bean name. */ protected HandlerMethod createHandlerMethod(Object handler, Method method) { HandlerMethod handlerMethod; if (handler instanceof String) { ApplicationContext context = getApplicationContext(); Assert.state(context != null, "ApplicationContext is required for resolving handler bean names"); String beanName = (String) handler; handlerMethod = new HandlerMethod(beanName, context.getAutowireCapableBeanFactory(), method); } else { handlerMethod = new HandlerMethod(handler, method); } return handlerMethod; }
/** * Create a HandlerMethod instance from an Object handler that is either a handler * instance or a String-based bean name. */ protected HandlerMethod createHandlerMethod(Object handler, Method method) { HandlerMethod handlerMethod; if (handler instanceof String) { ApplicationContext context = getApplicationContext(); Assert.state(context != null, "ApplicationContext is required for resolving handler bean names"); String beanName = (String) handler; handlerMethod = new HandlerMethod(beanName, context.getAutowireCapableBeanFactory(), method); } else { handlerMethod = new HandlerMethod(handler, method); } return handlerMethod; }
private void detectWampMethods(String beanName, Class<?> userType) { Set<Method> methods = MethodIntrospector.selectMethods(userType, (MethodFilter) method -> AnnotationUtils.findAnnotation(method, WampProcedure.class) != null); for (Method method : methods) { WampProcedure annotation = AnnotationUtils.findAnnotation(method, WampProcedure.class); InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod( new HandlerMethod(this.applicationContext.getBean(beanName), method)); String procedure = (String) AnnotationUtils.getValue(annotation); if (!StringUtils.hasText(procedure)) { procedure = beanName + "." + method.getName(); } this.wampMethods.put(procedure, handlerMethod); if (this.logger.isInfoEnabled()) { this.logger.info("Mapped \"" + procedure + "\" onto " + handlerMethod); } } }
private List<EventListenerInfo> detectEventListeners(String beanName, Class<?> userType) { List<EventListenerInfo> registry = new ArrayList<>(); Set<Method> methods = MethodIntrospector.selectMethods(userType, (MethodFilter) method -> AnnotationUtils.findAnnotation(method, WampListener.class) != null); for (Method method : methods) { WampListener wampEventListenerAnnotation = AnnotationUtils .findAnnotation(method, WampListener.class); InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod( new HandlerMethod(this.applicationContext.getBean(beanName), method)); String[] topics = (String[]) AnnotationUtils .getValue(wampEventListenerAnnotation); if (topics.length == 0) { // by default use beanName.methodName as topic topics = new String[] { beanName + "." + method.getName() }; } MatchPolicy match = (MatchPolicy) AnnotationUtils .getValue(wampEventListenerAnnotation, "match"); EventListenerInfo info = new EventListenerInfo(handlerMethod, topics, match); registry.add(info); } return registry; }