List of usage examples for org.springframework.beans.factory.xml ParserContext getContainingBeanDefinition
@Nullable public final BeanDefinition getContainingBeanDefinition()
From source file:org.mule.security.oauth.config.AbstractDevkitBasedDefinitionParser.java
protected void attachProcessorDefinition(ParserContext parserContext, BeanDefinition definition) { MutablePropertyValues propertyValues = parserContext.getContainingBeanDefinition().getPropertyValues(); if (parserContext.getContainingBeanDefinition().getBeanClassName() .equals("org.mule.config.spring.factories.PollingMessageSourceFactoryBean")) { propertyValues.addPropertyValue("messageProcessor", definition); } else {/*from w w w . ja v a2s . c o m*/ if (parserContext.getContainingBeanDefinition().getBeanClassName() .equals("org.mule.enricher.MessageEnricher")) { propertyValues.addPropertyValue("enrichmentMessageProcessor", definition); } else { PropertyValue messageProcessors = propertyValues.getPropertyValue("messageProcessors"); if ((messageProcessors == null) || (messageProcessors.getValue() == null)) { propertyValues.addPropertyValue("messageProcessors", new ManagedList()); } List listMessageProcessors = ((List) propertyValues.getPropertyValue("messageProcessors") .getValue()); listMessageProcessors.add(definition); } } }
From source file:org.mule.security.oauth.config.AbstractDevkitBasedDefinitionParser.java
protected void attachSourceDefinition(ParserContext parserContext, BeanDefinition definition) { MutablePropertyValues propertyValues = parserContext.getContainingBeanDefinition().getPropertyValues(); propertyValues.addPropertyValue("messageSource", definition); }
From source file:org.springframework.data.jdbc.config.oracle.PoolingDataSourceBeanDefinitionParser.java
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { //ToDo look for username-connection-proxy boolean useWrapper = false; String connectionContextProviderRef = null; Element usernameConnectionProxyElement = DomUtils.getChildElementByTagName(element, USERNAME_CONNECTION_PROXY);//from ww w . jav a 2 s. co m if (usernameConnectionProxyElement != null) { if (logger.isDebugEnabled()) { logger.debug("Using username-connection-proxy"); } if (usernameConnectionProxyElement.hasAttribute(CONNECTION_CONTEXT_PROVIDER)) { if (logger.isDebugEnabled()) { logger.debug(CONNECTION_CONTEXT_PROVIDER + ": " + usernameConnectionProxyElement.getAttribute(CONNECTION_CONTEXT_PROVIDER)); } connectionContextProviderRef = usernameConnectionProxyElement .getAttribute(CONNECTION_CONTEXT_PROVIDER); } useWrapper = true; //builder.addPropertyValue("connectionProperties", connProperties); } BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); builder.getRawBeanDefinition().setBeanClassName(getBeanClassName(element)); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); builder.getRawBeanDefinition().setDestroyMethodName("close"); if (parserContext.isNested()) { // Inner bean definition must receive same scope as containing bean. builder.setScope(parserContext.getContainingBeanDefinition().getScope()); } if (parserContext.isDefaultLazyInit()) { // Default-lazy-init applies to custom bean definitions as well. builder.setLazyInit(true); } doParse(element, parserContext, builder); if (useWrapper) { BeanDefinitionBuilder wrapper = BeanDefinitionBuilder.genericBeanDefinition(); wrapper.getRawBeanDefinition() .setBeanClassName("org.springframework.data.jdbc.support.oracle.ProxyDataSource"); wrapper.addConstructorArgValue(builder.getBeanDefinition()); if (connectionContextProviderRef == null) { wrapper.addConstructorArgValue(null); } else { wrapper.addConstructorArgReference(connectionContextProviderRef); } return wrapper.getBeanDefinition(); } else { return builder.getBeanDefinition(); } }
From source file:org.springframework.integration.config.xml.ChainParser.java
@Override protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) throws BeanDefinitionStoreException { String id = super.resolveId(element, definition, parserContext); BeanDefinition containingBeanDefinition = parserContext.getContainingBeanDefinition(); if (containingBeanDefinition != null) { String nestedChainIdPrefix = (String) containingBeanDefinition .getAttribute(SI_CHAIN_NESTED_ID_ATTRIBUTE); if (StringUtils.hasText(nestedChainIdPrefix)) { id = nestedChainIdPrefix + "$child." + id; }//from w ww. j a v a 2s. c o m } definition.setAttribute(SI_CHAIN_NESTED_ID_ATTRIBUTE, id); return id; }