Refine search
@Override @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { parserContext.getReaderContext().error( "Class [" + getClass().getName() + "] does not support custom elements.", element); return null; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String path = element.getAttribute("path"); if (!StringUtils.hasText(path)) { parserContext.getReaderContext().error("Attribute 'path' must not be empty", element); return; } int dotIndex = path.indexOf('.'); if (dotIndex == -1) { parserContext.getReaderContext().error( "Attribute 'path' must follow pattern 'beanName.propertyName'", element); return; } String beanName = path.substring(0, dotIndex); String propertyPath = path.substring(dotIndex + 1); builder.addPropertyValue("targetBeanName", beanName); builder.addPropertyValue("propertyPath", propertyPath); }
@Override @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { String basePackage = element.getAttribute(BASE_PACKAGE_ATTRIBUTE); basePackage = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(basePackage); String[] basePackages = StringUtils.tokenizeToStringArray(basePackage, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); // Actually scan for bean definitions and register them. ClassPathBeanDefinitionScanner scanner = configureScanner(parserContext, element); Set<BeanDefinitionHolder> beanDefinitions = scanner.doScan(basePackages); registerComponents(parserContext.getReaderContext(), beanDefinitions, element); return null; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { location = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(location); String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } String propertiesRef = element.getAttribute("properties-ref"); if (StringUtils.hasLength(propertiesRef)) { builder.addPropertyReference("properties", propertiesRef); } String fileEncoding = element.getAttribute("file-encoding"); if (StringUtils.hasLength(fileEncoding)) { builder.addPropertyValue("fileEncoding", fileEncoding); } String order = element.getAttribute("order"); if (StringUtils.hasLength(order)) { builder.addPropertyValue("order", Integer.valueOf(order)); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); String defaultValue = element.getAttribute(DEFAULT_VALUE); String defaultRef = element.getAttribute(DEFAULT_REF); if (StringUtils.hasLength(defaultValue)) { if (StringUtils.hasLength(defaultRef)) { parserContext.getReaderContext().error("<jndi-lookup> element is only allowed to contain either " + "'default-value' attribute OR 'default-ref' attribute, not both", element); } builder.addPropertyValue(DEFAULT_OBJECT, defaultValue); } else if (StringUtils.hasLength(defaultRef)) { builder.addPropertyValue(DEFAULT_OBJECT, new RuntimeBeanReference(defaultRef)); } }
@Override @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { parserContext.getReaderContext().error( "Class [" + getClass().getName() + "] does not support custom elements.", element); return null; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { Properties parsedProps = parserContext.getDelegate().parsePropsElement(element); builder.addPropertyValue("properties", parsedProps); String location = element.getAttribute("location"); if (StringUtils.hasLength(location)) { location = parserContext.getReaderContext().getEnvironment().resolvePlaceholders(location); String[] locations = StringUtils.commaDelimitedListToStringArray(location); builder.addPropertyValue("locations", locations); } builder.addPropertyValue("ignoreResourceNotFound", Boolean.valueOf(element.getAttribute("ignore-resource-not-found"))); builder.addPropertyValue("localOverride", Boolean.valueOf(element.getAttribute("local-override"))); String scope = element.getAttribute(SCOPE_ATTRIBUTE); if (StringUtils.hasLength(scope)) { builder.setScope(scope); } } }
@Nullable protected Integer parseAcknowledgeMode(Element ele, ParserContext parserContext) { String acknowledge = ele.getAttribute(ACKNOWLEDGE_ATTRIBUTE); if (StringUtils.hasText(acknowledge)) { int acknowledgeMode = Session.AUTO_ACKNOWLEDGE; if (ACKNOWLEDGE_TRANSACTED.equals(acknowledge)) { acknowledgeMode = Session.SESSION_TRANSACTED; } else if (ACKNOWLEDGE_DUPS_OK.equals(acknowledge)) { acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE; } else if (ACKNOWLEDGE_CLIENT.equals(acknowledge)) { acknowledgeMode = Session.CLIENT_ACKNOWLEDGE; } else if (!ACKNOWLEDGE_AUTO.equals(acknowledge)) { parserContext.getReaderContext().error("Invalid listener container 'acknowledge' setting [" + acknowledge + "]: only \"auto\", \"client\", \"dups-ok\" and \"transacted\" supported.", ele); } return acknowledgeMode; } else { return null; } }
private void attrNotAllowed(ParserContext context, String attrName, String otherAttrName, Element element) { context.getReaderContext().error( "Only one of '" + attrName + "' or '" + otherAttrName + "' can be set.", element); }
public static RuntimeBeanReference registerHandshakeHandler( Element element, ParserContext context, @Nullable Object source) { RuntimeBeanReference handlerRef; Element handlerElem = DomUtils.getChildElementByTagName(element, "handshake-handler"); if (handlerElem != null) { handlerRef = new RuntimeBeanReference(handlerElem.getAttribute("ref")); } else { RootBeanDefinition defaultHandlerDef = new RootBeanDefinition(DefaultHandshakeHandler.class); defaultHandlerDef.setSource(source); defaultHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); String handlerName = context.getReaderContext().registerWithGeneratedName(defaultHandlerDef); handlerRef = new RuntimeBeanReference(handlerName); } return handlerRef; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String cleanup = element.getAttribute("verifierLengthBytes"); if (StringUtils.hasText(cleanup)) { try { builder.addPropertyValue("verifierLengthBytes", Integer.parseInt(cleanup)); } catch (NumberFormatException e) { parserContext.getReaderContext().error("Invalid value " + cleanup + " for attribute verifierLengthBytes.", element); } } } }
@Override @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { parserContext.getReaderContext().error( "Class [" + getClass().getName() + "] does not support custom elements.", element); return null; }
private RuntimeBeanReference getConversionService(Element element, @Nullable Object source, ParserContext context) { RuntimeBeanReference conversionServiceRef; if (element.hasAttribute("conversion-service")) { conversionServiceRef = new RuntimeBeanReference(element.getAttribute("conversion-service")); } else { RootBeanDefinition conversionDef = new RootBeanDefinition(FormattingConversionServiceFactoryBean.class); conversionDef.setSource(source); conversionDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); String conversionName = context.getReaderContext().registerWithGeneratedName(conversionDef); context.registerComponent(new BeanComponentDefinition(conversionDef, conversionName)); conversionServiceRef = new RuntimeBeanReference(conversionName); } return conversionServiceRef; }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String cleanup = element.getAttribute("cleanupInterval"); if (StringUtils.hasText(cleanup)) { try { builder.addPropertyValue("cleanupIntervalSeconds", Integer.parseInt(cleanup)); } catch (NumberFormatException e) { parserContext.getReaderContext().error("Invalid value " + cleanup + " for attribute cleanupIntervalSeconds.", element); } } } }
@Override @Nullable public BeanDefinition parse(Element element, ParserContext parserContext) { parserContext.getReaderContext().error( "Class [" + getClass().getName() + "] does not support custom elements.", element); return null; }
@Nullable private RuntimeBeanReference getValidator(Element element, @Nullable Object source, ParserContext context) { if (element.hasAttribute("validator")) { return new RuntimeBeanReference(element.getAttribute("validator")); } else if (javaxValidationPresent) { RootBeanDefinition validatorDef = new RootBeanDefinition( "org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean"); validatorDef.setSource(source); validatorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); String validatorName = context.getReaderContext().registerWithGeneratedName(validatorDef); context.registerComponent(new BeanComponentDefinition(validatorDef, validatorName)); return new RuntimeBeanReference(validatorName); } else { return null; } }
protected void parseListenerConfiguration(Element ele, ParserContext parserContext, MutablePropertyValues configValues) { String destination = ele.getAttribute(DESTINATION_ATTRIBUTE); if (!StringUtils.hasText(destination)) { parserContext.getReaderContext().error( "Listener 'destination' attribute contains empty value.", ele); String subscription = ele.getAttribute(SUBSCRIPTION_ATTRIBUTE); if (!StringUtils.hasText(subscription)) { parserContext.getReaderContext().error( "Listener 'subscription' attribute contains empty value.", ele); String selector = ele.getAttribute(SELECTOR_ATTRIBUTE); if (!StringUtils.hasText(selector)) { parserContext.getReaderContext().error( "Listener 'selector' attribute contains empty value.", ele); String concurrency = ele.getAttribute(CONCURRENCY_ATTRIBUTE); if (!StringUtils.hasText(concurrency)) { parserContext.getReaderContext().error( "Listener 'concurrency' attribute contains empty value.", ele);
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { builder.addPropertyReference("transactionManager", TxNamespaceHandler.getTransactionManagerName(element)); List<Element> txAttributes = DomUtils.getChildElementsByTagName(element, ATTRIBUTES_ELEMENT); if (txAttributes.size() > 1) { parserContext.getReaderContext().error( "Element <attributes> is allowed at most once inside element <advice>", element); } else if (txAttributes.size() == 1) { // Using attributes source. Element attributeSourceElement = txAttributes.get(0); RootBeanDefinition attributeSourceDefinition = parseAttributeSource(attributeSourceElement, parserContext); builder.addPropertyValue("transactionAttributeSource", attributeSourceDefinition); } else { // Assume annotations source. builder.addPropertyValue("transactionAttributeSource", new RootBeanDefinition("org.springframework.transaction.annotation.AnnotationTransactionAttributeSource")); } }
@Nullable private RuntimeBeanReference getValidator( Element messageBrokerElement, @Nullable Object source, ParserContext context) { if (messageBrokerElement.hasAttribute("validator")) { return new RuntimeBeanReference(messageBrokerElement.getAttribute("validator")); } else if (javaxValidationPresent) { RootBeanDefinition validatorDef = new RootBeanDefinition( "org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean"); validatorDef.setSource(source); validatorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); String validatorName = context.getReaderContext().registerWithGeneratedName(validatorDef); context.registerComponent(new BeanComponentDefinition(validatorDef, validatorName)); return new RuntimeBeanReference(validatorName); } else { return null; } }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String path = element.getAttribute("path"); if (!StringUtils.hasText(path)) { parserContext.getReaderContext().error("Attribute 'path' must not be empty", element); return; } int dotIndex = path.indexOf('.'); if (dotIndex == -1) { parserContext.getReaderContext().error( "Attribute 'path' must follow pattern 'beanName.propertyName'", element); return; } String beanName = path.substring(0, dotIndex); String propertyPath = path.substring(dotIndex + 1); builder.addPropertyValue("targetBeanName", beanName); builder.addPropertyValue("propertyPath", propertyPath); }