geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r931020 [3/6] - in /geronimo/server/trunk: framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ plugins/j2ee/geronimo-web-2.5-bu...
Date Tue, 06 Apr 2010 05:14:12 GMT
Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbLocalRefMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbLocalRefMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbLocalRefMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbLocalRefMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,115 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.ElementSource;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.web25.deployment.merge.MergeItem;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
+import org.apache.geronimo.xbeans.javaee6.EjbLocalRefType;
+import org.apache.geronimo.xbeans.javaee6.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EjbLocalRefMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String EJB_LOCAL_REF_NAME_PREFIX = "ejb-local-ref.ejb-ref-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a ejb-local-ref in the current merged web.xml file, then
+     *     a.1 If it is from web-fragment.xml, throw an error, as it is not allowed that the same ejb-local-ref in different web-fragment.xml while it is not present in web.xml
+     *     a.2 Else it is from web.xml, check whether inject-target is configured in the initial web.xml, if not, merge the configurations from web-fragment.xml, else ignore.
+     * b. web.xml file should inherit it from the web-fragment.xml file
+     */
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (EjbLocalRefType srcEjbLocalRef : webFragment.getEjbLocalRefArray()) {
+            String ejbLocalRefName = srcEjbLocalRef.getEjbRefName().getStringValue();
+            String ejbLocalRefKey = createEjbLocalRefKey(ejbLocalRefName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(ejbLocalRefKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("ejb-local-ref", ejbLocalRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isEjbLocalRefInjectTargetsConfiguredInInitialWebXML(ejbLocalRefName, mergeContext)) {
+                    //Merge InjectTarget
+                    EjbLocalRefType ejbLocalRef = (EjbLocalRefType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcEjbLocalRef.getInjectionTargetArray()) {
+                        String ejbLocalRefInjectTargetKey = createEjbLocalRefInjectTargetKey(ejbLocalRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(ejbLocalRefInjectTargetKey)) {
+                            ejbLocalRef.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(ejbLocalRefInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                EjbLocalRefType targetEjbLocalRef = (EjbLocalRefType) webApp.addNewEjbLocalRef().set(srcEjbLocalRef);
+                mergeContext.setAttribute(ejbLocalRefKey, new MergeItem(targetEjbLocalRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetEjbLocalRef.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createEjbLocalRefInjectTargetKey(ejbLocalRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                            .getStringValue()), Boolean.TRUE);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (EjbLocalRefType ejbLocalRef : webApp.getEjbLocalRefArray()) {
+            String ejbLocalRefName = ejbLocalRef.getEjbRefName().getStringValue();
+            mergeContext.setAttribute(createEjbLocalRefKey(ejbLocalRefName), new MergeItem(ejbLocalRef, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (ejbLocalRef.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createEjbLocalRefInjectTargetConfiguredInWebXMLKey(ejbLocalRefName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : ejbLocalRef.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createEjbLocalRefInjectTargetKey(ejbLocalRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createEjbLocalRefInjectTargetConfiguredInWebXMLKey(String ejbLocalRefName) {
+        return EJB_LOCAL_REF_NAME_PREFIX + ejbLocalRefName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createEjbLocalRefInjectTargetKey(String ejbLocalRefName, String injectTargetClassName, String injectTargetName) {
+        return EJB_LOCAL_REF_NAME_PREFIX + ejbLocalRefName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createEjbLocalRefKey(String ejbLocalRefName) {
+        return EJB_LOCAL_REF_NAME_PREFIX + ejbLocalRefName;
+    }
+
+    public static boolean isEjbLocalRefInjectTargetConfigured(String ejbLocalRefName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createEjbLocalRefInjectTargetKey(ejbLocalRefName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isEjbLocalRefInjectTargetsConfiguredInInitialWebXML(String ejbLocalRefName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createEjbLocalRefInjectTargetConfiguredInWebXMLKey(ejbLocalRefName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbLocalRefMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbLocalRefMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbLocalRefMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbRefMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbRefMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbRefMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbRefMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,115 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.ElementSource;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.web25.deployment.merge.MergeItem;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
+import org.apache.geronimo.xbeans.javaee6.EjbRefType;
+import org.apache.geronimo.xbeans.javaee6.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EjbRefMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String EJB_REF_NAME_PREFIX = "ejb-ref.ejb-ref-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a ejb-ref in the current merged web.xml file, then
+     *     a.1 If it is from web-fragment.xml, throw an error, as it is not allowed that the same ejb-ref in different web-fragment.xml while it is not present in web.xml
+     *     a.2 Else it is from web.xml, check whether inject-target is configured in the initial web.xml, if not, merge the configurations from web-fragment.xml, else ignore.
+     * b. web.xml file should inherit it from the web-fragment.xml file
+     */
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (EjbRefType srcEjbRef : webFragment.getEjbRefArray()) {
+            String ejbRefName = srcEjbRef.getEjbRefName().getStringValue();
+            String ejbRefKey = createEjbRefKey(ejbRefName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(ejbRefKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("ejb-ref", ejbRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isEjbRefInjectTargetsConfiguredInInitialWebXML(ejbRefName, mergeContext)) {
+                    //Merge InjectTarget
+                    EjbRefType ejbRef = (EjbRefType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcEjbRef.getInjectionTargetArray()) {
+                        String ejbRefInjectTargetKey = createEjbRefInjectTargetKey(ejbRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(ejbRefInjectTargetKey)) {
+                            ejbRef.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(ejbRefInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                EjbRefType targetEjbRef = (EjbRefType) webApp.addNewEjbRef().set(srcEjbRef);
+                mergeContext.setAttribute(ejbRefKey, new MergeItem(targetEjbRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetEjbRef.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createEjbRefInjectTargetKey(ejbRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                            .getStringValue()), Boolean.TRUE);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (EjbRefType ejbRef : webApp.getEjbRefArray()) {
+            String ejbRefName = ejbRef.getEjbRefName().getStringValue();
+            mergeContext.setAttribute(createEjbRefKey(ejbRefName), new MergeItem(ejbRef, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (ejbRef.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createEjbRefInjectTargetConfiguredInWebXMLKey(ejbRefName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : ejbRef.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createEjbRefInjectTargetKey(ejbRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createEjbRefInjectTargetConfiguredInWebXMLKey(String ejbRefName) {
+        return EJB_REF_NAME_PREFIX + ejbRefName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createEjbRefInjectTargetKey(String ejbRefName, String injectTargetClassName, String injectTargetName) {
+        return EJB_REF_NAME_PREFIX + ejbRefName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createEjbRefKey(String ejbRefName) {
+        return EJB_REF_NAME_PREFIX + ejbRefName;
+    }
+
+    public static boolean isEjbRefInjectTargetConfigured(String ejbRefName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createEjbRefInjectTargetKey(ejbRefName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isEjbRefInjectTargetsConfiguredInInitialWebXML(String ejbRefName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createEjbRefInjectTargetConfiguredInWebXMLKey(ejbRefName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbRefMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbRefMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EjbRefMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EnvEntryMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EnvEntryMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EnvEntryMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EnvEntryMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,115 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.ElementSource;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.web25.deployment.merge.MergeItem;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
+import org.apache.geronimo.xbeans.javaee6.EnvEntryType;
+import org.apache.geronimo.xbeans.javaee6.InjectionTargetType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EnvEntryMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String ENV_ENTRY_NAME_PREFIX = "env-entry.env-entry-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a env-entry in the current merged web.xml file, then
+     *     a.1 If it is from web-fragment.xml, throw an error, as it is not allowed that the same env-entry in different web-fragment.xml while it is not present in web.xml
+     *     a.2 Else it is from web.xml, check whether inject-target is configured in the initial web.xml, if not, merge the configurations from web-fragment.xml, else ignore.
+     * b. web.xml file should inherit it from the web-fragment.xml file
+     */
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (EnvEntryType srcEnvEntry : webFragment.getEnvEntryArray()) {
+            String envEntryName = srcEnvEntry.getEnvEntryName().getStringValue();
+            String envEntryKey = createEnvEntryKey(envEntryName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(envEntryKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("env-entry", envEntryName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isEnvEntryInjectTargetsConfiguredInInitialWebXML(envEntryName, mergeContext)) {
+                    //Merge InjectTarget
+                    EnvEntryType envEntry = (EnvEntryType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcEnvEntry.getInjectionTargetArray()) {
+                        String envEntryInjectTargetKey = createEnvEntryInjectTargetKey(envEntryName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(envEntryInjectTargetKey)) {
+                            envEntry.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(envEntryInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                EnvEntryType targetEnvEntry = (EnvEntryType) webApp.addNewEnvEntry().set(srcEnvEntry);
+                mergeContext.setAttribute(envEntryKey, new MergeItem(targetEnvEntry, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetEnvEntry.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createEnvEntryInjectTargetKey(envEntryName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                            .getStringValue()), Boolean.TRUE);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (EnvEntryType envEntry : webApp.getEnvEntryArray()) {
+            String envEntryName = envEntry.getEnvEntryName().getStringValue();
+            mergeContext.setAttribute(createEnvEntryKey(envEntryName), new MergeItem(envEntry, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (envEntry.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createEnvEntryInjectTargetConfiguredInWebXMLKey(envEntryName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : envEntry.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createEnvEntryInjectTargetKey(envEntryName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createEnvEntryInjectTargetConfiguredInWebXMLKey(String envEntryName) {
+        return ENV_ENTRY_NAME_PREFIX + envEntryName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createEnvEntryInjectTargetKey(String envEntryName, String injectTargetClassName, String injectTargetName) {
+        return ENV_ENTRY_NAME_PREFIX + envEntryName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createEnvEntryKey(String envEntryName) {
+        return ENV_ENTRY_NAME_PREFIX + envEntryName;
+    }
+
+    public static boolean isEnvEntryInjectTargetConfigured(String envEntryName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createEnvEntryInjectTargetKey(envEntryName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isEnvEntryInjectTargetsConfiguredInInitialWebXML(String envEntryName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createEnvEntryInjectTargetConfiguredInWebXMLKey(envEntryName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EnvEntryMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EnvEntryMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/EnvEntryMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ErrorPageMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ErrorPageMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ErrorPageMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ErrorPageMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,76 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.ElementSource;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.web25.deployment.merge.MergeItem;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
+import org.apache.geronimo.xbeans.javaee6.ErrorPageType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ErrorPageMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (ErrorPageType errorPage : webFragment.getErrorPageArray()) {
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(createErrorPageKey(errorPage));
+            if (mergeItem != null) {
+                if (mergeItem.getSourceType().equals(ElementSource.WEB_XML)) {
+                    continue;
+                } else if (mergeItem.getValue().equals(errorPage.getLocation().getStringValue())) {
+                    boolean isErrorCodeConfigured = errorPage.getErrorCode() != null;
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("error-page", isErrorCodeConfigured ? "error-code" : "exception-type", isErrorCodeConfigured ? errorPage
+                            .getErrorCode().getStringValue() : errorPage.getExceptionType().getStringValue(), "location", (String) mergeItem.getValue(), mergeItem.getBelongedURL(), errorPage
+                            .getLocation().getStringValue(), mergeContext.getCurrentJarUrl()));
+                }
+            } else {
+                webApp.addNewErrorPage().set(errorPage);
+                mergeContext.setAttribute(createErrorPageKey(errorPage), new MergeItem(errorPage.getLocation().getStringValue(), mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (ErrorPageType errorPage : webApp.getErrorPageArray()) {
+            context.setAttribute(createErrorPageKey(errorPage), new MergeItem(errorPage.getLocation().getStringValue(), null, ElementSource.WEB_XML));
+        }
+    }
+
+    public static final String createErrorCodeKey(String errorCode) {
+        return "error-page.error-code." + errorCode;
+    }
+
+    public static final String createExceptionTypeKey(String exceptionType) {
+        return "error-page.exception-type." + exceptionType;
+    }
+
+    public static final String createErrorPageKey(ErrorPageType errorPage) {
+        return errorPage.getErrorCode() == null ? createExceptionTypeKey(errorPage.getExceptionType().getStringValue()) : createErrorCodeKey(errorPage.getErrorCode().getStringValue());
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ErrorPageMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ErrorPageMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ErrorPageMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,101 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.ElementSource;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.web25.deployment.merge.MergeItem;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
+import org.apache.geronimo.xbeans.javaee6.FilterType;
+import org.apache.geronimo.xbeans.javaee6.ParamValueType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FilterInitParamMergeHandler implements SubMergeHandler<FilterType, FilterType> {
+
+    @Override
+    public void add(FilterType servlet, MergeContext mergeContext) throws DeploymentException {
+        String servletName = servlet.getFilterName().getStringValue();
+        for (ParamValueType paramValue : servlet.getInitParamArray()) {
+            addFilterInitParam(servletName, paramValue, ElementSource.WEB_FRAGMENT, mergeContext.getCurrentJarUrl(), mergeContext);
+        }
+    }
+
+    @Override
+    public void merge(FilterType srcFilter, FilterType targetFilter, MergeContext mergeContext) throws DeploymentException {
+        String filterName = srcFilter.getFilterName().getStringValue();
+        for (ParamValueType paramValue : srcFilter.getInitParamArray()) {
+            MergeItem existedMergeItem = (MergeItem) mergeContext.getAttribute(createFilterInitParamKey(filterName, paramValue.getParamName().getStringValue()));
+            if (existedMergeItem == null) {
+                targetFilter.addNewInitParam().set(paramValue);
+                addFilterInitParam(filterName, paramValue, ElementSource.WEB_FRAGMENT, mergeContext.getCurrentJarUrl(), mergeContext);
+            } else {
+                ParamValueType existedParamValue = (ParamValueType) existedMergeItem.getValue();
+                switch (existedMergeItem.getSourceType()) {
+                case WEB_XML:
+                    continue;
+                case WEB_FRAGMENT:
+                    if (!existedParamValue.getParamValue().getStringValue().equals(paramValue.getParamValue().getStringValue())) {
+                        throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("filter " + filterName, "param-name", paramValue.getParamName().getStringValue(), "param-value",
+                                existedParamValue.getParamValue().getStringValue(), existedMergeItem.getBelongedURL(), paramValue.getParamValue().getStringValue(), mergeContext.getCurrentJarUrl()));
+                    }
+                    break;
+                case ANNOTATION:
+                    //Spec 8.1.n.iii Init params for servlets and filters defined via annotations, will be
+                    //overridden in the descriptor if the name of the init param exactly matches
+                    //the name specified via the annotation. Init params are additive between the
+                    //annotations and descriptors.
+                    //In my understanding, the value of init-param should be overridden even if it is merged from annotation before the current web-fragment.xml file
+                    existedParamValue.getParamValue().set(paramValue.getParamValue());
+                    existedMergeItem.setBelongedURL(mergeContext.getCurrentJarUrl());
+                    existedMergeItem.setSourceType(ElementSource.WEB_FRAGMENT);
+                }
+            }
+        }
+
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (FilterType filter : webApp.getFilterArray()) {
+            String filterName = filter.getFilterName().getStringValue();
+            for (ParamValueType paramValue : filter.getInitParamArray()) {
+                addFilterInitParam(filterName, paramValue, ElementSource.WEB_XML, null, context);
+            }
+        }
+    }
+
+    public static String createFilterInitParamKey(String filterName, String paramName) {
+        return "filter." + filterName + ".init-param.param-name." + paramName;
+    }
+
+    public static boolean isFilterInitParamConfigured(String filterName, String paramName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createFilterInitParamKey(filterName, paramName));
+    }
+
+    public static void addFilterInitParam(String filterName, ParamValueType paramValue, ElementSource source, String relativeUrl, MergeContext mergeContext) {
+        mergeContext.setAttribute(createFilterInitParamKey(filterName, paramValue.getParamName().getStringValue()), new MergeItem(paramValue, relativeUrl, source));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingDispatcherMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingDispatcherMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingDispatcherMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingDispatcherMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,72 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.xbeans.javaee6.DispatcherType;
+import org.apache.geronimo.xbeans.javaee6.FilterMappingType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FilterMappingDispatcherMergeHandler implements SubMergeHandler<FilterMappingType, FilterMappingType> {
+
+    @Override
+    public void add(FilterMappingType filterMapping, MergeContext mergeContext) throws DeploymentException {
+        String filterName = filterMapping.getFilterName().getStringValue();
+        for (DispatcherType dispatcher : filterMapping.getDispatcherArray()) {
+            mergeContext.setAttribute(createFilterMappingDispatcherKey(filterName, dispatcher.getStringValue(), mergeContext), Boolean.TRUE);
+        }
+    }
+
+    @Override
+    public void merge(FilterMappingType srcFilterMapping, FilterMappingType targetFilterMapping, MergeContext mergeContext) throws DeploymentException {
+        String filterName = srcFilterMapping.getFilterName().getStringValue();
+        for (DispatcherType dispatcher : srcFilterMapping.getDispatcherArray()) {
+            if (isFilterMappingDispatcherConfigured(filterName, dispatcher.getStringValue(), mergeContext)) {
+                continue;
+            }
+            mergeContext.setAttribute(createFilterMappingDispatcherKey(filterName, dispatcher.getStringValue(), mergeContext), Boolean.TRUE);
+            targetFilterMapping.addNewDispatcher().setStringValue(dispatcher.getStringValue());
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (FilterMappingType filterMapping : webApp.getFilterMappingArray()) {
+            String filterName = filterMapping.getFilterName().getStringValue();
+            for (DispatcherType dispatcher : filterMapping.getDispatcherArray()) {
+                context.setAttribute(createFilterMappingDispatcherKey(filterName, dispatcher.getStringValue(), context), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createFilterMappingDispatcherKey(String filterName, String dispatcherValue, MergeContext mergeContext) {
+        return "filter-mapping.filter-name." + filterName + ".dispatcher." + dispatcherValue;
+    }
+
+    public static boolean isFilterMappingDispatcherConfigured(String filterName, String dispatcherValue, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createFilterMappingDispatcherKey(filterName, dispatcherValue, mergeContext));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingDispatcherMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingDispatcherMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingDispatcherMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,115 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.ElementSource;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.xbeans.javaee6.DispatcherType;
+import org.apache.geronimo.xbeans.javaee6.FilterMappingType;
+import org.apache.geronimo.xbeans.javaee6.ServletNameType;
+import org.apache.geronimo.xbeans.javaee6.UrlPatternType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FilterMappingMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    private List<SubMergeHandler<FilterMappingType, FilterMappingType>> subMergeHandlers;
+
+    public FilterMappingMergeHandler() {
+        subMergeHandlers = new ArrayList<SubMergeHandler<FilterMappingType, FilterMappingType>>();
+        subMergeHandlers.add(new FilterMappingUrlPatternMergeHandler());
+        subMergeHandlers.add(new FilterMappingServletNameMergeHandler());
+        subMergeHandlers.add(new FilterMappingDispatcherMergeHandler());
+    }
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (FilterMappingType srcFilterMapping : webFragment.getFilterMappingArray()) {
+            String filterName = srcFilterMapping.getFilterName().getStringValue();
+            FilterMappingType targetFilterMapping = (FilterMappingType) mergeContext.getAttribute(createFilterMappingKey(filterName));
+            if (targetFilterMapping == null) {
+                targetFilterMapping = (FilterMappingType) webApp.addNewFilterMapping().set(srcFilterMapping);
+                mergeContext.setAttribute(createFilterMappingKey(filterName), targetFilterMapping);
+                for (SubMergeHandler<FilterMappingType, FilterMappingType> subMergeHandler : subMergeHandlers) {
+                    subMergeHandler.add(targetFilterMapping, mergeContext);
+                }
+            } else {
+                if (isFilterMappingFromAnnotation(filterName, mergeContext)) {
+                    //If the current url-patterns configurations are from annotations, so let's drop them
+                    targetFilterMapping.setUrlPatternArray(new UrlPatternType[0]);
+                    targetFilterMapping.setDispatcherArray(new DispatcherType[0]);
+                    targetFilterMapping.setServletNameArray(new ServletNameType[0]);
+                    mergeContext.removeAttribute(createFilterMappingSourceKey(filterName));
+                }
+                for (SubMergeHandler<FilterMappingType, FilterMappingType> subMergeHandler : subMergeHandlers) {
+                    subMergeHandler.merge(srcFilterMapping, targetFilterMapping, mergeContext);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (SubMergeHandler<FilterMappingType, FilterMappingType> subMergeHandler : subMergeHandlers) {
+            subMergeHandler.postProcessWebXmlElement(webApp, context);
+        }
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (FilterMappingType filterMapping : webApp.getFilterMappingArray()) {
+            String filterName = filterMapping.getFilterName().getStringValue();
+            context.setAttribute(createFilterMappingKey(filterName), filterMapping);
+        }
+        for (SubMergeHandler<FilterMappingType, FilterMappingType> subMergeHandler : subMergeHandlers) {
+            subMergeHandler.preProcessWebXmlElement(webApp, context);
+        }
+    }
+
+    public static String createFilterMappingKey(String filterName) {
+        return "filter-mapping.filter-name" + filterName;
+    }
+
+    public static boolean isFilterMappingConfigured(String filterName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createFilterMappingKey(filterName));
+    }
+
+    public static FilterMappingType getFilterMappingType(String filterName, MergeContext mergeContext) {
+        return (FilterMappingType) mergeContext.getAttribute(createFilterMappingKey(filterName));
+    }
+
+    public static String createFilterMappingSourceKey(String filterName) {
+        return "filter-mapping.filter-name." + filterName + ".sources";
+    }
+
+    public static boolean isFilterMappingFromAnnotation(String filterName, MergeContext mergeContext) {
+        ElementSource elementSource = (ElementSource) mergeContext.getAttribute(createFilterMappingSourceKey(filterName));
+        return elementSource != null && elementSource.equals(ElementSource.ANNOTATION);
+    }
+
+    public static void addFilterMapping(FilterMappingType filterMapping, MergeContext mergeContext) {
+        mergeContext.setAttribute(createFilterMappingKey(filterMapping.getFilterName().getStringValue()), filterMapping);
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingServletNameMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingServletNameMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingServletNameMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingServletNameMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,68 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.xbeans.javaee6.FilterMappingType;
+import org.apache.geronimo.xbeans.javaee6.ServletNameType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FilterMappingServletNameMergeHandler implements SubMergeHandler<FilterMappingType, FilterMappingType> {
+
+    @Override
+    public void add(FilterMappingType filterMapping, MergeContext mergeContext) throws DeploymentException {
+        String filterName = filterMapping.getFilterName().getStringValue();
+        for (ServletNameType servletName : filterMapping.getServletNameArray()) {
+            mergeContext.setAttribute(createFilterMappingServletNameKey(filterName, servletName.getStringValue()), Boolean.TRUE);
+        }
+    }
+
+    @Override
+    public void merge(FilterMappingType srcFilterMapping, FilterMappingType targetFilterMapping, MergeContext mergeContext) throws DeploymentException {
+        String filterName = srcFilterMapping.getFilterName().getStringValue();
+        for (ServletNameType servletName : srcFilterMapping.getServletNameArray()) {
+            String filterMappingServletNameKey = createFilterMappingServletNameKey(filterName, servletName.getStringValue());
+            if (!mergeContext.containsAttribute(filterMappingServletNameKey)) {
+                targetFilterMapping.addNewServletName().set(servletName);
+                mergeContext.setAttribute(filterMappingServletNameKey, Boolean.TRUE);
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (FilterMappingType filterMapping : webApp.getFilterMappingArray()) {
+            String filterName = filterMapping.getFilterName().getStringValue();
+            for (ServletNameType servletName : filterMapping.getServletNameArray()) {
+                context.setAttribute(createFilterMappingServletNameKey(filterName, servletName.getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createFilterMappingServletNameKey(String filterName, String servletName) {
+        return "filter-mapping.filter-name." + filterName + ".servlet-name." + servletName;
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingServletNameMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingServletNameMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingServletNameMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingUrlPatternMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingUrlPatternMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingUrlPatternMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingUrlPatternMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,84 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentValidationUtils;
+import org.apache.geronimo.xbeans.javaee6.FilterMappingType;
+import org.apache.geronimo.xbeans.javaee6.UrlPatternType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FilterMappingUrlPatternMergeHandler implements SubMergeHandler<FilterMappingType, FilterMappingType> {
+
+    @Override
+    public void add(FilterMappingType filterMapping, MergeContext mergeContext) throws DeploymentException {
+        String filterName = filterMapping.getFilterName().getStringValue();
+        for (UrlPatternType urlPattern : filterMapping.getUrlPatternArray()) {
+            String urlPatternStr = urlPattern.getStringValue();
+            if (!WebDeploymentValidationUtils.isUrlPatternValid(urlPatternStr)) {
+                throw new DeploymentException(WebDeploymentMessageUtils.createInvalidUrlPatternErrorMessage("filter-mapping", filterName, urlPatternStr, "web-fragment.xml located in "
+                        + mergeContext.getCurrentJarUrl()));
+            }
+            mergeContext.setAttribute(createFilterMappingUrlPatternKey(filterName, urlPatternStr), urlPattern);
+        }
+    }
+
+    @Override
+    public void merge(FilterMappingType srcFilterMapping, FilterMappingType targetFilterMapping, MergeContext mergeContext) throws DeploymentException {
+        String filterName = srcFilterMapping.getFilterName().getStringValue();
+        for (UrlPatternType urlPattern : srcFilterMapping.getUrlPatternArray()) {
+            String urlPatternStr = urlPattern.getStringValue();
+            String filterMappingUrlPatternKey = createFilterMappingUrlPatternKey(filterName, urlPatternStr);
+            if (!mergeContext.containsAttribute(filterMappingUrlPatternKey)) {
+                UrlPatternType newUrlPattern = (UrlPatternType) targetFilterMapping.addNewUrlPattern().set(urlPattern);
+                if (!WebDeploymentValidationUtils.isUrlPatternValid(urlPatternStr)) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createInvalidUrlPatternErrorMessage("filter-mapping", filterName, urlPatternStr, "web-fragment.xml located in "
+                            + mergeContext.getCurrentJarUrl()));
+                }
+                mergeContext.setAttribute(filterMappingUrlPatternKey, newUrlPattern);
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (FilterMappingType filterMapping : webApp.getFilterMappingArray()) {
+            String filterName = filterMapping.getFilterName().getStringValue();
+            for (UrlPatternType urlPattern : filterMapping.getUrlPatternArray()) {
+                String urlPatternStr = urlPattern.getStringValue();
+                if (!WebDeploymentValidationUtils.isUrlPatternValid(urlPatternStr)) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createInvalidUrlPatternErrorMessage("filter-mapping", filterName, urlPatternStr, "web.xml"));
+                }
+                context.setAttribute(createFilterMappingUrlPatternKey(filterName, urlPatternStr), urlPattern);
+            }
+        }
+    }
+
+    public static String createFilterMappingUrlPatternKey(String filterName, String urlPattern) {
+        return "filter-mapping.filter-name." + filterName + ".url-pattern." + urlPattern;
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingUrlPatternMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingUrlPatternMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMappingUrlPatternMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,91 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.xbeans.javaee6.FilterType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FilterMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    private List<SubMergeHandler<FilterType, FilterType>> subMergeHandlers;
+
+    public FilterMergeHandler() {
+        subMergeHandlers = new ArrayList<SubMergeHandler<FilterType, FilterType>>();
+        subMergeHandlers.add(new FilterInitParamMergeHandler());
+    }
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (FilterType srcFilter : webFragment.getFilterArray()) {
+            String filterName = srcFilter.getFilterName().getStringValue();
+            FilterType targetFilter = (FilterType) mergeContext.getAttribute(createFilterKey(filterName));
+            if (targetFilter == null) {
+                targetFilter = (FilterType) webApp.addNewFilter().set(srcFilter);
+                mergeContext.setAttribute(createFilterKey(filterName), targetFilter);
+                for (SubMergeHandler<FilterType, FilterType> subMergeHandler : subMergeHandlers) {
+                    subMergeHandler.add(targetFilter, mergeContext);
+                }
+            } else {
+                for (SubMergeHandler<FilterType, FilterType> subMergeHandler : subMergeHandlers) {
+                    subMergeHandler.merge(srcFilter, targetFilter, mergeContext);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (SubMergeHandler<FilterType, FilterType> subMergeHandler : subMergeHandlers) {
+            subMergeHandler.postProcessWebXmlElement(webApp, mergeContext);
+        }
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (FilterType filter : webApp.getFilterArray()) {
+            mergeContext.setAttribute(createFilterKey(filter.getFilterName().getStringValue()), filter);
+        }
+        for (SubMergeHandler<FilterType, FilterType> subMergeHandler : subMergeHandlers) {
+            subMergeHandler.preProcessWebXmlElement(webApp, mergeContext);
+        }
+    }
+
+    public static String createFilterKey(String filterName) {
+        return "filter.filter-name." + filterName;
+    }
+
+    public static boolean isFilterConfigured(String filterName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createFilterKey(filterName));
+    }
+
+    public static FilterType getFilter(String filterName, MergeContext mergeContext) {
+        return (FilterType) mergeContext.getAttribute(createFilterKey(filterName));
+    }
+
+    public static void addFilter(FilterType filter, MergeContext mergeContext) {
+        mergeContext.setAttribute(createFilterKey(filter.getFilterName().getStringValue()), filter);
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/JspConfigMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/JspConfigMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/JspConfigMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/JspConfigMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,86 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.ElementSource;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.web25.deployment.merge.MergeHelper;
+import org.apache.geronimo.web25.deployment.merge.MergeItem;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
+import org.apache.geronimo.xbeans.javaee6.JspConfigType;
+import org.apache.geronimo.xbeans.javaee6.JspPropertyGroupType;
+import org.apache.geronimo.xbeans.javaee6.TaglibType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JspConfigMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    private static final Logger logger = LoggerFactory.getLogger(JspConfigMergeHandler.class);
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        if (webFragment.getJspConfigArray().length == 0) {
+            return;
+        }
+        if (webFragment.getJspConfigArray().length > 1) {
+            logger.warn(WebDeploymentMessageUtils.createMultipleConfigurationWarningMessage("jsp-config", mergeContext.getCurrentJarUrl()));
+        }
+        JspConfigType srcJspConfig = webFragment.getJspConfigArray(0);
+        JspConfigType targetJspConfig = webApp.getJspConfigArray().length == 0 ? webApp.addNewJspConfig() : webApp.getJspConfigArray(0);
+        //Merge Tag lib configurations
+        for (TaglibType taglib : srcJspConfig.getTaglibArray()) {
+            if (MergeHelper.mergeRequired(createTaglibKey(taglib), "jsp-config/tag-lib", "taglib-uri", taglib.getTaglibUri().getStringValue(), "taglib-location", taglib.getTaglibLocation()
+                    .getStringValue(), mergeContext)) {
+                TaglibType newTaglib = targetJspConfig.addNewTaglib();
+                newTaglib.set(taglib);
+            }
+        }
+        //Merge jsp-property-group configurations, seem that no merge actions are required, just add them to the web.xml file
+        for (JspPropertyGroupType srcJspPropertyGroup : srcJspConfig.getJspPropertyGroupArray()) {
+            targetJspConfig.addNewJspPropertyGroup().set(srcJspPropertyGroup);
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        if (webApp.getJspConfigArray().length == 0) {
+            return;
+        }
+        if (webApp.getJspConfigArray().length > 1) {
+            throw new DeploymentException(WebDeploymentMessageUtils.createMultipleConfigurationWebAppErrorMessage("jsp-config"));
+        }
+        JspConfigType jspConfig = webApp.getJspConfigArray(0);
+        for (TaglibType taglib : jspConfig.getTaglibArray()) {
+            context.setAttribute(createTaglibKey(taglib), new MergeItem(taglib.getTaglibLocation().getStringValue(), null, ElementSource.WEB_XML));
+        }
+    }
+
+    public static String createTaglibKey(TaglibType taglib) {
+        return "jsp-config.taglib.taglib-uri." + taglib.getTaglibUri().getStringValue();
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/JspConfigMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/JspConfigMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/JspConfigMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ListenerMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ListenerMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ListenerMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ListenerMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,67 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.xbeans.javaee6.ListenerType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * According to the spec 8.2.3.g.vii
+ * Multiple <listener> elements with the same <listener-class> are treated as a single <listener> declaration
+ * @version $Rev$ $Date$
+ */
+public class ListenerMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (ListenerType listener : webFragment.getListenerArray()) {
+            String listenerClassName = listener.getListenerClass().getStringValue();
+            if (!mergeContext.containsAttribute(createListenerKey(listenerClassName))) {
+                ListenerType targetListener = webApp.addNewListener();
+                targetListener.addNewListenerClass().setStringValue(listenerClassName);
+                mergeContext.setAttribute(createListenerKey(listener.getListenerClass().getStringValue()), listener);
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (ListenerType listener : webApp.getListenerArray()) {
+            context.setAttribute(createListenerKey(listener.getListenerClass().getStringValue()), listener);
+        }
+    }
+
+    public static String createListenerKey(String listenerClassName) {
+        return "listener.listener-class." + listenerClassName;
+    }
+
+    public static boolean isListenerConfigured(String listenerClassName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createListenerKey(listenerClassName));
+    }
+
+    public static void addListener(ListenerType listener, MergeContext mergeContext) {
+        mergeContext.setAttribute(createListenerKey(listener.getListenerClass().getStringValue()), listener);
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ListenerMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ListenerMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ListenerMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LocaleEncodingMappingListMergeHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LocaleEncodingMappingListMergeHandler.java?rev=931020&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LocaleEncodingMappingListMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LocaleEncodingMappingListMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,86 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.web25.deployment.merge.webfragment;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.web25.deployment.merge.ElementSource;
+import org.apache.geronimo.web25.deployment.merge.MergeContext;
+import org.apache.geronimo.web25.deployment.merge.MergeItem;
+import org.apache.geronimo.web25.deployment.utils.WebDeploymentMessageUtils;
+import org.apache.geronimo.xbeans.javaee6.LocaleEncodingMappingListType;
+import org.apache.geronimo.xbeans.javaee6.LocaleEncodingMappingType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LocaleEncodingMappingListMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        LocaleEncodingMappingListType targetLocaleEncodingMappingList = null;
+        for (LocaleEncodingMappingListType localeEncodingMappingList : webFragment.getLocaleEncodingMappingListArray()) {
+            for (LocaleEncodingMappingType localeEncodingMapping : localeEncodingMappingList.getLocaleEncodingMappingArray()) {
+                String localeEncodingMappingKey = createLocaleEncodingMappingKey(localeEncodingMapping.getLocale());
+                MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(localeEncodingMappingKey);
+                if (mergeItem != null && mergeItem.isFromWebFragment() && !mergeItem.getValue().equals(localeEncodingMapping.getEncoding())) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("locale-encoding-mapping", "locale", localeEncodingMapping.getLocale(), "encoding",
+                            (String) mergeItem.getValue(), mergeItem.getBelongedURL(), localeEncodingMapping.getLocale(), mergeContext.getCurrentJarUrl()));
+                }
+                if (targetLocaleEncodingMappingList == null) {
+                    targetLocaleEncodingMappingList = webApp.getLocaleEncodingMappingListArray().length > 0 ? webApp.getLocaleEncodingMappingListArray(0) : webApp.addNewLocaleEncodingMappingList();
+                }
+                targetLocaleEncodingMappingList.addNewLocaleEncodingMapping().set(localeEncodingMapping);
+                mergeContext.setAttribute(localeEncodingMappingKey, new MergeItem(localeEncodingMapping.getEncoding(), mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        LocaleEncodingMappingListType[] localeEncodingMappingLists = webApp.getLocaleEncodingMappingListArray();
+        if (localeEncodingMappingLists.length == 0) {
+            return;
+        }
+        //Spec 14.2 While multiple locale-encoding-mapping lists are found, we need to concatenate the items
+        if (localeEncodingMappingLists.length > 1) {
+            LocaleEncodingMappingListType targetLocaleEncodingMappingList = localeEncodingMappingLists[0];
+            for (int i = 1; i < localeEncodingMappingLists.length; i++) {
+                LocaleEncodingMappingListType localeEncodingMappingList = localeEncodingMappingLists[i];
+                for (LocaleEncodingMappingType localeEncodingMapping : localeEncodingMappingList.getLocaleEncodingMappingArray()) {
+                    targetLocaleEncodingMappingList.addNewLocaleEncodingMapping().set(localeEncodingMapping);
+                }
+            }
+            for (int i = 1, iLength = localeEncodingMappingLists.length; i < iLength; i++) {
+                webApp.removeLocaleEncodingMappingList(1);
+            }
+        }
+        for (LocaleEncodingMappingType localeEncodingMapping : webApp.getLocaleEncodingMappingListArray(0).getLocaleEncodingMappingArray()) {
+            context.setAttribute(createLocaleEncodingMappingKey(localeEncodingMapping.getLocale()), new MergeItem(localeEncodingMapping.getEncoding(), null, ElementSource.WEB_XML));
+        }
+    }
+
+    public static String createLocaleEncodingMappingKey(String locale) {
+        return "locale-encoding-mapping-list.locale-encoding-mapping.locale." + locale;
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LocaleEncodingMappingListMergeHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LocaleEncodingMappingListMergeHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LocaleEncodingMappingListMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message