/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2012, Red Hat, Inc., and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.jboss.as.server.deployment.jbossallxml;

import javax.xml.namespace.QName;

import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;

/**
 * DUP that registers a {@link JBossAllXMLParserDescription} with the DU. These should all be registered in the
 * {@link org.jboss.as.server.deployment.Phase#STRUCTURE_REGISTER_JBOSS_ALL_XML_PARSER} phase.
 *
 * @author Stuart Douglas
 */
public class JBossAllXmlParserRegisteringProcessor<T> implements DeploymentUnitProcessor {

    private final JBossAllXMLParserDescription<T> description;

    public JBossAllXmlParserRegisteringProcessor(final QName rootElement, final AttachmentKey<T> attachmentKey, final JBossAllXMLParser<T> parser) {
        description = new JBossAllXMLParserDescription<T>(attachmentKey, parser, rootElement);
    }

    @Override
    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        phaseContext.getDeploymentUnit().addToAttachmentList(JBossAllXMLParserDescription.ATTACHMENT_KEY, description);
    }

    @Override
    public void undeploy(final DeploymentUnit context) {

    }
}

@@ -1070,16 +1070,99 @@
 llxml;%0A%0A
+import java.util.Collections;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0A
 import j
@@ -1844,24 +1844,39 @@
 ivate final 
+List%3C? extends 
 JBossAllXMLP
@@ -1892,17 +1892,18 @@
 ription%3C
-T
+?%3E
 %3E descri
@@ -1907,16 +1907,17 @@
 cription
+s
 ;%0A%0A    p
@@ -2083,11 +2083,38 @@
 tion
+s
  = 
+Collections.singletonList(
 new 
@@ -2180,16 +2180,180 @@
 Element)
+);%0A    %7D%0A%0A    private JBossAllXmlParserRegisteringProcessor(List%3C? extends JBossAllXMLParserDescription%3C?%3E%3E descriptions) %7B%0A        this.descriptions = descriptions
 ;%0A    %7D%0A
@@ -2476,16 +2476,95 @@
 ption %7B%0A
+        for (JBossAllXMLParserDescription%3C?%3E description : descriptions) %7B%0A    
         
@@ -2675,16 +2675,26 @@
 ption);%0A
+        %7D%0A
     %7D%0A%0A 
@@ -2769,11 +2769,970 @@
 %7B%0A%0A    %7D
+%0A%0A    public static Builder builder() %7B%0A        return new Builder();%0A    %7D%0A%0A    /**%0A     * Builder for building JBossAllXmlParserRegisteringProcessor that registers multiple parsers at once. Useful%0A     * for cases when parsers for multiple versions of a particular schema are registered.%0A     *%0A     * @author Jozef Hartinger%0A     *%0A     */%0A    public static final class Builder %7B%0A%0A        private final List%3CJBossAllXMLParserDescription%3C?%3E%3E descriptions = new LinkedList%3C%3E();%0A%0A        private Builder() %7B%0A        %7D%0A%0A        public %3CT%3E Builder addParser(final QName rootElement, final AttachmentKey%3CT%3E attachmentKey, final JBossAllXMLParser%3CT%3E parser) %7B%0A            descriptions.add(new JBossAllXMLParserDescription%3CT%3E(attachmentKey, parser, rootElement));%0A            return this;%0A        %7D%0A%0A        public JBossAllXmlParserRegisteringProcessor%3CObject%3E build() %7B%0A            return new JBossAllXmlParserRegisteringProcessor%3C%3E(descriptions);%0A        %7D%0A    %7D
 %0A%7D%0A

Add builder for JBossAllXmlParserRegisteringProcessor