dreamworker

Untitled

Aug 27th, 2020
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1.             // Ask spring to find (and load if not loaded?) all beans annotated with @JrpcController
  2.             Map<String,Object> beans = context.getBeansWithAnnotation(JrpcController.class);
  3.  
  4.             // https://stackoverflow.com/questions/27929965/find-method-level-custom-annotation-in-a-spring-context
  5.             for (Map.Entry<String, Object> entry : beans.entrySet()) {
  6.  
  7.                 Object bean = entry.getValue();
  8.                 Class<?> beanClass = bean.getClass();
  9.                 JrpcController jrpcController = beanClass.getAnnotation(JrpcController.class);
  10.  
  11.                 // bean is an AOP proxy
  12.                 if (jrpcController == null) {
  13.                     beanClass = AopProxyUtils.ultimateTargetClass(bean);
  14.                     jrpcController = beanClass.getAnnotation(JrpcController.class);
  15.                 }
  16.                
  17.                 // Ищем в бине метод, помеченный аннотацией @JrpcMethod
  18.                 for (Method method : beanClass.getDeclaredMethods()) {
Add Comment
Please, Sign In to add comment