private void processMultiMethodListeners(RabbitListener[] classLevelListeners, Method[] multiMethods, Object bean, String beanName) { List<Method> checkedMethods = new ArrayList<Method>(); Method defaultMethod = null; for (Method method : multiMethods) { Method checked = checkProxy(method, bean); if (AnnotationUtils.findAnnotation(method, RabbitHandler.class).isDefault()) { // NOSONAR never null final Method toAssert = defaultMethod; Assert.state(toAssert == null, () -> "Only one @RabbitHandler can be marked 'isDefault', found: " + toAssert.toString() + " and " + method.toString()); defaultMethod = checked; } checkedMethods.add(checked); } for (RabbitListener classLevelListener : classLevelListeners) { MultiMethodRabbitListenerEndpoint endpoint = new MultiMethodRabbitListenerEndpoint(checkedMethods, defaultMethod, bean); processListener(endpoint, classLevelListener, bean, bean.getClass(), beanName); } }
private void processMultiMethodListeners(RabbitListener[] classLevelListeners, Method[] multiMethods, Object bean, String beanName) { List<Method> checkedMethods = new ArrayList<Method>(); Method defaultMethod = null; for (Method method : multiMethods) { Method checked = checkProxy(method, bean); if (AnnotationUtils.findAnnotation(method, RabbitHandler.class).isDefault()) { // NOSONAR never null final Method toAssert = defaultMethod; Assert.state(toAssert == null, () -> "Only one @RabbitHandler can be marked 'isDefault', found: " + toAssert.toString() + " and " + method.toString()); defaultMethod = checked; } checkedMethods.add(checked); } for (RabbitListener classLevelListener : classLevelListeners) { MultiMethodRabbitListenerEndpoint endpoint = new MultiMethodRabbitListenerEndpoint(checkedMethods, defaultMethod, bean); processListener(endpoint, classLevelListener, bean, bean.getClass(), beanName); } }
protected void processAmqpListener(RabbitListener rabbitListener, Method method, Object bean, String beanName) { Method methodToUse = checkProxy(method, bean); MethodRabbitListenerEndpoint endpoint = new MethodRabbitListenerEndpoint(); endpoint.setMethod(methodToUse); processListener(endpoint, rabbitListener, bean, methodToUse, beanName); }
protected void processAmqpListener(RabbitListener rabbitListener, Method method, Object bean, String beanName) { Method methodToUse = checkProxy(method, bean); MethodRabbitListenerEndpoint endpoint = new MethodRabbitListenerEndpoint(); endpoint.setMethod(methodToUse); processListener(endpoint, rabbitListener, bean, methodToUse, beanName); }
@Override protected void processListener(MethodRabbitListenerEndpoint endpoint, RabbitListener rabbitListener, Object bean, Object adminTarget, String beanName) { Object proxy = bean; String id = rabbitListener.id(); if (StringUtils.hasText(id)) { if (this.attributes.getBoolean("spy")) { proxy = Mockito.spy(proxy); this.listeners.put(id, proxy); } if (this.attributes.getBoolean("capture")) { try { ProxyFactoryBean pfb = new ProxyFactoryBean(); pfb.setProxyTargetClass(true); pfb.setTarget(proxy); CaptureAdvice advice = new CaptureAdvice(); pfb.addAdvice(advice); proxy = pfb.getObject(); this.listenerCapture.put(id, advice); } catch (Exception e) { throw new AmqpException("Failed to proxy @RabbitListener with id: " + id, e); } } } else { logger.info("The test harness can only proxy @RabbitListeners with an 'id' attribute"); } super.processListener(endpoint, rabbitListener, proxy, adminTarget, beanName); }
@Override protected void processListener(MethodRabbitListenerEndpoint endpoint, RabbitListener rabbitListener, Object bean, Object adminTarget, String beanName) { Object proxy = bean; String id = rabbitListener.id(); if (StringUtils.hasText(id)) { if (this.attributes.getBoolean("spy")) { proxy = Mockito.spy(proxy); this.listeners.put(id, proxy); } if (this.attributes.getBoolean("capture")) { try { ProxyFactoryBean pfb = new ProxyFactoryBean(); pfb.setProxyTargetClass(true); pfb.setTarget(proxy); CaptureAdvice advice = new CaptureAdvice(); pfb.addAdvice(advice); proxy = pfb.getObject(); this.listenerCapture.put(id, advice); } catch (Exception e) { throw new AmqpException("Failed to proxy @RabbitListener with id: " + id, e); } } } else { logger.info("The test harness can only proxy @RabbitListeners with an 'id' attribute"); } super.processListener(endpoint, rabbitListener, proxy, adminTarget, beanName); }