/** * Convenience method when we have only a single method name to match. * Use either this method or {@code setMappedNames}, not both. * @see #setMappedNames * @see NameMatchMethodPointcut#setMappedName */ public void setMappedName(String mappedName) { this.pointcut.setMappedName(mappedName); }
@Test public void testEqualsAndHashCode() { NameMatchMethodPointcut pc1 = new NameMatchMethodPointcut(); NameMatchMethodPointcut pc2 = new NameMatchMethodPointcut(); String foo = "foo"; assertEquals(pc1, pc2); assertEquals(pc1.hashCode(), pc2.hashCode()); pc1.setMappedName(foo); assertFalse(pc1.equals(pc2)); assertTrue(pc1.hashCode() != pc2.hashCode()); pc2.setMappedName(foo); assertEquals(pc1, pc2); assertEquals(pc1.hashCode(), pc2.hashCode()); }
@Override protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource customTargetSource) throws BeansException { initIdempotentEndpointsIfNecessary(); if (MessageHandler.class.isAssignableFrom(beanClass)) { List<Advisor> interceptors = new ArrayList<Advisor>(); for (Map.Entry<String, List<String>> entry : this.idempotentEndpoints.entrySet()) { List<String> mappedNames = entry.getValue(); for (String mappedName : mappedNames) { if (isMatch(mappedName, beanName)) { DefaultBeanFactoryPointcutAdvisor idempotentReceiverInterceptor = new DefaultBeanFactoryPointcutAdvisor(); idempotentReceiverInterceptor.setAdviceBeanName(entry.getKey()); NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut(); pointcut.setMappedName("handleMessage"); idempotentReceiverInterceptor.setPointcut(pointcut); BeanFactory beanFactory = getBeanFactory(); if (beanFactory != null) { idempotentReceiverInterceptor.setBeanFactory(beanFactory); } interceptors.add(idempotentReceiverInterceptor); } } } if (!interceptors.isEmpty()) { return interceptors.toArray(); } } return DO_NOT_PROXY; }
/** * Convenience method when we have only a single method name to match. * Use either this method or {@code setMappedNames}, not both. * @see #setMappedNames * @see NameMatchMethodPointcut#setMappedName */ public void setMappedName(String mappedName) { this.pointcut.setMappedName(mappedName); }
/** * Convenience method when we have only a single method name to match. * Use either this method or {@code setMappedNames}, not both. * @see #setMappedNames * @see NameMatchMethodPointcut#setMappedName */ public void setMappedName(String mappedName) { this.pointcut.setMappedName(mappedName); }
advisor.setAdviceBeanName(interceptor); NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut(); pointcut.setMappedName("handleMessage"); advisor.setPointcut(pointcut); advisor.setBeanFactory(this.beanFactory);
@Override protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String beanName, TargetSource customTargetSource) throws BeansException { initIdempotentEndpointsIfNecessary(); if (MessageHandler.class.isAssignableFrom(beanClass)) { List<Advisor> interceptors = new ArrayList<Advisor>(); for (Map.Entry<String, List<String>> entry : this.idempotentEndpoints.entrySet()) { List<String> mappedNames = entry.getValue(); for (String mappedName : mappedNames) { if (isMatch(mappedName, beanName)) { DefaultBeanFactoryPointcutAdvisor idempotentReceiverInterceptor = new DefaultBeanFactoryPointcutAdvisor(); idempotentReceiverInterceptor.setAdviceBeanName(entry.getKey()); NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut(); pointcut.setMappedName("handleMessage"); idempotentReceiverInterceptor.setPointcut(pointcut); BeanFactory beanFactory = getBeanFactory(); if (beanFactory != null) { idempotentReceiverInterceptor.setBeanFactory(beanFactory); } interceptors.add(idempotentReceiverInterceptor); } } } if (!interceptors.isEmpty()) { return interceptors.toArray(); } } return DO_NOT_PROXY; }
advisor.setAdviceBeanName(interceptor); NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut(); pointcut.setMappedName("handleMessage"); advisor.setPointcut(pointcut); advisor.setBeanFactory(this.beanFactory);