use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-integration by spring-projects.
the class StoredProcOutboundGatewayParser method parseHandler.
@Override
protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) {
final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(StoredProcOutboundGateway.class);
final BeanDefinitionBuilder storedProcExecutorBuilder = StoredProcParserUtils.getStoredProcExecutorBuilder(element, parserContext);
IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "is-function");
IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "return-value-required");
IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "use-payload-as-parameter-source");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(storedProcExecutorBuilder, element, "sql-parameter-source-factory");
IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "skip-undeclared-results");
final ManagedMap<String, BeanMetadataElement> returningResultSetMap = StoredProcParserUtils.getReturningResultsetBeanDefinitions(element, parserContext);
if (!returningResultSetMap.isEmpty()) {
storedProcExecutorBuilder.addPropertyValue("returningResultSetRowMappers", returningResultSetMap);
}
final AbstractBeanDefinition storedProcExecutorBuilderBeanDefinition = storedProcExecutorBuilder.getBeanDefinition();
final String gatewayId = this.resolveId(element, builder.getRawBeanDefinition(), parserContext);
final String storedProcExecutorBeanName = gatewayId + ".storedProcExecutor";
parserContext.registerBeanComponent(new BeanComponentDefinition(storedProcExecutorBuilderBeanDefinition, storedProcExecutorBeanName));
builder.addConstructorArgReference(storedProcExecutorBeanName);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "expect-single-result");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout", "sendTimeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "requires-reply");
String replyChannel = element.getAttribute("reply-channel");
if (StringUtils.hasText(replyChannel)) {
builder.addPropertyReference("outputChannel", replyChannel);
}
return builder;
}
use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-integration by spring-projects.
the class StoredProcPollingChannelAdapterParser method parseSource.
@Override
protected BeanMetadataElement parseSource(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(StoredProcPollingChannelAdapter.class);
final BeanDefinitionBuilder storedProcExecutorBuilder = StoredProcParserUtils.getStoredProcExecutorBuilder(element, parserContext);
IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "return-value-required");
IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "is-function");
IntegrationNamespaceUtils.setValueIfAttributeDefined(storedProcExecutorBuilder, element, "skip-undeclared-results");
final ManagedMap<String, BeanMetadataElement> returningResultsetMap = StoredProcParserUtils.getReturningResultsetBeanDefinitions(element, parserContext);
if (!returningResultsetMap.isEmpty()) {
storedProcExecutorBuilder.addPropertyValue("returningResultSetRowMappers", returningResultsetMap);
}
final AbstractBeanDefinition storedProcExecutorBuilderBeanDefinition = storedProcExecutorBuilder.getBeanDefinition();
final String storedProcPollingChannelAdapterId = this.resolveId(element, builder.getRawBeanDefinition(), parserContext);
final String storedProcExecutorBeanName = storedProcPollingChannelAdapterId + ".storedProcExecutor";
parserContext.registerBeanComponent(new BeanComponentDefinition(storedProcExecutorBuilderBeanDefinition, storedProcExecutorBeanName));
builder.addConstructorArgReference(storedProcExecutorBeanName);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "expect-single-result");
return builder.getBeanDefinition();
}
use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-integration by spring-projects.
the class RetrievingJpaOutboundGatewayParser method parseHandler.
@Override
protected BeanDefinitionBuilder parseHandler(Element gatewayElement, ParserContext parserContext) {
final BeanDefinitionBuilder jpaOutboundGatewayBuilder = super.parseHandler(gatewayElement, parserContext);
final BeanDefinitionBuilder jpaExecutorBuilder = JpaParserUtils.getOutboundGatewayJpaExecutorBuilder(gatewayElement, parserContext);
BeanDefinition firstResultExpression = IntegrationNamespaceUtils.createExpressionDefinitionFromValueOrExpression("first-result", "first-result-expression", parserContext, gatewayElement, false);
if (firstResultExpression != null) {
jpaExecutorBuilder.addPropertyValue("firstResultExpression", firstResultExpression);
}
BeanDefinition maxResultsExpression = IntegrationNamespaceUtils.createExpressionDefinitionFromValueOrExpression("max-results", "max-results-expression", parserContext, gatewayElement, false);
if (maxResultsExpression != null) {
jpaExecutorBuilder.addPropertyValue("maxResultsExpression", maxResultsExpression);
}
if (StringUtils.hasText(gatewayElement.getAttribute("id-expression"))) {
String[] otherAttributes = { "jpa-query", "native-query", "named-query", "first-result", "first-result-expression", "max-results", "max-results-expression", "delete-in-batch", "expect-single-result", "parameter-source-factory", "use-payload-as-parameter-source" };
StringBuilder others = new StringBuilder();
for (String otherAttribute : otherAttributes) {
if (gatewayElement.hasAttribute(otherAttribute) && StringUtils.hasText(gatewayElement.getAttribute(otherAttribute))) {
if (others.length() > 0) {
others.append(", ");
}
others.append(otherAttribute);
}
}
boolean childElementsExist = !CollectionUtils.isEmpty(DomUtils.getChildElementsByTagName(gatewayElement, "parameter"));
if (others.length() > 0 || childElementsExist) {
parserContext.getReaderContext().error((others.length() == 0 ? "" : "'" + others.toString() + "' " + (childElementsExist ? "and " : "")) + (childElementsExist ? "child elements " : "") + "not allowed with an 'id-expression' attribute.", gatewayElement);
}
BeanDefinition idExpressionDef = IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("id-expression", gatewayElement);
jpaExecutorBuilder.addPropertyValue("idExpression", idExpressionDef);
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, gatewayElement, "delete-after-poll");
IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, gatewayElement, "flush-after-delete", "flush");
IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, gatewayElement, "delete-in-batch");
IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, gatewayElement, "expect-single-result");
final BeanDefinition jpaExecutorBuilderBeanDefinition = jpaExecutorBuilder.getBeanDefinition();
final String gatewayId = resolveId(gatewayElement, jpaOutboundGatewayBuilder.getRawBeanDefinition(), parserContext);
final String jpaExecutorBeanName = gatewayId + ".jpaExecutor";
parserContext.registerBeanComponent(new BeanComponentDefinition(jpaExecutorBuilderBeanDefinition, jpaExecutorBeanName));
return jpaOutboundGatewayBuilder.addPropertyReference("jpaExecutor", jpaExecutorBeanName).addPropertyValue("gatewayType", OutboundGatewayType.RETRIEVING);
}
use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project spring-integration by spring-projects.
the class UpdatingJpaOutboundGatewayParser method parseHandler.
@Override
protected BeanDefinitionBuilder parseHandler(Element gatewayElement, ParserContext parserContext) {
BeanDefinitionBuilder jpaOutboundGatewayBuilder = super.parseHandler(gatewayElement, parserContext);
BeanDefinitionBuilder jpaExecutorBuilder = JpaParserUtils.getOutboundGatewayJpaExecutorBuilder(gatewayElement, parserContext);
IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, gatewayElement, "persist-mode");
IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, gatewayElement, "flush");
IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, gatewayElement, "flush-size");
IntegrationNamespaceUtils.setValueIfAttributeDefined(jpaExecutorBuilder, gatewayElement, "clear-on-flush");
final BeanDefinition jpaExecutorBuilderBeanDefinition = jpaExecutorBuilder.getBeanDefinition();
final String gatewayId = resolveId(gatewayElement, jpaOutboundGatewayBuilder.getRawBeanDefinition(), parserContext);
final String jpaExecutorBeanName = gatewayId + ".jpaExecutor";
parserContext.registerBeanComponent(new BeanComponentDefinition(jpaExecutorBuilderBeanDefinition, jpaExecutorBeanName));
return jpaOutboundGatewayBuilder.addPropertyReference("jpaExecutor", jpaExecutorBeanName).addPropertyValue("gatewayType", OutboundGatewayType.UPDATING);
}
use of org.springframework.beans.factory.parsing.BeanComponentDefinition in project geronimo-xbean by apache.
the class XBeanNamespaceHandler method parse.
public BeanDefinition parse(Element element, ParserContext parserContext) {
this.parserContext = parserContext;
this.qnameHelper = new XBeanQNameHelper(parserContext.getReaderContext());
BeanDefinitionHolder holder = parseBeanFromExtensionElement(element);
// a 2nd level could be a nested <beans> from Spring 3.1 onwards
if (element.getParentNode() == element.getOwnerDocument() || element.getParentNode().getParentNode() == element.getOwnerDocument() || element.getParentNode().getParentNode().getParentNode() == element.getOwnerDocument()) {
BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
BeanComponentDefinition componentDefinition = new BeanComponentDefinition(holder);
parserContext.getReaderContext().fireComponentRegistered(componentDefinition);
}
return holder.getBeanDefinition();
}
Aggregations