Java 类org.springframework.beans.factory.xml.ParserContext 实例源码

项目:gemini.blueprint    文件:ParsingUtils.java   
public static BeanDefinitionHolder decorateIfRequired(Node node, BeanDefinitionHolder originalDef,
        ParserContext parserContext) {

    String namespaceUri = node.getNamespaceURI();
    if (!parserContext.getDelegate().isDefaultNamespace(namespaceUri) && !isRFC124Namespace(namespaceUri)) {
        NamespaceHandler handler =
                parserContext.getReaderContext().getNamespaceHandlerResolver().resolve(namespaceUri);
        if (handler != null) {
            return handler.decorate(node, originalDef, new ParserContext(parserContext.getReaderContext(),
                    parserContext.getDelegate()));
        } else if (namespaceUri.startsWith("http://www.springframework.org/")) {
            parserContext.getReaderContext().error(
                    "Unable to locate Spring NamespaceHandler for XML schema namespace [" + namespaceUri + "]",
                    node);
        } else {
            // A custom namespace, not to be handled by Spring - maybe "xml:...".
        }
    }
    return originalDef;
}
项目:dubbox-hystrix    文件:DubboBeanDefinitionParser.java   
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
    NodeList nodeList = element.getChildNodes();
    if (nodeList != null && nodeList.getLength() > 0) {
        boolean first = true;
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node instanceof Element) {
                if (tag.equals(node.getNodeName())
                        || tag.equals(node.getLocalName())) {
                    if (first) {
                        first = false;
                        String isDefault = element.getAttribute("default");
                        if (isDefault == null || isDefault.length() == 0) {
                            beanDefinition.getPropertyValues().addPropertyValue("default", "false");
                        }
                    }
                    BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
                    if (subDefinition != null && ref != null && ref.length() > 0) {
                        subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
                    }
                }
            }
        }
    }
}
项目:JRediClients    文件:RedissonRPCClientDefinitionParser.java   
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
    Class<?> apiClass;
    try {
        apiClass = Class.forName(helper.getAttribute(element,
                RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE));
    } catch (ClassNotFoundException ex) {
        throw new IllegalArgumentException(
                "The class [" + helper.getAttribute(element,
                        RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE)
                        + "] specified in \""
                        + RedissonNamespaceParserSupport.API_CLASS_ATTRIBUTE
                        + "\" attribute has not "
                        + "found. Please check the class path.", ex);
    }
    builder.addPropertyValue("targetObject", new RuntimeBeanReference(
            helper.getAttribute(element,
                    RedissonNamespaceParserSupport.REMOTE_SERVICE_REF_ATTRIBUTE)));
    builder.addPropertyValue("targetMethod", "get");
    builder.addPropertyValue("arguments", new Object[] {apiClass});
}
项目:JRediClients    文件:RedissonGenericObjectDefinitionParser.java   
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
    bd.setFactoryBeanName(element.getAttribute(
            RedissonNamespaceParserSupport.REDISSON_REF_ATTRIBUTE));
    String typeName
            = Conventions.attributeNameToPropertyName(element.getLocalName());
    bd.setFactoryMethodName("get" + StringUtils.capitalize(typeName));

    helper.addConstructorArgs(element, KEY_ATTRIBUTE,
            String.class, builder);
    helper.addConstructorArgs(element, TOPIC_ATTRIBUTE,
            String.class, builder);
    helper.addConstructorArgs(element, PATTERN_ATTRIBUTE,
            String.class, builder);
    helper.addConstructorArgs(element, SERVICE_ATTRIBUTE,
            String.class, builder);
    helper.addConstructorArgs(element, CODEC_REF_ATTRIBUTE,
            Codec.class, builder);
    if (RDestroyable.class.isAssignableFrom(getBeanClass(element))) {
        ((AbstractBeanDefinition) bd).setDestroyMethodName("destroy");
    }
}
项目:lams    文件:JndiLookupBeanDefinitionParser.java   
@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));
    }
}
项目:JRediClients    文件:RedissonDefinitionParser.java   
private void parseChildElements(Element element, String parentId, String redissonRef, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
    if (element.hasChildNodes()) {
        CompositeComponentDefinition compositeDef
                = new CompositeComponentDefinition(parentId,
                        parserContext.extractSource(element));
        parserContext.pushContainingComponent(compositeDef);
        List<Element> childElts = DomUtils.getChildElements(element);
        for (Element elt : childElts) {
            if(BeanDefinitionParserDelegate
                    .QUALIFIER_ELEMENT.equals(elt.getLocalName())) {
                continue;//parsed elsewhere
            }
            String localName = parserContext.getDelegate().getLocalName(elt);
            localName = Conventions.attributeNameToPropertyName(localName);
            if (ConfigType.contains(localName)) {
                parseConfigTypes(elt, localName, redissonDef, parserContext);
            } else if (AddressType.contains(localName)) {
                parseAddressTypes(elt, localName, redissonDef, parserContext);
            } else if (helper.isRedissonNS(elt)) {
                elt.setAttribute(REDISSON_REF, redissonRef);
                parserContext.getDelegate().parseCustomElement(elt);
            }
        }
        parserContext.popContainingComponent();
    }
}
项目:lams    文件:TxAdviceBeanDefinitionParser.java   
@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"));
    }
}
项目:JRediClients    文件:AbstractRedissonNamespaceDefinitionParser.java   
@Override
protected final void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    Assert.state(helper.isRedissonNS(element),
            "Illegal state. "
                    + this.getClass().getName()
            + " can only parse "
                    + RedissonNamespaceParserSupport.REDISSON_NAMESPACE
            + " namespace elements");
    Assert.state(element.hasAttribute(parentRefAttribute),
            "Illegal state. property \"" + parentRefAttribute 
                    + "\" is required in the \""
            + helper.getName(element)
            + "\" element.");

    helper.populateIdAttribute(element, builder, parserContext);
    AbstractBeanDefinition bd = builder.getRawBeanDefinition();
    parseNested(element, parserContext, builder, bd);
    decorator.decorate(element, parserContext, builder, helper);
    parserContext.getDelegate().parseQualifierElements(element, bd);
    if (parserContext.isNested()) {
        helper.registerBeanDefinition(builder, element, parserContext);
    }
}
项目:gemini.blueprint    文件:ReferenceParsingUtil.java   
public static void checkAvailabilityAndCardinalityDuplication(Element element, String availabilityName,
        String cardinalityName, ParserContext context) {

    String avail = element.getAttribute(availabilityName);
    String cardinality = element.getAttribute(cardinalityName);

    if (StringUtils.hasText(avail) && StringUtils.hasText(cardinality)) {
        boolean availStatus = avail.startsWith(ONE);
        boolean cardStatus = cardinality.startsWith(M);

        if (availStatus != cardStatus) {
            context.getReaderContext().error(
                    "Both '" + availabilityName + "' and '" + cardinalityName
                            + "' attributes have been specified but with contradictory values.", element);
        }
    }
}
项目:JRediClients    文件:RedissonNamespaceParserSupport.java   
public void parseAttributes(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    NamedNodeMap attributes = element.getAttributes();
    for (int x = 0; x < attributes.getLength(); x++) {
        Attr attribute = (Attr) attributes.item(x);
        if (isEligibleAttribute(attribute)) {
            String propertyName
                    = attribute.getLocalName().endsWith(REF_SUFFIX)
                            ? attribute.getLocalName()
                                    .substring(0, attribute.getLocalName()
                                            .length() - REF_SUFFIX.length())
                            : attribute.getLocalName();
            propertyName = Conventions
                    .attributeNameToPropertyName(propertyName);
            Assert.state(StringUtils.hasText(propertyName),
                    "Illegal property name returned from"
                            + " 'extractPropertyName(String)': cannot be"
                            + " null or empty.");
            if (attribute.getLocalName().endsWith(REF_SUFFIX)) {
                builder.addPropertyReference(propertyName,
                        attribute.getValue());
            } else {
                builder.addPropertyValue(propertyName, attribute.getValue());
            }
        }
    }
}
项目:gemini.blueprint    文件:BlueprintServiceDefinitionParser.java   
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    // first check the attributes
    if (element.hasAttribute(AUTOEXPORT) && !DISABLED.equals(element.getAttribute(AUTOEXPORT).trim())) {
        if (element.hasAttribute(INTERFACE)) {
            parserContext.getReaderContext().error(
                    "either 'auto-export' or 'interface' attribute has be specified but not both", element);
        }
        if (DomUtils.getChildElementByTagName(element, INTERFACES) != null) {
            parserContext.getReaderContext().error(
                    "either 'auto-export' attribute or <intefaces> sub-element has be specified but not both",
                    element);

        }

    }

    builder.addPropertyValue(CACHE_TARGET, true);
    super.doParse(element, parserContext, builder);
}
项目:lams    文件:AnnotationConfigBeanDefinitionParser.java   
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    Object source = parserContext.extractSource(element);

    // Obtain bean definitions for all relevant BeanPostProcessors.
    Set<BeanDefinitionHolder> processorDefinitions =
            AnnotationConfigUtils.registerAnnotationConfigProcessors(parserContext.getRegistry(), source);

    // Register component for the surrounding <context:annotation-config> element.
    CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
    parserContext.pushContainingComponent(compDefinition);

    // Nest the concrete beans in the surrounding component.
    for (BeanDefinitionHolder processorDefinition : processorDefinitions) {
        parserContext.registerComponent(new BeanComponentDefinition(processorDefinition));
    }

    // Finally register the composite component.
    parserContext.popAndRegisterContainingComponent();

    return null;
}
项目:gemini.blueprint    文件:BlueprintDefaultsDefinition.java   
/**
 * Constructs a new <code>BlueprintDefaultsDefinition</code> instance.
 * @param parserContext
 * 
 * @param root
 */
public BlueprintDefaultsDefinition(Document doc, ParserContext parserContext) {
    super(doc, parserContext);
    Element root = doc.getDocumentElement();
    String timeout = getAttribute(root, BLUEPRINT_NS, DEFAULT_TIMEOUT);
    setTimeout(StringUtils.hasText(timeout) ? timeout.trim() : TIMEOUT_DEFAULT);

    String availability = getAttribute(root, BLUEPRINT_NS, DEFAULT_AVAILABILITY);
    if (StringUtils.hasText(availability)) {
        Availability avail = ReferenceParsingUtil.determineAvailability(availability);
        setAvailability(avail);
    }

    // default initialization
    String initialization = getAttribute(root, BLUEPRINT_NS, DEFAULT_INITIALIZATION);
    defaultInitialization =
            (StringUtils.hasText(initialization) ? initialization.trim().equalsIgnoreCase(LAZY_INITIALIZATION)
                    : INITIALIZATION_DEFAULT);
}
项目:dubbocloud    文件:DubboBeanDefinitionParser.java   
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
    NodeList nodeList = element.getChildNodes();
    if (nodeList != null && nodeList.getLength() > 0) {
        boolean first = true;
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node instanceof Element) {
                if (tag.equals(node.getNodeName())
                        || tag.equals(node.getLocalName())) {
                    if (first) {
                        first = false;
                        String isDefault = element.getAttribute("default");
                        if (isDefault == null || isDefault.length() == 0) {
                            beanDefinition.getPropertyValues().addPropertyValue("default", "false");
                        }
                    }
                    BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
                    if (subDefinition != null && ref != null && ref.length() > 0) {
                        subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
                    }
                }
            }
        }
    }
}
项目:JRediClients    文件:RedissonNamespaceParserSupport.java   
private BeanDefinitionBuilder preInvoke(Element element, Object obj, String method, Object[] args, ParserContext parserContext, boolean factory) {
    BeanDefinitionBuilder builder
            = createBeanDefinitionBuilder(element, parserContext,
                    factory
                            ? MethodInvokingFactoryBean.class
                            : BeanMethodInvoker.class);
    if (obj instanceof Class) {
        builder.addPropertyValue("staticMethod",
                ((Class) obj).getName() + "." + method);
    } else {
        builder.addPropertyValue("targetMethod", method);
    }
    builder.addPropertyValue("arguments", args);
    if (element != null) {
        parserContext.getDelegate().parseQualifierElements(element,
                builder.getRawBeanDefinition());
    }
    return builder;
}
项目:lams    文件:AspectJAutoProxyBeanDefinitionParser.java   
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) {
    ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>();
    NodeList childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node node = childNodes.item(i);
        if (node instanceof Element) {
            Element includeElement = (Element) node;
            TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name"));
            valueHolder.setSource(parserContext.extractSource(includeElement));
            includePatterns.add(valueHolder);
        }
    }
    if (!includePatterns.isEmpty()) {
        includePatterns.setSource(parserContext.extractSource(element));
        beanDef.getPropertyValues().add("includePatterns", includePatterns);
    }
}
项目:lams    文件:ConfigBeanDefinitionParser.java   
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    CompositeComponentDefinition compositeDef =
            new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element));
    parserContext.pushContainingComponent(compositeDef);

    configureAutoProxyCreator(parserContext, element);

    List<Element> childElts = DomUtils.getChildElements(element);
    for (Element elt: childElts) {
        String localName = parserContext.getDelegate().getLocalName(elt);
        if (POINTCUT.equals(localName)) {
            parsePointcut(elt, parserContext);
        }
        else if (ADVISOR.equals(localName)) {
            parseAdvisor(elt, parserContext);
        }
        else if (ASPECT.equals(localName)) {
            parseAspect(elt, parserContext);
        }
    }

    parserContext.popAndRegisterContainingComponent();
    return null;
}
项目:dubbo2    文件:DubboBeanDefinitionParser.java   
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
    NodeList nodeList = element.getChildNodes();
    if (nodeList != null && nodeList.getLength() > 0) {
        boolean first = true;
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node instanceof Element) {
                if (tag.equals(node.getNodeName())
                        || tag.equals(node.getLocalName())) {
                    if (first) {
                        first = false;
                        String isDefault = element.getAttribute("default");
                        if (isDefault == null || isDefault.length() == 0) {
                            beanDefinition.getPropertyValues().addPropertyValue("default", "false");
                        }
                    }
                    BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
                    if (subDefinition != null && ref != null && ref.length() > 0) {
                        subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
                    }
                }
            }
        }
    }
}
项目:hekate    文件:HekateBeanDefinitionParser.java   
@Override
protected String resolveId(Element el, AbstractBeanDefinition def, ParserContext ctx) {
    String id = super.resolveId(el, def, ctx);

    deferredBaseBeans.forEach((baseBeanBuilder, baseBeanName) -> {
        baseBeanBuilder.addPropertyValue("source", new RuntimeBeanReference(id));

        AbstractBeanDefinition baseBean = baseBeanBuilder.getBeanDefinition();

        if (baseBeanName == null) {
            ctx.getRegistry().registerBeanDefinition(ctx.getReaderContext().generateBeanName(baseBean), baseBean);
        } else {
            ctx.getRegistry().registerBeanDefinition(baseBeanName, baseBean);
        }
    });

    return id;
}
项目:hekate    文件:HekateBeanDefinitionParser.java   
private Optional<RuntimeBeanReference> parseMessagingBackPressure(Element el, ParserContext ctx) {
    Element backPressureEl = getChildElementByTagName(el, "back-pressure");

    if (backPressureEl != null) {
        BeanDefinitionBuilder backPressure = newBean(MessagingBackPressureConfig.class, backPressureEl);

        Element outboundEl = getChildElementByTagName(backPressureEl, "outbound");
        Element inboundEl = getChildElementByTagName(backPressureEl, "inbound");

        if (outboundEl != null) {
            setProperty(backPressure, outboundEl, "outLowWatermark", "low-watermark");
            setProperty(backPressure, outboundEl, "outHighWatermark", "high-watermark");
            setProperty(backPressure, outboundEl, "outOverflowPolicy", "overflow");
        }

        if (inboundEl != null) {
            setProperty(backPressure, inboundEl, "inLowWatermark", "low-watermark");
            setProperty(backPressure, inboundEl, "inHighWatermark", "high-watermark");
        }

        return Optional.of(registerInnerBean(backPressure, ctx));
    } else {
        return Optional.empty();
    }
}
项目:parabuild-ci    文件:DwrNamespaceHandler.java   
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext)
{
    BeanDefinitionRegistry registry = parserContext.getRegistry();
    BeanDefinition config = registerSpringConfiguratorIfNecessary(registry);

    StringBuffer sigtext = new StringBuffer();
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++)
    {
        Node child = children.item(i);
        if (child.getNodeType() != Node.TEXT_NODE && child.getNodeType() != Node.CDATA_SECTION_NODE)
        {
            log.warn("Ignoring illegal node type: " + child.getNodeType());
            continue;
        }
        sigtext.append(child.getNodeValue());
    }

    config.getPropertyValues().addPropertyValue("signatures", sigtext.toString());

    return definition;
}
项目:hekate    文件:HekateBeanDefinitionParser.java   
private Optional<RuntimeBeanReference> parseClusterMetricsService(Element rootEl, ParserContext ctx) {
    Element metricsEl = getChildElementByTagName(rootEl, "cluster-metrics");

    if (metricsEl != null) {
        BeanDefinitionBuilder metrics = newBean(ClusterMetricsServiceFactory.class, metricsEl);

        setProperty(metrics, metricsEl, "enabled", "enabled");
        setProperty(metrics, metricsEl, "replicationInterval", "replication-interval-ms");

        setBeanOrRef(metrics, metricsEl, "replicationFilter", "filter", ctx);

        String id = metricsEl.getAttribute("id");

        if (!id.isEmpty()) {
            deferredBaseBeans.put(newLazyBean(ClusterMetricsServiceBean.class, metricsEl), id);
        }

        return Optional.of(registerInnerBean(metrics, ctx));
    } else {
        return Optional.empty();
    }
}
项目:gemini.blueprint    文件:ParsingUtils.java   
public static BeanDefinitionHolder register(Element ele, BeanDefinitionHolder bdHolder, ParserContext parserContext) {
    if (bdHolder != null) {
        String name = bdHolder.getBeanName();
        checkReservedName(name, ele, parserContext);
        checkUniqueName(name, parserContext.getRegistry());
        try {
            // add non-lenient constructor resolution
            BeanDefinition beanDefinition = bdHolder.getBeanDefinition();
            if (beanDefinition instanceof AbstractBeanDefinition) {
                AbstractBeanDefinition abd = (AbstractBeanDefinition) beanDefinition;
                abd.setLenientConstructorResolution(false);
                abd.setNonPublicAccessAllowed(false);
            }

            // Register the final decorated instance.
            BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, parserContext.getRegistry());
        } catch (BeanDefinitionStoreException ex) {
            parserContext.getReaderContext().error(
                    "Failed to register bean definition with name '" + bdHolder.getBeanName() + "'", ele, ex);
        }
        // register component (and send registration events)
        parserContext.registerComponent(new BeanComponentDefinition(bdHolder));
    }
    return bdHolder;
}
项目:gemini.blueprint    文件:ConfigPropertiesDefinitionParser.java   
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    // parse attributes using conventions
    super.doParse(element, parserContext, builder);

    // parse nested element (if any)
    Properties parsedProps = parserContext.getDelegate().parsePropsElement(element);
    if (!parsedProps.isEmpty()) {
        if (builder.getRawBeanDefinition().getPropertyValues().contains(PROPERTIES_PROP)) {
            parserContext.getReaderContext().error(
                "Property '" + PROPERTIES_PROP
                        + "' is defined more then once. Only one approach may be used per property.", element);

        }
        builder.addPropertyValue(PROPERTIES_PROP, parsedProps);
    }
}
项目:lams    文件:CacheAdviceParser.java   
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    builder.addPropertyReference("cacheManager", CacheNamespaceHandler.extractCacheManager(element));
    CacheNamespaceHandler.parseKeyGenerator(element, builder.getBeanDefinition());

    List<Element> cacheDefs = DomUtils.getChildElementsByTagName(element, DEFS_ELEMENT);
    if (cacheDefs.size() >= 1) {
        // Using attributes source.
        List<RootBeanDefinition> attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext);
        builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions);
    } else {
        // Assume annotations source.
        builder.addPropertyValue("cacheOperationSources", new RootBeanDefinition(
                AnnotationCacheOperationSource.class));
    }
}
项目:bdf2    文件:ResourcesElementParser.java   
public Resource[] parse(Node rootNode, ParserContext parserContext) {
    NamedNodeMap nodeMap=rootNode.getAttributes();
    String locations=getAttributeValue("locations",nodeMap);
    if(StringUtils.isNotEmpty(locations)){
        String[] locationsArray=locations.split(LOCATION_SEPARATOR);
        List<Resource> resources=new ArrayList<Resource>();
        for(int i=0;i<locationsArray.length;i++){
            String location=locationsArray[i];
            if(StringUtils.isNotEmpty(location)){
                resources.add(resourcePatternResolver.getResource(location));                   
            }
        }
        return resources.toArray(new Resource[resources.size()]);
    }else{
        return null;            
    }
}
项目:shibboleth-idp-oidc-extension    文件:AbstractOIDCEncoderParser.java   
/** {@inheritDoc} */
@Override
protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
        @Nonnull final BeanDefinitionBuilder builder) {

    super.doParse(config, parserContext, builder);
    if (config.hasAttributeNS(null, AS_ARRAY_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asArray",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_ARRAY_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_INT_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asInt",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_INT_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, STRING_DELIMETER_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("stringDelimiter",
                StringSupport.trimOrNull(config.getAttributeNS(null, STRING_DELIMETER_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_OBJECT_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asObject",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_OBJECT_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, FIELD_NAME_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("fieldName",
                StringSupport.trimOrNull(config.getAttributeNS(null, FIELD_NAME_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_BOOLEAN_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asBoolean",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_BOOLEAN_ATTRIBUTE_NAME)));
    }
}
项目:lams    文件:LoadTimeWeaverBeanDefinitionParser.java   
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);

    if (isAspectJWeavingEnabled(element.getAttribute(ASPECTJ_WEAVING_ATTRIBUTE), parserContext)) {
        RootBeanDefinition weavingEnablerDef = new RootBeanDefinition();
        weavingEnablerDef.setBeanClassName(ASPECTJ_WEAVING_ENABLER_CLASS_NAME);
        parserContext.getReaderContext().registerWithGeneratedName(weavingEnablerDef);

        if (isBeanConfigurerAspectEnabled(parserContext.getReaderContext().getBeanClassLoader())) {
            new SpringConfiguredBeanDefinitionParser().parse(element, parserContext);
        }
    }
}
项目:shibboleth-idp-oidc-extension    文件:AttributeInOIDCRequestedClaimsRuleParser.java   
/** {@inheritDoc} */
@Override
protected void doNativeParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
        @Nonnull final BeanDefinitionBuilder builder) {
    super.doParse(config, builder);


    if (config.hasAttributeNS(null, "onlyIfEssential")) {
        builder.addPropertyValue("onlyIfEssential",
                StringSupport.trimOrNull(config.getAttributeNS(null, "onlyIfEssential")));
    }

    if (config.hasAttributeNS(null, "matchOnlyIDToken")) {
        builder.addPropertyValue("matchOnlyIDToken",
                StringSupport.trimOrNull(config.getAttributeNS(null, "matchOnlyIDToken")));
    }

    if (config.hasAttributeNS(null, "matchOnlyUserInfo")) {
        builder.addPropertyValue("matchOnlyUserInfo",
                StringSupport.trimOrNull(config.getAttributeNS(null, "matchOnlyUserInfo")));
    }

    if (config.hasAttributeNS(null, "matchIfRequestedClaimsSilent")) {
        builder.addPropertyValue("matchIfRequestedClaimsSilent",
                StringSupport.trimOrNull(config.getAttributeNS(null, "matchIfRequestedClaimsSilent")));
    }

}
项目:parabuild-ci    文件:DwrNamespaceHandler.java   
public BeanDefinition parse(Element element, ParserContext parserContext)
{
    BeanDefinitionBuilder dwrController = BeanDefinitionBuilder.rootBeanDefinition(DwrController.class);
    List configurators = new ManagedList();
    configurators.add(new RuntimeBeanReference(DEFAULT_SPRING_CONFIGURATOR_ID));
    dwrController.addPropertyValue("configurators", configurators);

    String debug = element.getAttribute("debug");
    if (StringUtils.hasText(debug))
    {
        dwrController.addPropertyValue("debug", debug);
    }

    String beanName = element.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE);
    String nameAttr = element.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE);
    String[] aliases = null;
    if (!StringUtils.hasText(beanName))
    {
        beanName = element.getAttribute("name");
    }
    else
    {
        String aliasName = element.getAttribute("name");
        if (StringUtils.hasText(aliasName))
        {
            aliases = StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
        }
    }

    parseControllerParameters(dwrController, element);

    BeanDefinitionHolder holder = new BeanDefinitionHolder(dwrController.getBeanDefinition(), beanName, aliases);
    BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());

    return dwrController.getBeanDefinition();
}
项目:lams    文件:ConfigBeanDefinitionParser.java   
/**
 * Parses the supplied {@code &lt;pointcut&gt;} and registers the resulting
 * Pointcut with the BeanDefinitionRegistry.
 */
private AbstractBeanDefinition parsePointcut(Element pointcutElement, ParserContext parserContext) {
    String id = pointcutElement.getAttribute(ID);
    String expression = pointcutElement.getAttribute(EXPRESSION);

    AbstractBeanDefinition pointcutDefinition = null;

    try {
        this.parseState.push(new PointcutEntry(id));
        pointcutDefinition = createPointcutDefinition(expression);
        pointcutDefinition.setSource(parserContext.extractSource(pointcutElement));

        String pointcutBeanName = id;
        if (StringUtils.hasText(pointcutBeanName)) {
            parserContext.getRegistry().registerBeanDefinition(pointcutBeanName, pointcutDefinition);
        }
        else {
            pointcutBeanName = parserContext.getReaderContext().registerWithGeneratedName(pointcutDefinition);
        }

        parserContext.registerComponent(
                new PointcutComponentDefinition(pointcutBeanName, pointcutDefinition, expression));
    }
    finally {
        this.parseState.pop();
    }

    return pointcutDefinition;
}
项目:JRediClients    文件:RedissonDefinitionParser.java   
private void parseAddressTypes(Element element, String addressType, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
    BeanComponentDefinition invoker = helper.invoker(element,
            parserContext.getContainingComponent().getName(),
            "add" + StringUtils.capitalize(addressType),
            new String[]{element.getAttribute("value")},
            parserContext);
    String id = invoker.getName();
    redissonDef.addDependsOn(id);
}
项目:saluki    文件:GrpcServiceBeanDefinitionParser.java   
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ServiceBean.class);
    this.setInterface(element, builder);
    this.setGroup(element, builder);
    this.setVersion(element, builder);
    this.setRef(element, builder);
    return builder.getBeanDefinition();
}
项目:lams    文件:EmbeddedDatabaseBeanDefinitionParser.java   
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(EmbeddedDatabaseFactoryBean.class);
    setDatabaseType(element, builder);
    DatabasePopulatorConfigUtils.setDatabasePopulator(element, builder);
    useIdAsDatabaseNameIfGiven(element, builder);
    builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
    return builder.getBeanDefinition();
}
项目:JRediClients    文件:RedissonNamespaceParserSupport.java   
public String getId(Element element, BeanDefinitionBuilder builder, ParserContext parserContext) {
    String id = element != null
            ? element.getAttribute(ID_ATTRIBUTE)
            : null;
    if (!StringUtils.hasText(id)) {
        id = generateId(builder, parserContext);
    }
    return id;
}
项目:gemini.blueprint    文件:ServiceBeanDefinitionParser.java   
protected void applyDefaults(ParserContext parserContext, OsgiDefaultsDefinition defaults,
        BeanDefinitionBuilder builder) {
    if (parserContext.isDefaultLazyInit()) {
        // Default-lazy-init applies to custom bean definitions as well.
        builder.setLazyInit(true);
    }
}
项目:lams    文件:AnnotationDrivenBeanDefinitionParser.java   
private void registerAsyncExecutionAspect(Element element, ParserContext parserContext) {
    if (!parserContext.getRegistry().containsBeanDefinition(AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)) {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
                AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_CLASS_NAME);
        builder.setFactoryMethod("aspectOf");
        String executor = element.getAttribute("executor");
        if (StringUtils.hasText(executor)) {
            builder.addPropertyReference("executor", executor);
        }
        parserContext.registerBeanComponent(
                new BeanComponentDefinition(builder.getBeanDefinition(),
                        AnnotationConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME));
    }
}
项目:gemini.blueprint    文件:BlueprintBeanDefinitionParser.java   
public BeanDefinition parse(Element componentsRootElement, ParserContext parserContext) {
    // re-initialize defaults
    BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
    delegate.initDefaults(componentsRootElement);

    NodeList nl = componentsRootElement.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++) {
        Node node = nl.item(i);
        if (node instanceof Element) {
            Element ele = (Element) node;
            String namespaceUri = ele.getNamespaceURI();
            // check beans namespace
            if (delegate.isDefaultNamespace(namespaceUri)) {
                BeanDefinitionHolder holder = delegate.parseBeanDefinitionElement(ele);
                ParsingUtils.decorateAndRegister(ele, holder, parserContext);
            }
            // handle own components
            else if (BlueprintParser.NAMESPACE_URI.equals(namespaceUri)) {
                parseTopLevelElement(ele, parserContext);
            }
            // leave the delegate to find a parser for it
            else {
                delegate.parseCustomElement(ele);
            }
        }
    }

    return null;
}
项目:mango    文件:MangoBeanDefinitionParser.java   
private static void parseSingleRef(String property, Element element, BeanDefinition bd,
                                   ParserContext parserContext) {

    String value = element.getAttribute(property);
    if (StringUtils.isNotBlank(value)) {
        if (parserContext.getRegistry().containsBeanDefinition(value)) {
            BeanDefinition refBean = parserContext.getRegistry().getBeanDefinition(value);
            if (!refBean.isSingleton()) {
                throw new IllegalStateException("The exported service ref " + value + " must be singleton! Please set the " + value
                        + " bean scope to singleton, eg: <bean id=\"" + value + "\" scope=\"singleton\" ...>");
            }
        }
        bd.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(value));
    }
}
项目:lams    文件:AspectJAutoProxyBeanDefinitionParser.java   
private void extendBeanDefinition(Element element, ParserContext parserContext) {
    BeanDefinition beanDef =
            parserContext.getRegistry().getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
    if (element.hasChildNodes()) {
        addIncludePatterns(element, parserContext, beanDef);
    }
}