@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { if (element.hasAttribute(ADDRESSES) && (element.hasAttribute(HOST_ATTRIBUTE) || element.hasAttribute(PORT_ATTRIBUTE))) { parserContext.getReaderContext().error("If the 'addresses' attribute is provided, a connection " + "factory can not have 'host' or 'port' attributes.", element); } NamespaceUtils.addConstructorArgParentRefIfAttributeDefined(builder, element, CONNECTION_FACTORY_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, CHANNEL_CACHE_SIZE_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, HOST_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, PORT_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, USER_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, PASSWORD_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, VIRTUAL_HOST_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, EXECUTOR_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, ADDRESSES); NamespaceUtils.setValueIfAttributeDefined(builder, element, PUBLISHER_CONFIRMS); NamespaceUtils.setValueIfAttributeDefined(builder, element, PUBLISHER_RETURNS); NamespaceUtils.setValueIfAttributeDefined(builder, element, REQUESTED_HEARTBEAT, "requestedHeartBeat"); NamespaceUtils.setValueIfAttributeDefined(builder, element, CONNECTION_TIMEOUT); NamespaceUtils.setValueIfAttributeDefined(builder, element, CACHE_MODE); NamespaceUtils.setValueIfAttributeDefined(builder, element, CONNECTION_CACHE_SIZE_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, THREAD_FACTORY, "connectionThreadFactory"); NamespaceUtils.setValueIfAttributeDefined(builder, element, FACTORY_TIMEOUT, "channelCheckoutTimeout"); NamespaceUtils.setValueIfAttributeDefined(builder, element, CONNECTION_LIMIT); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, "connection-name-strategy"); }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { if (element.hasAttribute(ADDRESSES) && (element.hasAttribute(HOST_ATTRIBUTE) || element.hasAttribute(PORT_ATTRIBUTE))) { parserContext.getReaderContext().error("If the 'addresses' attribute is provided, a connection " + "factory can not have 'host' or 'port' attributes.", element); } NamespaceUtils.addConstructorArgParentRefIfAttributeDefined(builder, element, CONNECTION_FACTORY_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, CHANNEL_CACHE_SIZE_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, HOST_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, PORT_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, USER_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, PASSWORD_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, VIRTUAL_HOST_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, EXECUTOR_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, ADDRESSES); NamespaceUtils.setValueIfAttributeDefined(builder, element, PUBLISHER_CONFIRMS); NamespaceUtils.setValueIfAttributeDefined(builder, element, PUBLISHER_RETURNS); NamespaceUtils.setValueIfAttributeDefined(builder, element, REQUESTED_HEARTBEAT, "requestedHeartBeat"); NamespaceUtils.setValueIfAttributeDefined(builder, element, CONNECTION_TIMEOUT); NamespaceUtils.setValueIfAttributeDefined(builder, element, CACHE_MODE); NamespaceUtils.setValueIfAttributeDefined(builder, element, CONNECTION_CACHE_SIZE_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, THREAD_FACTORY, "connectionThreadFactory"); NamespaceUtils.setValueIfAttributeDefined(builder, element, FACTORY_TIMEOUT, "channelCheckoutTimeout"); NamespaceUtils.setValueIfAttributeDefined(builder, element, CONNECTION_LIMIT); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, "connection-name-strategy"); }
/** * Parses 'auto-declare' and 'declared-by' attributes. * * @param element The element. * @param builder The builder. */ public static void parseDeclarationControls(Element element, BeanDefinitionBuilder builder) { NamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-declare", "shouldDeclare"); String admins = element.getAttribute("declared-by"); if (StringUtils.hasText(admins)) { String[] adminBeanNames = admins.split(","); ManagedList<BeanReference> adminBeanRefs = new ManagedList<BeanReference>(); for (String adminBeanName : adminBeanNames) { adminBeanRefs.add(new RuntimeBeanReference(adminBeanName.trim())); } builder.addPropertyValue("adminsThatShouldDeclare", adminBeanRefs); } NamespaceUtils.setValueIfAttributeDefined(builder, element, "ignore-declaration-exceptions"); }
/** * Parses 'auto-declare' and 'declared-by' attributes. * * @param element The element. * @param builder The builder. */ public static void parseDeclarationControls(Element element, BeanDefinitionBuilder builder) { NamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-declare", "shouldDeclare"); String admins = element.getAttribute("declared-by"); if (StringUtils.hasText(admins)) { String[] adminBeanNames = admins.split(","); ManagedList<BeanReference> adminBeanRefs = new ManagedList<BeanReference>(); for (String adminBeanName : adminBeanNames) { adminBeanRefs.add(new RuntimeBeanReference(adminBeanName.trim())); } builder.addPropertyValue("adminsThatShouldDeclare", adminBeanRefs); } NamespaceUtils.setValueIfAttributeDefined(builder, element, "ignore-declaration-exceptions"); }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String connectionFactoryRef = element.getAttribute(CONNECTION_FACTORY_ATTRIBUTE); // At least one of 'templateRef' or 'connectionFactoryRef' attribute must be set. if (!StringUtils.hasText(connectionFactoryRef)) { parserContext.getReaderContext().error("A '" + CONNECTION_FACTORY_ATTRIBUTE + "' attribute must be set.", element); } if (StringUtils.hasText(connectionFactoryRef)) { // Use constructor with connectionFactory parameter builder.addConstructorArgReference(connectionFactoryRef); } String attributeValue; attributeValue = element.getAttribute(AUTO_STARTUP_ATTRIBUTE); if (StringUtils.hasText(attributeValue)) { builder.addPropertyValue("autoStartup", attributeValue); } NamespaceUtils.setValueIfAttributeDefined(builder, element, IGNORE_DECLARATION_EXCEPTIONS); } }
/** * Populates the bean definition property corresponding to the specified attributeName with the value of that * attribute if it is defined in the given element. * * <p> * The property name will be the camel-case equivalent of the lower case hyphen separated attribute (e.g. the * "foo-bar" attribute would match the "fooBar" property). * * @param builder the bean definition builder to be configured * @param element the XML element where the attribute should be defined * @param attributeName the name of the attribute whose value will be set on the property * @return true if defined. * @see Conventions#attributeNameToPropertyName(String) */ public static boolean setValueIfAttributeDefined(BeanDefinitionBuilder builder, Element element, String attributeName) { return setValueIfAttributeDefined(builder, element, attributeName, Conventions.attributeNameToPropertyName(attributeName)); }
/** * Populates the bean definition property corresponding to the specified attributeName with the value of that * attribute if it is defined in the given element. * * <p> * The property name will be the camel-case equivalent of the lower case hyphen separated attribute (e.g. the * "foo-bar" attribute would match the "fooBar" property). * * @param builder the bean definition builder to be configured * @param element the XML element where the attribute should be defined * @param attributeName the name of the attribute whose value will be set on the property * @return true if defined. * @see Conventions#attributeNameToPropertyName(String) */ public static boolean setValueIfAttributeDefined(BeanDefinitionBuilder builder, Element element, String attributeName) { return setValueIfAttributeDefined(builder, element, attributeName, Conventions.attributeNameToPropertyName(attributeName)); }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String connectionFactoryRef = element.getAttribute(CONNECTION_FACTORY_ATTRIBUTE); // At least one of 'templateRef' or 'connectionFactoryRef' attribute must be set. if (!StringUtils.hasText(connectionFactoryRef)) { parserContext.getReaderContext().error("A '" + CONNECTION_FACTORY_ATTRIBUTE + "' attribute must be set.", element); } if (StringUtils.hasText(connectionFactoryRef)) { // Use constructor with connectionFactory parameter builder.addConstructorArgReference(connectionFactoryRef); } String attributeValue; attributeValue = element.getAttribute(AUTO_STARTUP_ATTRIBUTE); if (StringUtils.hasText(attributeValue)) { builder.addPropertyValue("autoStartup", attributeValue); } NamespaceUtils.setValueIfAttributeDefined(builder, element, IGNORE_DECLARATION_EXCEPTIONS); } }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String exchangeName = element.getAttribute(NAME_ATTRIBUTE); builder.addConstructorArgValue(new TypedStringValue(exchangeName)); parseBindings(element, parserContext, builder, exchangeName); NamespaceUtils.addConstructorArgBooleanValueIfAttributeDefined(builder, element, DURABLE_ATTRIBUTE, true); NamespaceUtils.addConstructorArgBooleanValueIfAttributeDefined(builder, element, AUTO_DELETE_ATTRIBUTE, false); NamespaceUtils.setValueIfAttributeDefined(builder, element, DELAYED_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, "internal"); this.parseArguments(element, ARGUMENTS_ELEMENT, parserContext, builder, null); NamespaceUtils.parseDeclarationControls(element, builder); CURRENT_ELEMENT.set(element); }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String exchangeName = element.getAttribute(NAME_ATTRIBUTE); builder.addConstructorArgValue(new TypedStringValue(exchangeName)); parseBindings(element, parserContext, builder, exchangeName); NamespaceUtils.addConstructorArgBooleanValueIfAttributeDefined(builder, element, DURABLE_ATTRIBUTE, true); NamespaceUtils.addConstructorArgBooleanValueIfAttributeDefined(builder, element, AUTO_DELETE_ATTRIBUTE, false); NamespaceUtils.setValueIfAttributeDefined(builder, element, DELAYED_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, "internal"); this.parseArguments(element, ARGUMENTS_ELEMENT, parserContext, builder, null); NamespaceUtils.parseDeclarationControls(element, builder); CURRENT_ELEMENT.set(element); }
NamespaceUtils.setValueIfAttributeDefined(builder, element, CHANNEL_TRANSACTED_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, QUEUE_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, EXCHANGE_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, ROUTING_KEY_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, RECEIVE_TIMEOUT_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, REPLY_TIMEOUT_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, ENCODING_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, MESSAGE_CONVERTER_ATTRIBUTE); String replyAddress = element.getAttribute(REPLY_ADDRESS_ATTRIBUTE); Conventions.attributeNameToPropertyName(REPLY_ADDRESS_ATTRIBUTE)); NamespaceUtils.setValueIfAttributeDefined(builder, element, USE_TEMPORARY_REPLY_QUEUES_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, REPLY_ADDRESS_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETURN_CALLBACK_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, CONFIRM_CALLBACK_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, CORRELATION_KEY); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETRY_TEMPLATE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RECOVERY_CALLBACK); NamespaceUtils.setValueIfAttributeDefined(builder, element, DIRECT_REPLY_TO_CONTAINER, "useDirectReplyToContainer");
NamespaceUtils.setValueIfAttributeDefined(builder, element, CHANNEL_TRANSACTED_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, QUEUE_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, EXCHANGE_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, ROUTING_KEY_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, RECEIVE_TIMEOUT_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, REPLY_TIMEOUT_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, ENCODING_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, MESSAGE_CONVERTER_ATTRIBUTE); String replyAddress = element.getAttribute(REPLY_ADDRESS_ATTRIBUTE); Conventions.attributeNameToPropertyName(REPLY_ADDRESS_ATTRIBUTE)); NamespaceUtils.setValueIfAttributeDefined(builder, element, USE_TEMPORARY_REPLY_QUEUES_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, REPLY_ADDRESS_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETURN_CALLBACK_ATTRIBUTE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, CONFIRM_CALLBACK_ATTRIBUTE); NamespaceUtils.setValueIfAttributeDefined(builder, element, CORRELATION_KEY); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RETRY_TEMPLATE); NamespaceUtils.setReferenceIfAttributeDefined(builder, element, RECOVERY_CALLBACK); NamespaceUtils.setValueIfAttributeDefined(builder, element, DIRECT_REPLY_TO_CONTAINER, "useDirectReplyToContainer");