List of usage examples for org.springframework.beans.factory.support AbstractBeanDefinition setLazyInit
@Override public void setLazyInit(boolean lazyInit)
From source file:com.griddynamics.banshun.xml.ImportBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String exportInterface = element.getAttribute(INTERFACE_ATTR); if (isBlank(exportInterface)) { return;//from ww w .j a v a2 s . co m } String externalName = element.getAttribute(ID_ATTR); if (isBlank(externalName)) { return; } String rootName = element.getAttribute(ROOT_ATTR); if (isBlank(rootName)) { rootName = DEFAULT_ROOT_FACTORY_NAME; } ConstructorArgumentValues constructorArgValues = new ConstructorArgumentValues(); constructorArgValues.addGenericArgumentValue(externalName); constructorArgValues.addGenericArgumentValue(findClass(exportInterface, element.getAttribute(ID_ATTR), parserContext.getReaderContext().getResource().getDescription())); AbstractBeanDefinition beanDef = builder.getRawBeanDefinition(); beanDef.setFactoryBeanName(rootName); beanDef.setFactoryMethodName("lookup"); beanDef.setConstructorArgumentValues(constructorArgValues); beanDef.setLazyInit(true); beanDef.setScope(SCOPE_SINGLETON); }
From source file:com.griddynamics.banshun.xml.ExportBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { BeanDefinitionRegistry registry = parserContext.getRegistry(); String exportInterface = element.getAttribute(INTERFACE_ATTR); if (isBlank(exportInterface)) { return;/*from www .j av a 2 s. c o m*/ } String exportBeanRef = element.getAttribute(REF_ATTR); if (isBlank(exportBeanRef)) { return; } String rootName = element.getAttribute(ROOT_ATTR); if (isBlank(rootName)) { rootName = DEFAULT_ROOT_FACTORY_NAME; } String exportName = element.getAttribute(NAME_ATTR); if (isBlank(exportName)) { exportName = exportBeanRef; } String exportRefName = exportName + BEAN_NAME_SUFFIX; if (registry.containsBeanDefinition(exportRefName)) { throw new BeanCreationException("Registry already contains bean with name: " + exportRefName); } ConstructorArgumentValues exportBeanConstructorArgValues = new ConstructorArgumentValues(); exportBeanConstructorArgValues.addGenericArgumentValue(exportName); exportBeanConstructorArgValues.addGenericArgumentValue(findClass(exportInterface, exportBeanRef, parserContext.getReaderContext().getResource().getDescription())); AbstractBeanDefinition exportBeanDef = rootBeanDefinition(ExportRef.class).getRawBeanDefinition(); exportBeanDef.setConstructorArgumentValues(exportBeanConstructorArgValues); ConstructorArgumentValues voidBeanConstructorArgValues = new ConstructorArgumentValues(); voidBeanConstructorArgValues.addGenericArgumentValue(exportBeanDef, ExportRef.class.getName()); AbstractBeanDefinition voidBeanDef = rootBeanDefinition(Void.class).getRawBeanDefinition(); voidBeanDef.setFactoryBeanName(rootName); voidBeanDef.setFactoryMethodName("export"); voidBeanDef.setLazyInit(false); voidBeanDef.setScope(SCOPE_SINGLETON); voidBeanDef.setConstructorArgumentValues(voidBeanConstructorArgValues); // voidBeanDefinition.setDependsOn(new String[] { exportBeanRef }); TODO ? registry.registerBeanDefinition(exportRefName, voidBeanDef); }
From source file:com.griddynamics.banshun.config.xml.ImportBeanDefinitionParser.java
@Override protected void doParse(Element el, ParserContext parserContext, BeanDefinitionBuilder builder) { Resource resource = parserContext.getReaderContext().getResource(); String rootName = defaultIfBlank(el.getAttribute(ROOT_ATTR), DEFAULT_ROOT_FACTORY_NAME); String serviceIfaceName = el.getAttribute(INTERFACE_ATTR); String serviceName = el.getAttribute(ID_ATTR); Class<?> serviceIface = ParserUtils.findClassByName(serviceIfaceName, el.getAttribute(ID_ATTR), parserContext);/*from www . java2 s . com*/ AbstractBeanDefinition beanDef = builder.getRawBeanDefinition(); beanDef.setFactoryBeanName(rootName); beanDef.setFactoryMethodName(Registry.LOOKUP_METHOD_NAME); beanDef.setConstructorArgumentValues(defineLookupMethodArgs(serviceName, serviceIface)); beanDef.setLazyInit(true); beanDef.setScope(SCOPE_SINGLETON); beanDef.setResource(resource); beanDef.setAttribute(IMPORT_BEAN_DEF_ATTR_NAME, new BeanReferenceInfo(serviceName, serviceIface, extractResourcePath(resource))); }
From source file:com.mtgi.analytics.aop.config.v11.BtManagerBeanDefinitionParser.java
@Override protected void transform(ConfigurableListableBeanFactory factory, BeanDefinition template, Element element, ParserContext parserContext) {//w ww.jav a2 s.com ManagerComponentDefinition def = (ManagerComponentDefinition) parserContext.getContainingComponent(); String managerId = overrideAttribute(ATT_ID, template, element); if (managerId == null) template.setAttribute(ATT_ID, managerId = "defaultTrackingManager"); if ("false".equals(element.getAttribute(ATT_ENABLED))) { //manager is disabled. replace definition with dummy instance. template.setBeanClassName(DisabledBehaviorTrackingManager.class.getName()); //clear properties and attributes. for (String att : template.attributeNames()) if (!ATT_ID.equals(att)) template.removeAttribute(att); template.getPropertyValues().clear(); //terminate immediately, do not parse any nested definitions (persisters, AOP config, context beans, etc) return; } overrideProperty(ATT_APPLICATION, template, element, false); overrideProperty(ATT_FLUSH_THRESHOLD, template, element, false); //wake up MBeanExporter if we're going to be doing MBean registration. if ("true".equalsIgnoreCase(element.getAttribute(ATT_REGISTER_MBEANS))) { AbstractBeanDefinition exporter = (AbstractBeanDefinition) factory .getBeanDefinition(CONFIG_MBEAN_EXPORTER); exporter.setLazyInit(false); //append manager ID to mbean name, in case of multiple managers in a single application. BeanDefinition naming = factory.getBeanDefinition(CONFIG_NAMING_STRATEGY); naming.getPropertyValues().addPropertyValue("value", managerId); } //prefer references to beans in the parent factory if they've been specified if (element.hasAttribute(ATT_MBEAN_SERVER)) factory.registerAlias(element.getAttribute(ATT_MBEAN_SERVER), CONFIG_MBEAN_SERVER); if (element.hasAttribute(ATT_SCHEDULER)) factory.registerAlias(element.getAttribute(ATT_SCHEDULER), CONFIG_SCHEDULER); if (element.hasAttribute(ATT_TASK_EXECUTOR)) factory.registerAlias(element.getAttribute(ATT_TASK_EXECUTOR), CONFIG_EXECUTOR); //make note of external persister element so that we don't activate log rotation. if (element.hasAttribute(ATT_PERSISTER)) { def.addNestedProperty(ATT_PERSISTER); MutablePropertyValues props = template.getPropertyValues(); props.removePropertyValue(ATT_PERSISTER); props.addPropertyValue(ATT_PERSISTER, new RuntimeBeanReference(element.getAttribute(ATT_PERSISTER))); } if (element.hasAttribute(ATT_SESSION_CONTEXT)) { //override default session context with reference def.addNestedProperty("sessionContext"); factory.registerAlias(element.getAttribute(ATT_SESSION_CONTEXT), CONFIG_SESSION_CONTEXT); } //handle AOP configuration if needed if (element.hasAttribute(ATT_METHOD_EXPRESSION)) { //activate global AOP proxying if it hasn't already been done (borrowed logic from AopNamespaceHandler / config element parser) activateAopProxies(parserContext, element); //register pointcut definition for the provided expression. RootBeanDefinition pointcut = new RootBeanDefinition(AspectJExpressionPointcut.class); //rely on deprecated method to maintain spring 2.0 support pointcut.setSingleton(false); pointcut.setSynthetic(true); pointcut.getPropertyValues().addPropertyValue("expression", element.getAttribute(ATT_METHOD_EXPRESSION)); //create implicit pointcut advice bean. RootBeanDefinition advice = new RootBeanDefinition(BehaviorTrackingAdvice.class); advice.getPropertyValues().addPropertyValue("trackingManager", new RuntimeBeanReference(managerId)); //register advice, pointcut, and advisor entry to bind the two together. XmlReaderContext ctx = parserContext.getReaderContext(); String pointcutId = ctx.registerWithGeneratedName(pointcut); String adviceId = ctx.registerWithGeneratedName(advice); RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); advisorDefinition.getPropertyValues().addPropertyValue("adviceBeanName", new RuntimeBeanNameReference(adviceId)); advisorDefinition.getPropertyValues().addPropertyValue("pointcut", new RuntimeBeanReference(pointcutId)); ctx.registerWithGeneratedName(advisorDefinition); } //configure flush trigger and job to be globally unique based on manager name. BeanDefinition flushTrigger = factory.getBeanDefinition("com.mtgi.analytics.btFlushTrigger"); SchedulerActivationPostProcessor.configureTriggerDefinition(flushTrigger, element.getAttribute(ATT_FLUSH_SCHEDULE), managerId + "_flush"); //set up a post-processor to register the flush job with the selected scheduler instance. the job and scheduler //come from the template factory, but the post-processor runs when the currently-parsing factory is finished. SchedulerActivationPostProcessor.registerPostProcessor(parserContext, factory, CONFIG_SCHEDULER, CONFIG_NAMESPACE + ".btFlushTrigger"); //ManagerComponentDefinition is a flag to nested parsers that they should push their parsed bean definitions into //the manager bean definition. for example, see BtPersisterBeanDefinitionParser. //descend on nested child nodes to pick up persister and session context configuration NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { String namespaceUri = node.getNamespaceURI(); NamespaceHandler handler = parserContext.getReaderContext().getNamespaceHandlerResolver() .resolve(namespaceUri); ParserContext nestedCtx = new ParserContext(parserContext.getReaderContext(), parserContext.getDelegate(), template); nestedCtx.pushContainingComponent(def); handler.parse((Element) node, nestedCtx); } } if (!def.nestedProperties.contains(ATT_PERSISTER)) { //no persister registered. schedule default log rotation trigger. BtXmlPersisterBeanDefinitionParser.configureLogRotation(parserContext, factory, null); } if (!def.nestedProperties.contains("sessionContext")) { //custom session context not registered. select appropriate default class //depending on whether we are in a web context or not. if (parserContext.getReaderContext().getReader().getResourceLoader() instanceof WebApplicationContext) { BeanDefinition scDef = factory.getBeanDefinition(CONFIG_SESSION_CONTEXT); scDef.setBeanClassName(SpringSessionContext.class.getName()); } } }
From source file:com.seovic.validation.config.ValidationBeanDefinitionParser.java
@SuppressWarnings("unchecked") private BeanDefinition parseValidator(Element element, ParserContext parserContext) { String parent = element.getAttribute("parent"); if ("".equals(parent)) { parent = null;/*from w w w . j ava 2 s . c o m*/ } String test = element.getAttribute("test"); String when = element.getAttribute("when"); String validateAll = element.getAttribute("validate-all"); String context = element.getAttribute("context"); String includeElementsErrors = element.getAttribute("include-element-errors"); MutablePropertyValues properties = new MutablePropertyValues(); if (StringUtils.hasText(test)) { properties.addPropertyValue("test", test); } if (StringUtils.hasText(when)) { properties.addPropertyValue("when", when); } if (StringUtils.hasText(validateAll)) { properties.addPropertyValue("validateAll", validateAll); } if (StringUtils.hasText(context)) { properties.addPropertyValue("context", context); } if (StringUtils.hasText(includeElementsErrors)) { properties.addPropertyValue("includeElementsErrors", includeElementsErrors); } ManagedList nestedValidators = new ManagedList(); ManagedList actions = new ManagedList(); for (int i = 0; i < element.getChildNodes().getLength(); i++) { Node child = element.getChildNodes().item(i); if (child != null && child instanceof Element) { Element childElement = (Element) child; if ("message".equals(childElement.getLocalName())) { actions.add(parseErrorMessageAction(childElement, parserContext)); } else { nestedValidators.add(parseAndRegisterValidator2(childElement, parserContext)); } } } if (nestedValidators.size() > 0) { properties.addPropertyValue("validators", nestedValidators); } if (actions.size() > 0) { properties.addPropertyValue("actions", actions); } String className; if ("required".equals(element.getLocalName())) { className = RequiredValidator.class.getName(); } else if ("condition".equals(element.getLocalName())) { className = ConditionValidator.class.getName(); } else if ("validator".equals(element.getLocalName())) { className = element.getAttribute("type"); } else { className = ValidatorGroup.class.getName(); } AbstractBeanDefinition validatorDefinition; try { validatorDefinition = BeanDefinitionReaderUtils.createBeanDefinition(parent, className, parserContext.getReaderContext().getBeanClassLoader()); } catch (ClassNotFoundException e) { throw new BeanCreationException("Error occured during creation of bean definition", e); } validatorDefinition.setResource(parserContext.getReaderContext().getResource()); validatorDefinition.setSource(parserContext.extractSource(element)); validatorDefinition.setPropertyValues(properties); validatorDefinition.setLazyInit(true); validatorDefinition.setScope("singleton"); return validatorDefinition; }
From source file:org.os890.ds.addon.spring.impl.CdiAwareBeanFactoryPostProcessor.java
private BeanDefinition createSpringBeanDefinition(Bean<?> cdiBean) throws Exception { AbstractBeanDefinition beanDefinition = new GenericBeanDefinition(); Set<Type> beanTypes = new HashSet<Type>(cdiBean.getTypes()); beanTypes.remove(Object.class); beanTypes.remove(Serializable.class); Type beanType = beanTypes.size() == 1 ? beanTypes.iterator().next() : null; if (beanType instanceof Class) { //to support producers beanDefinition.setBeanClass((Class) beanType); } else { //fallback since spring doesn't support multiple types beanDefinition.setBeanClass(cdiBean.getBeanClass()); }/* w ww . j a v a 2s .co m*/ beanDefinition.setScope(CdiSpringScope.class.getName()); for (Annotation qualifier : cdiBean.getQualifiers()) { if (Any.class.equals(qualifier.annotationType()) || Default.class.equals(qualifier.annotationType())) { continue; } //currently only simple qualifiers are supported AutowireCandidateQualifier springQualifier = new AutowireCandidateQualifier(qualifier.annotationType()); for (Method annotationMethod : qualifier.annotationType().getDeclaredMethods()) { if (!annotationMethod.isAnnotationPresent(Nonbinding.class)) { springQualifier.setAttribute(annotationMethod.getName(), annotationMethod.invoke(qualifier)); } } beanDefinition.addQualifier(springQualifier); } beanDefinition.setLazyInit(true); return beanDefinition; }
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
/** * Parse the bean definition itself, without regard to name or aliases. May return <code>null</code> if problems * occurred during the parse of the bean definition. *//*from w w w .j ava2s . c o m*/ private AbstractBeanDefinition parseBeanDefinitionElement(Element ele, String beanName, BeanDefinition containingBean) { this.parseState.push(new BeanEntry(beanName)); String className = null; if (ele.hasAttribute(BeanDefinitionParserDelegate.CLASS_ATTRIBUTE)) { className = ele.getAttribute(BeanDefinitionParserDelegate.CLASS_ATTRIBUTE).trim(); } try { AbstractBeanDefinition beanDefinition = BeanDefinitionReaderUtils.createBeanDefinition(null, className, parserContext.getReaderContext().getBeanClassLoader()); // some early validation String activation = ele.getAttribute(LAZY_INIT_ATTR); String scope = ele.getAttribute(BeanDefinitionParserDelegate.SCOPE_ATTRIBUTE); if (EAGER_INIT_VALUE.equals(activation) && BeanDefinition.SCOPE_PROTOTYPE.equals(scope)) { error("Prototype beans cannot be eagerly activated", ele); } // add marker to indicate that the scope was present if (StringUtils.hasText(scope)) { beanDefinition.setAttribute(DECLARED_SCOPE, Boolean.TRUE); } // parse attributes parseAttributes(ele, beanName, beanDefinition); // inner beans get a predefined scope in RFC 124 if (containingBean != null) { beanDefinition.setLazyInit(true); beanDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE); } // parse description beanDefinition.setDescription( DomUtils.getChildElementValueByTagName(ele, BeanDefinitionParserDelegate.DESCRIPTION_ELEMENT)); parseConstructorArgElements(ele, beanDefinition); parsePropertyElements(ele, beanDefinition); beanDefinition.setResource(parserContext.getReaderContext().getResource()); beanDefinition.setSource(extractSource(ele)); return beanDefinition; } catch (ClassNotFoundException ex) { error("Bean class [" + className + "] not found", ele, ex); } catch (NoClassDefFoundError err) { error("Class that bean class [" + className + "] depends on not found", ele, err); } catch (Throwable ex) { error("Unexpected failure during bean definition parsing", ele, ex); } finally { this.parseState.pop(); } return null; }
From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java
private AbstractBeanDefinition parseAttributes(Element ele, String beanName, AbstractBeanDefinition beanDefinition) { AbstractBeanDefinition bd = parserContext.getDelegate().parseBeanDefinitionAttributes(ele, beanName, null, beanDefinition);//from www.ja v a 2 s .c o m // 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; }
From source file:org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.java
/** * Apply the attributes of the given bean element to the given bean * definition. * @param ele bean declaration element/*from w w w. ja va 2 s . c o m*/ * @param beanName bean name * @param containingBean containing bean definition * @return a bean definition initialized according to the bean element attributes */ public AbstractBeanDefinition parseBeanDefinitionAttributes(Element ele, String beanName, @Nullable BeanDefinition containingBean, AbstractBeanDefinition bd) { if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) { error("Old 1.x 'singleton' attribute in use - upgrade to 'scope' declaration", ele); } else if (ele.hasAttribute(SCOPE_ATTRIBUTE)) { bd.setScope(ele.getAttribute(SCOPE_ATTRIBUTE)); } else if (containingBean != null) { // Take default from containing bean in case of an inner bean definition. bd.setScope(containingBean.getScope()); } if (ele.hasAttribute(ABSTRACT_ATTRIBUTE)) { bd.setAbstract(TRUE_VALUE.equals(ele.getAttribute(ABSTRACT_ATTRIBUTE))); } String lazyInit = ele.getAttribute(LAZY_INIT_ATTRIBUTE); if (DEFAULT_VALUE.equals(lazyInit)) { lazyInit = this.defaults.getLazyInit(); } bd.setLazyInit(TRUE_VALUE.equals(lazyInit)); String autowire = ele.getAttribute(AUTOWIRE_ATTRIBUTE); bd.setAutowireMode(getAutowireMode(autowire)); if (ele.hasAttribute(DEPENDS_ON_ATTRIBUTE)) { String dependsOn = ele.getAttribute(DEPENDS_ON_ATTRIBUTE); bd.setDependsOn(StringUtils.tokenizeToStringArray(dependsOn, MULTI_VALUE_ATTRIBUTE_DELIMITERS)); } String autowireCandidate = ele.getAttribute(AUTOWIRE_CANDIDATE_ATTRIBUTE); if ("".equals(autowireCandidate) || DEFAULT_VALUE.equals(autowireCandidate)) { String candidatePattern = this.defaults.getAutowireCandidates(); if (candidatePattern != null) { String[] patterns = StringUtils.commaDelimitedListToStringArray(candidatePattern); bd.setAutowireCandidate(PatternMatchUtils.simpleMatch(patterns, beanName)); } } else { bd.setAutowireCandidate(TRUE_VALUE.equals(autowireCandidate)); } if (ele.hasAttribute(PRIMARY_ATTRIBUTE)) { bd.setPrimary(TRUE_VALUE.equals(ele.getAttribute(PRIMARY_ATTRIBUTE))); } if (ele.hasAttribute(INIT_METHOD_ATTRIBUTE)) { String initMethodName = ele.getAttribute(INIT_METHOD_ATTRIBUTE); bd.setInitMethodName(initMethodName); } else if (this.defaults.getInitMethod() != null) { bd.setInitMethodName(this.defaults.getInitMethod()); bd.setEnforceInitMethod(false); } if (ele.hasAttribute(DESTROY_METHOD_ATTRIBUTE)) { String destroyMethodName = ele.getAttribute(DESTROY_METHOD_ATTRIBUTE); bd.setDestroyMethodName(destroyMethodName); } else if (this.defaults.getDestroyMethod() != null) { bd.setDestroyMethodName(this.defaults.getDestroyMethod()); bd.setEnforceDestroyMethod(false); } if (ele.hasAttribute(FACTORY_METHOD_ATTRIBUTE)) { bd.setFactoryMethodName(ele.getAttribute(FACTORY_METHOD_ATTRIBUTE)); } if (ele.hasAttribute(FACTORY_BEAN_ATTRIBUTE)) { bd.setFactoryBeanName(ele.getAttribute(FACTORY_BEAN_ATTRIBUTE)); } return bd; }
From source file:org.springframework.beans.factory.xml.DefaultXmlBeanDefinitionParser.java
/** * Parse the BeanDefinition itself, without regard to name or aliases. *//*from w w w .jav a2s . c o m*/ protected BeanDefinition parseBeanDefinitionElement(Element ele, String beanName) throws BeanDefinitionStoreException { String className = null; if (ele.hasAttribute(CLASS_ATTRIBUTE)) { className = ele.getAttribute(CLASS_ATTRIBUTE).trim(); } String parent = null; if (ele.hasAttribute(PARENT_ATTRIBUTE)) { parent = ele.getAttribute(PARENT_ATTRIBUTE); } try { ConstructorArgumentValues cargs = parseConstructorArgElements(ele, beanName); MutablePropertyValues pvs = parsePropertyElements(ele, beanName); AbstractBeanDefinition bd = BeanDefinitionReaderUtils.createBeanDefinition(className, parent, cargs, pvs, getBeanDefinitionReader().getBeanClassLoader()); if (ele.hasAttribute(DEPENDS_ON_ATTRIBUTE)) { String dependsOn = ele.getAttribute(DEPENDS_ON_ATTRIBUTE); bd.setDependsOn(StringUtils.tokenizeToStringArray(dependsOn, BEAN_NAME_DELIMITERS)); } if (ele.hasAttribute(FACTORY_METHOD_ATTRIBUTE)) { bd.setFactoryMethodName(ele.getAttribute(FACTORY_METHOD_ATTRIBUTE)); } if (ele.hasAttribute(FACTORY_BEAN_ATTRIBUTE)) { bd.setFactoryBeanName(ele.getAttribute(FACTORY_BEAN_ATTRIBUTE)); } String dependencyCheck = ele.getAttribute(DEPENDENCY_CHECK_ATTRIBUTE); if (DEFAULT_VALUE.equals(dependencyCheck)) { dependencyCheck = getDefaultDependencyCheck(); } bd.setDependencyCheck(getDependencyCheck(dependencyCheck)); String autowire = ele.getAttribute(AUTOWIRE_ATTRIBUTE); if (DEFAULT_VALUE.equals(autowire)) { autowire = getDefaultAutowire(); } bd.setAutowireMode(getAutowireMode(autowire)); if (ele.hasAttribute(INIT_METHOD_ATTRIBUTE)) { String initMethodName = ele.getAttribute(INIT_METHOD_ATTRIBUTE); if (!"".equals(initMethodName)) { bd.setInitMethodName(initMethodName); } } else { if (getDefaultInitMethod() != null) { bd.setInitMethodName(getDefaultInitMethod()); bd.setEnforceInitMethod(false); } } if (ele.hasAttribute(DESTROY_METHOD_ATTRIBUTE)) { String destroyMethodName = ele.getAttribute(DESTROY_METHOD_ATTRIBUTE); if (!"".equals(destroyMethodName)) { bd.setDestroyMethodName(destroyMethodName); } } else { if (getDefaultDestroyMethod() != null) { bd.setDestroyMethodName(getDefaultDestroyMethod()); bd.setEnforceDestroyMethod(false); } } parseLookupOverrideSubElements(ele, beanName, bd.getMethodOverrides()); parseReplacedMethodSubElements(ele, beanName, bd.getMethodOverrides()); bd.setResourceDescription(getResource().getDescription()); if (ele.hasAttribute(ABSTRACT_ATTRIBUTE)) { bd.setAbstract(TRUE_VALUE.equals(ele.getAttribute(ABSTRACT_ATTRIBUTE))); } if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) { bd.setSingleton(TRUE_VALUE.equals(ele.getAttribute(SINGLETON_ATTRIBUTE))); } String lazyInit = ele.getAttribute(LAZY_INIT_ATTRIBUTE); if (DEFAULT_VALUE.equals(lazyInit) && bd.isSingleton()) { // Just apply default to singletons, as lazy-init has no meaning for prototypes. lazyInit = getDefaultLazyInit(); } bd.setLazyInit(TRUE_VALUE.equals(lazyInit)); return bd; } catch (BeanDefinitionStoreException ex) { throw ex; } catch (ClassNotFoundException ex) { throw new BeanDefinitionStoreException(getResource(), beanName, "Bean class [" + className + "] not found", ex); } catch (NoClassDefFoundError err) { throw new BeanDefinitionStoreException(getResource(), beanName, "Class that bean class [" + className + "] depends on not found", err); } catch (Throwable ex) { throw new BeanDefinitionStoreException(getResource(), beanName, "Unexpected failure during bean definition parsing", ex); } }