Search in sources :

Example 1 with WeldFilterImpl

use of org.jboss.weld.metadata.WeldFilterImpl in project core by weld.

the class BeansXmlStreamParser method handleFilter.

private void handleFilter(StartElement filterElement, XMLEventReader reader, Consumer<XmlMetadata<Filter>> consumer) throws XMLStreamException {
    String name = getAttribute(filterElement, NAME_ATTRIBUTE_NAME);
    String pattern = name != null ? null : getAttribute(filterElement, PATTERN_ATTRIBUTE_NAME);
    if (name != null || pattern != null) {
        List<Metadata<SystemPropertyActivation>> systemPropertyActivations = new LinkedList<>();
        List<Metadata<ClassAvailableActivation>> classAvailableActivations = new LinkedList<>();
        while (reader.hasNext()) {
            XMLEvent event = reader.nextEvent();
            if (isEnd(event, EXCLUDE, SCANNING_URIS) || isEnd(event, INCLUDE, SCANNING_URIS)) {
                Filter filter;
                if (filterElement.getName().getNamespaceURI().equals(WELD_URI)) {
                    filter = new WeldFilterImpl(name, systemPropertyActivations, classAvailableActivations, pattern);
                } else {
                    filter = new FilterImpl(name, systemPropertyActivations, classAvailableActivations);
                }
                consumer.accept(new XmlMetadata<Filter>(filterElement.getName().toString(), filter, beansXml, filterElement.getLocation().getLineNumber()));
                return;
            } else if (event.isStartElement()) {
                StartElement element = (StartElement) event;
                if (isStartElement(element, IF_CLASS_AVAILABLE, SCANNING_URIS)) {
                    classAvailable(element, classAvailableActivations::add, false);
                } else if (isStartElement(element, IF_CLASS_NOT_AVAILABLE, SCANNING_URIS)) {
                    classAvailable(element, classAvailableActivations::add, true);
                } else if (isStartElement(element, IF_SYSTEM_PROPERTY, SCANNING_URIS)) {
                    systemProperty(element, systemPropertyActivations::add);
                }
            }
        }
    }
}
Also used : StartElement(javax.xml.stream.events.StartElement) WeldFilterImpl(org.jboss.weld.metadata.WeldFilterImpl) FilterImpl(org.jboss.weld.metadata.FilterImpl) Filter(org.jboss.weld.bootstrap.spi.Filter) Metadata(org.jboss.weld.bootstrap.spi.Metadata) XMLEvent(javax.xml.stream.events.XMLEvent) WeldFilterImpl(org.jboss.weld.metadata.WeldFilterImpl) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 StartElement (javax.xml.stream.events.StartElement)1 XMLEvent (javax.xml.stream.events.XMLEvent)1 Filter (org.jboss.weld.bootstrap.spi.Filter)1 Metadata (org.jboss.weld.bootstrap.spi.Metadata)1 FilterImpl (org.jboss.weld.metadata.FilterImpl)1 WeldFilterImpl (org.jboss.weld.metadata.WeldFilterImpl)1