private string ParseMessageListenerContainer(XmlElement element, ParserContext parserContext) { if (element.HasAttribute("container")) { foreach (string containerAttribute in containerAttributes) { if (element.HasAttribute(containerAttribute)) { parserContext.ReaderContext.ReportException(element, containerAttribute, "The '" + containerAttribute + "' attribute should not be provided when specifying a 'container' reference."); } } return(element.GetAttribute("container")); } ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(SimpleMessageListenerContainer)); string destinationAttribute = this.expectReply ? "request-destination" : "destination"; string destinationNameAttribute = this.expectReply ? "request-destination-name" : "destination-name"; string destination = element.GetAttribute(destinationAttribute); string destinationName = element.GetAttribute(destinationNameAttribute); if (!(StringUtils.HasText(destination) ^ StringUtils.HasText(destinationName))) { parserContext.ReaderContext.ReportException(element, "destination or destination-name", "Exactly one of '" + destinationAttribute + "' or '" + destinationNameAttribute + "' is required."); } builder.AddPropertyReference(NmsAdapterParserUtils.CONNECTION_FACTORY_PROPERTY, NmsAdapterParserUtils.DetermineConnectionFactoryBeanName(element, parserContext)); if (StringUtils.HasText(destination)) { builder.AddPropertyReference("destination", destination); } else { builder.AddPropertyValue("destinationName", destinationName); } AcknowledgementMode acknowledgementMode = NmsAdapterParserUtils.ParseAcknowledgementMode(element, parserContext); if (acknowledgementMode.Equals(AcknowledgementMode.Transactional)) { builder.AddPropertyValue("sessionTransacted", true); } else { builder.AddPropertyValue("sessionAcknowledgeMode", acknowledgementMode); } IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "destination-resolver"); IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "transaction-manager"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "pub-sub-domain"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "concurrent-consumers"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "max-concurrent-consumers"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "max-messages-per-task"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "idle-task-execution-limit"); builder.AddPropertyValue("autoStartup", false); return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.ObjectDefinition)); }
protected override string ParseSource(XmlElement element, ParserContext parserContext) { ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(NmsDestinationPollingSource)); string nmsTemplate = element.GetAttribute(NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE); string destination = element.GetAttribute(NmsAdapterParserUtils.DESTINATION_ATTRIBUTE); string destinationName = element.GetAttribute(NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE); string headerMapper = element.GetAttribute(NmsAdapterParserUtils.HEADER_MAPPER_ATTRIBUTE); if (StringUtils.HasText(nmsTemplate)) { if (element.HasAttribute(NmsAdapterParserUtils.CONNECTION_FACTORY_ATTRIBUTE) || element.HasAttribute(NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE) || element.HasAttribute(NmsAdapterParserUtils.DESTINATION_ATTRIBUTE)) { throw new ObjectCreationException( "When providing '" + NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE + "', none of '" + NmsAdapterParserUtils.CONNECTION_FACTORY_ATTRIBUTE + "', '" + NmsAdapterParserUtils.DESTINATION_ATTRIBUTE + "', or '" + NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE + "' should be provided."); } builder.AddConstructorArgReference(nmsTemplate); } else if (StringUtils.HasText(destination) || StringUtils.HasText(destinationName)) { builder.AddConstructorArgReference(NmsAdapterParserUtils.DetermineConnectionFactoryBeanName(element, parserContext)); if (StringUtils.HasText(destination)) { builder.AddConstructorArgReference(destination); } else if (StringUtils.HasText(destinationName)) { builder.AddConstructorArg(destinationName); } } else { throw new ObjectCreationException("either a '" + NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE + "' or one of '" + NmsAdapterParserUtils.DESTINATION_ATTRIBUTE + "' or '" + NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE + "' attributes must be provided for a polling NMS adapter"); } if (StringUtils.HasText(headerMapper)) { builder.AddPropertyReference(NmsAdapterParserUtils.HEADER_MAPPER_PROPERTY, headerMapper); } IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "extract-payload"); IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "destination-resolver"); return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.ObjectDefinition)); }
protected override AbstractObjectDefinition ParseConsumer(XmlElement element, ParserContext parserContext) { ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(NmsSendingMessageHandler)); string nmsTemplate = element.GetAttribute(NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE); string destination = element.GetAttribute(NmsAdapterParserUtils.DESTINATION_ATTRIBUTE); string destinationName = element.GetAttribute(NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE); string headerMapper = element.GetAttribute(NmsAdapterParserUtils.HEADER_MAPPER_ATTRIBUTE); if (StringUtils.HasText(nmsTemplate)) { if (element.HasAttribute(NmsAdapterParserUtils.CONNECTION_FACTORY_ATTRIBUTE) || element.HasAttribute(NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE) || element.HasAttribute(NmsAdapterParserUtils.DESTINATION_ATTRIBUTE)) { throw new ObjectCreationException( "When providing '" + NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE + "', none of '" + NmsAdapterParserUtils.CONNECTION_FACTORY_ATTRIBUTE + "', '" + NmsAdapterParserUtils.DESTINATION_ATTRIBUTE + "', or '" + NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE + "' should be provided."); } builder.AddPropertyReference(NmsAdapterParserUtils.NMS_TEMPLATE_PROPERTY, nmsTemplate); } else if (StringUtils.HasText(destination) ^ StringUtils.HasText(destinationName)) { builder.AddPropertyReference(NmsAdapterParserUtils.CONNECTION_FACTORY_PROPERTY, NmsAdapterParserUtils.DetermineConnectionFactoryBeanName(element, parserContext)); if (StringUtils.HasText(destination)) { builder.AddPropertyReference(NmsAdapterParserUtils.DESTINATION_PROPERTY, destination); } else { builder.AddPropertyValue(NmsAdapterParserUtils.DESTINATION_NAME_PROPERTY, destinationName); } } else { throw new ObjectCreationException("either a '" + NmsAdapterParserUtils.NMS_TEMPLATE_ATTRIBUTE + "' or one of '" + NmsAdapterParserUtils.DESTINATION_ATTRIBUTE + "' or '" + NmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE + "' attributes must be provided"); } if (StringUtils.HasText(headerMapper)) { builder.AddPropertyReference(NmsAdapterParserUtils.HEADER_MAPPER_PROPERTY, headerMapper); } IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "extract-payload"); return(builder.ObjectDefinition); }