@Test public void destroyMethodMetadataIsPropagated() { @Configuration class Config { @Bean(destroyMethod="destroy") Object foo() { return null; } } assertEquals("destroy method name was not propagated", "destroy", beanDef(Config.class).getDestroyMethodName()); }
setEnforceInitMethod(otherAbd.isEnforceInitMethod()); if (otherAbd.getDestroyMethodName() != null) { setDestroyMethodName(otherAbd.getDestroyMethodName()); setEnforceDestroyMethod(otherAbd.isEnforceDestroyMethod());
setEnforceInitMethod(otherAbd.isEnforceInitMethod()); if (otherAbd.getDestroyMethodName() != null) { setDestroyMethodName(otherAbd.getDestroyMethodName()); setEnforceDestroyMethod(otherAbd.isEnforceDestroyMethod());
setInitMethodName(originalAbd.getInitMethodName()); setEnforceInitMethod(originalAbd.isEnforceInitMethod()); setDestroyMethodName(originalAbd.getDestroyMethodName()); setEnforceDestroyMethod(originalAbd.isEnforceDestroyMethod()); setSynthetic(originalAbd.isSynthetic());
setInitMethodName(originalAbd.getInitMethodName()); setEnforceInitMethod(originalAbd.isEnforceInitMethod()); setDestroyMethodName(originalAbd.getDestroyMethodName()); setEnforceDestroyMethod(originalAbd.isEnforceDestroyMethod()); setSynthetic(originalAbd.isSynthetic());
public String getDestroyMethod() { return beanDefinition.getDestroyMethodName(); }
setEnforceInitMethod(otherAbd.isEnforceInitMethod()); if (StringUtils.hasLength(otherAbd.getDestroyMethodName())) { setDestroyMethodName(otherAbd.getDestroyMethodName()); setEnforceDestroyMethod(otherAbd.isEnforceDestroyMethod());
if (bd.getDestroyMethodName() != null) { beanElement.addAttribute("destroy-method", bd.getDestroyMethodName());
if (bd.getDestroyMethodName() != null) { beanElement.addAttribute("destroy-method", bd.getDestroyMethodName());
setInitMethodName(originalAbd.getInitMethodName()); setEnforceInitMethod(originalAbd.isEnforceInitMethod()); setDestroyMethodName(originalAbd.getDestroyMethodName()); setEnforceDestroyMethod(originalAbd.isEnforceDestroyMethod()); setMethodOverrides(new MethodOverrides(originalAbd.getMethodOverrides()));
private AbstractBeanDefinition parseAttributes(Element ele, String beanName, AbstractBeanDefinition beanDefinition) { AbstractBeanDefinition bd = parserContext.getDelegate().parseBeanDefinitionAttributes(ele, beanName, null, beanDefinition); // handle lazy flag (initialize) String lazyInit = ele.getAttribute(LAZY_INIT_ATTR); // check whether the value is "lazy" if (StringUtils.hasText(lazyInit)) { if (lazyInit.equalsIgnoreCase(LAZY_INIT_VALUE)) { bd.setLazyInit(true); } else { bd.setLazyInit(false); } } else { bd.setLazyInit(getDefaults(ele).getDefaultInitialization()); } // handle factory component String componentFactory = ele.getAttribute(FACTORY_REF_ATTR); if (StringUtils.hasText(componentFactory)) { bd.setFactoryBeanName(componentFactory); } // check whether the bean is a prototype with destroy method if (StringUtils.hasText(bd.getDestroyMethodName()) && BeanDefinition.SCOPE_PROTOTYPE.equalsIgnoreCase(bd.getScope())) { error("Blueprint prototype beans cannot define destroy methods", ele); } return bd; }
/** * <p> * lifecycle. * </p> * * @param registry a {@link org.beangle.commons.inject.bind.BindRegistry} object. * @param definitionRegistry a * {@link org.springframework.beans.factory.support.BeanDefinitionRegistry} object. */ protected void lifecycle(BindRegistry registry, BeanDefinitionRegistry definitionRegistry) { for (String name : registry.getBeanNames()) { Class<?> clazz = registry.getBeanType(name); String springName = name; if (springName.startsWith("&")) springName = springName.substring(1); if (!definitionRegistry.containsBeanDefinition(springName)) continue; AbstractBeanDefinition def = (AbstractBeanDefinition) definitionRegistry.getBeanDefinition(springName); if (Initializing.class.isAssignableFrom(clazz) && null == def.getInitMethodName() && !def.getPropertyValues().contains("init-method")) { def.setInitMethodName("init"); } if (Disposable.class.isAssignableFrom(clazz) && null == def.getDestroyMethodName() && !def.getPropertyValues().contains("destroy-method")) { def.setDestroyMethodName("destroy"); } } }
protected void declareLifecycleMethods(BeanDefinitionHolder definitionHolder, MappingMetaData metaData, Element element) { BeanDefinition definition = definitionHolder.getBeanDefinition(); if (definition instanceof AbstractBeanDefinition) { AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) definition; if (beanDefinition.getInitMethodName() == null) { beanDefinition.setInitMethodName(metaData.getInitMethodName(getLocalName(element))); } if (beanDefinition.getDestroyMethodName() == null) { beanDefinition.setDestroyMethodName(metaData.getDestroyMethodName(getLocalName(element))); } if (beanDefinition.getFactoryMethodName() == null) { beanDefinition.setFactoryMethodName(metaData.getFactoryMethodName(getLocalName(element))); } } }
protected void declareLifecycleMethods(BeanDefinitionHolder definitionHolder, MappingMetaData metaData, Element element) { BeanDefinition definition = definitionHolder.getBeanDefinition(); if (definition instanceof AbstractBeanDefinition) { AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) definition; if (beanDefinition.getInitMethodName() == null) { beanDefinition.setInitMethodName(metaData.getInitMethodName(getLocalName(element))); } if (beanDefinition.getDestroyMethodName() == null) { beanDefinition.setDestroyMethodName(metaData.getDestroyMethodName(getLocalName(element))); } if (beanDefinition.getFactoryMethodName() == null) { beanDefinition.setFactoryMethodName(metaData.getFactoryMethodName(getLocalName(element))); } } }
protected void declareLifecycleMethods(BeanDefinitionHolder definitionHolder, MappingMetaData metaData, Element element) { BeanDefinition definition = definitionHolder.getBeanDefinition(); if (definition instanceof AbstractBeanDefinition) { AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) definition; if (beanDefinition.getInitMethodName() == null) { beanDefinition.setInitMethodName(metaData.getInitMethodName(getLocalName(element))); } if (beanDefinition.getDestroyMethodName() == null) { beanDefinition.setDestroyMethodName(metaData.getDestroyMethodName(getLocalName(element))); } if (beanDefinition.getFactoryMethodName() == null) { beanDefinition.setFactoryMethodName(metaData.getFactoryMethodName(getLocalName(element))); } } }
String destroyMethod = abstractBeanDefinition.getDestroyMethodName(); if (destroyMethod != null) { builder.addAttribute(DESTROY_METHOD_ATTRIBUTE, destroyMethod);
String destroyMethod = abstractBeanDefinition.getDestroyMethodName(); if (destroyMethod != null) { builder.addAttribute(DESTROY_METHOD_ATTRIBUTE, destroyMethod);
setInitMethodName(other.getInitMethodName()); if (other.getDestroyMethodName() != null) { setDestroyMethodName(other.getDestroyMethodName());
if (bd.getDestroyMethodName() != null) { beanElement.addAttribute("destroy-method", bd.getDestroyMethodName());
/** * Create a new AbstractBeanDefinition as deep copy of the given * bean definition. * @param original the original bean definition to copy from */ protected AbstractBeanDefinition(AbstractBeanDefinition original) { this.beanClass = original.beanClass; setAbstract(original.isAbstract()); setSingleton(original.isSingleton()); setLazyInit(original.isLazyInit()); setConstructorArgumentValues(new ConstructorArgumentValues(original.getConstructorArgumentValues())); setPropertyValues(new MutablePropertyValues(original.getPropertyValues())); setMethodOverrides(new MethodOverrides(original.getMethodOverrides())); setAutowireMode(original.getAutowireMode()); setDependencyCheck(original.getDependencyCheck()); setInitMethodName(original.getInitMethodName()); setDestroyMethodName(original.getDestroyMethodName()); setFactoryMethodName(original.getFactoryMethodName()); setFactoryBeanName(original.getFactoryBeanName()); setDependsOn(original.getDependsOn()); setResourceDescription(original.getResourceDescription()); }