/** * Build the BeanWiringInfo for the given Configurable annotation. * @param beanInstance the bean instance * @param annotation the Configurable annotation found on the bean class * @return the resolved BeanWiringInfo */ protected BeanWiringInfo buildWiringInfo(Object beanInstance, Configurable annotation) { if (!Autowire.NO.equals(annotation.autowire())) { return new BeanWiringInfo(annotation.autowire().value(), annotation.dependencyCheck()); } else { if (!"".equals(annotation.value())) { // explicitly specified bean name return new BeanWiringInfo(annotation.value(), false); } else { // default bean name return new BeanWiringInfo(getDefaultBeanName(beanInstance), true); } } }
@Test public void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitly() { AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver(); BeanWiringInfo info = resolver.resolveWiringInfo(new WirelessSoap()); assertNotNull("Must *not* be returning null for an @Configurable class instance even when autowiring is NO", info); assertFalse(info.indicatesAutowiring()); assertEquals(WirelessSoap.class.getName(), info.getBeanName()); }
@Test public void testResolveWiringInfoWithAnInstanceOfAnAnnotatedClassWithAutowiringTurnedOffExplicitlyAndCustomBeanName() { AnnotationBeanWiringInfoResolver resolver = new AnnotationBeanWiringInfoResolver(); BeanWiringInfo info = resolver.resolveWiringInfo(new NamedWirelessSoap()); assertNotNull("Must *not* be returning null for an @Configurable class instance even when autowiring is NO", info); assertFalse(info.indicatesAutowiring()); assertEquals("DerBigStick", info.getBeanName()); }
@Override public BeanWiringInfo resolveWiringInfo(Object beanInstance) { Assert.notNull(beanInstance, "Bean instance must not be null"); Configurable annotation = beanInstance.getClass().getAnnotation(Configurable.class); return (annotation != null ? buildWiringInfo(beanInstance, annotation) : null); }
public BeanWiringInfo resolveWiringInfo(Object beanInstance) { Assert.notNull(beanInstance, "Bean instance must not be null"); Configurable annotation = beanInstance.getClass().getAnnotation(Configurable.class); return (annotation != null ? buildWiringInfo(beanInstance, annotation) : null); }