geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r931020 [4/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/LoginConfigMergeHandler.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/LoginConfigMergeHandler.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/LoginConfigMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LoginConfigMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,47 @@
+/**
+ *  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.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @FIXME For login-config, no rules are mentioned in spec, from my understanding, we should only use the one from web.xml
+ * @version $Rev$ $Date$
+ */
+public class LoginConfigMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType srcElement, WebAppType targetElement, MergeContext mergeContext) throws DeploymentException {
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        if (webApp.getLoginConfigArray().length > 1) {
+            throw new DeploymentException(WebDeploymentMessageUtils.createMultipleConfigurationWebAppErrorMessage("login-config"));
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/LoginConfigMergeHandler.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/LoginConfigMergeHandler.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/LoginConfigMergeHandler.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/MessageDestinationMergeHandler.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/MessageDestinationMergeHandler.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/MessageDestinationMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,71 @@
+/**
+ *  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.MessageDestinationType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MessageDestinationMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (MessageDestinationType messageDestination : webApp.getMessageDestinationArray()) {
+            String messageDestinationName = messageDestination.getMessageDestinationName().getStringValue();
+            if (mergeContext.containsAttribute(createMessageDestinationConfiguredInWebXMLKey(messageDestination.getMessageDestinationName().getStringValue()))) {
+                continue;
+            }
+            if (mergeContext.containsAttribute(createMessageDestinationConfiguredInWebFragmentXMLKey(messageDestinationName))) {
+                MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(createMessageDestinationConfiguredInWebFragmentXMLKey(messageDestinationName));
+                throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("message-destination", messageDestinationName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+            } else {
+                MessageDestinationType newMessageDestination = (MessageDestinationType) webApp.addNewMessageDestination().set(messageDestination);
+                mergeContext.setAttribute(createMessageDestinationConfiguredInWebFragmentXMLKey(messageDestinationName), new MergeItem(newMessageDestination, mergeContext.getCurrentJarUrl(),
+                        ElementSource.WEB_FRAGMENT));
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (MessageDestinationType messageDestination : webApp.getMessageDestinationArray()) {
+            context.setAttribute(createMessageDestinationConfiguredInWebXMLKey(messageDestination.getMessageDestinationName().getStringValue()), Boolean.TRUE);
+        }
+    }
+
+    public static String createMessageDestinationConfiguredInWebFragmentXMLKey(String messageDestinationName) {
+        return "message-destination.message-destination-name." + messageDestinationName + ".configured_in_web_fragment_xml";
+    }
+
+    public static String createMessageDestinationConfiguredInWebXMLKey(String messageDestinationName) {
+        return "message-destination.message-destination-name." + messageDestinationName + ".configured_in_web_xml";
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationMergeHandler.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/MessageDestinationMergeHandler.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/MessageDestinationMergeHandler.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/MessageDestinationRefMergeHandler.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/MessageDestinationRefMergeHandler.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/MessageDestinationRefMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationRefMergeHandler.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.MessageDestinationRefType;
+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 MessageDestinationRefMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String MESSAGE_DESTINATION_REF_NAME_PREFIX = "message-destination-ref.message-destination-ref-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a message-destination-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 message-destination-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 (MessageDestinationRefType srcMessageDestinationRef : webFragment.getMessageDestinationRefArray()) {
+            String messageDestinationRefName = srcMessageDestinationRef.getMessageDestinationRefName().getStringValue();
+            String messageDestinationRefKey = createMessageDestinationRefKey(messageDestinationRefName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(messageDestinationRefKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("message-destination-ref", messageDestinationRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isMessageDestinationRefInjectTargetsConfiguredInInitialWebXML(messageDestinationRefName, mergeContext)) {
+                    //Merge InjectTarget
+                    MessageDestinationRefType messageDestinationRef = (MessageDestinationRefType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcMessageDestinationRef.getInjectionTargetArray()) {
+                        String messageDestinationRefInjectTargetKey = createMessageDestinationRefInjectTargetKey(messageDestinationRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(messageDestinationRefInjectTargetKey)) {
+                            messageDestinationRef.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(messageDestinationRefInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                MessageDestinationRefType targetMessageDestinationRef = (MessageDestinationRefType) webApp.addNewMessageDestinationRef().set(srcMessageDestinationRef);
+                mergeContext.setAttribute(messageDestinationRefKey, new MergeItem(targetMessageDestinationRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetMessageDestinationRef.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createMessageDestinationRefInjectTargetKey(messageDestinationRefName, 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 (MessageDestinationRefType messageDestinationRef : webApp.getMessageDestinationRefArray()) {
+            String messageDestinationRefName = messageDestinationRef.getMessageDestinationRefName().getStringValue();
+            mergeContext.setAttribute(createMessageDestinationRefKey(messageDestinationRefName), new MergeItem(messageDestinationRef, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (messageDestinationRef.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createMessageDestinationRefInjectTargetConfiguredInWebXMLKey(messageDestinationRefName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : messageDestinationRef.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createMessageDestinationRefInjectTargetKey(messageDestinationRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createMessageDestinationRefInjectTargetConfiguredInWebXMLKey(String messageDestinationRefName) {
+        return MESSAGE_DESTINATION_REF_NAME_PREFIX + messageDestinationRefName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createMessageDestinationRefInjectTargetKey(String messageDestinationRefName, String injectTargetClassName, String injectTargetName) {
+        return MESSAGE_DESTINATION_REF_NAME_PREFIX + messageDestinationRefName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createMessageDestinationRefKey(String messageDestinationRefName) {
+        return MESSAGE_DESTINATION_REF_NAME_PREFIX + messageDestinationRefName;
+    }
+
+    public static boolean isMessageDestinationRefInjectTargetConfigured(String messageDestinationRefName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createMessageDestinationRefInjectTargetKey(messageDestinationRefName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isMessageDestinationRefInjectTargetsConfiguredInInitialWebXML(String messageDestinationRefName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createMessageDestinationRefInjectTargetConfiguredInWebXMLKey(messageDestinationRefName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MessageDestinationRefMergeHandler.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/MessageDestinationRefMergeHandler.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/MessageDestinationRefMergeHandler.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/MimeMappingMergeHandler.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/MimeMappingMergeHandler.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/MimeMappingMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MimeMappingMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,80 @@
+/**
+ *  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.MimeMappingType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MimeMappingMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (MimeMappingType mimeMapping : webFragment.getMimeMappingArray()) {
+            String extension = mimeMapping.getExtension().getStringValue();
+            if (isMimeMappingConfiguredInWebXML(extension, mergeContext)) {
+                continue;
+            }
+            String jarUrl = mergeContext.getCurrentJarUrl();
+            String qualifedMimeMappingName = createMimeMappingConfiguredInWebFragmentXMLKey(extension);
+            MergeItem existedMimeMapping = (MergeItem) mergeContext.getAttribute(qualifedMimeMappingName);
+            if (existedMimeMapping == null) {
+                mergeContext.setAttribute(qualifedMimeMappingName, new MergeItem(mimeMapping.getMimeType().getStringValue(), jarUrl, ElementSource.WEB_FRAGMENT));
+                webApp.addNewMimeMapping().set(mimeMapping);
+            } else if (!mimeMapping.getMimeType().getStringValue().equals(existedMimeMapping.getValue())) {
+                throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("mime-mapping", "extension", extension, "mime-type", (String) existedMimeMapping.getValue(), existedMimeMapping
+                        .getBelongedURL(), mimeMapping.getMimeType().getStringValue(), jarUrl));
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (MimeMappingType mimeMapping : webApp.getMimeMappingArray()) {
+            context.setAttribute(createMimeMappingConfiguredInWebXMLKey(mimeMapping.getExtension().getStringValue()), Boolean.TRUE);
+        }
+    }
+
+    public static String createMimeMappingConfiguredInWebFragmentXMLKey(String extension) {
+        return "mime-mapping.extension." + extension + ".configured_in_web_fragment_xml";
+    }
+
+    public static String createMimeMappingConfiguredInWebXMLKey(String extension) {
+        return "mime-mapping.extension." + extension + ".configured_in_web_xml";
+    }
+
+    public static boolean isMimeMappingConfiguredInWebFragmentXML(String extension, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createMimeMappingConfiguredInWebFragmentXMLKey(extension));
+    }
+
+    public static boolean isMimeMappingConfiguredInWebXML(String extension, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createMimeMappingConfiguredInWebXMLKey(extension));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/MimeMappingMergeHandler.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/MimeMappingMergeHandler.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/MimeMappingMergeHandler.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/PersistenceContextRefMergeHandler.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/PersistenceContextRefMergeHandler.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/PersistenceContextRefMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceContextRefMergeHandler.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.PersistenceContextRefType;
+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 PersistenceContextRefMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String PERSISTENCE_CONTEXT_REF_NAME_PREFIX = "persistence-context-ref.persistence-context-ref-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a persistence-context-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 persistence-context-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 (PersistenceContextRefType srcPersistenceContextRef : webFragment.getPersistenceContextRefArray()) {
+            String persistenceContextRefName = srcPersistenceContextRef.getPersistenceContextRefName().getStringValue();
+            String persistenceContextRefKey = createPersistenceContextRefKey(persistenceContextRefName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(persistenceContextRefKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("persistence-context-ref", persistenceContextRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isPersistenceContextRefInjectTargetsConfiguredInInitialWebXML(persistenceContextRefName, mergeContext)) {
+                    //Merge InjectTarget
+                    PersistenceContextRefType persistenceContextRef = (PersistenceContextRefType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcPersistenceContextRef.getInjectionTargetArray()) {
+                        String persistenceContextRefInjectTargetKey = createPersistenceContextRefInjectTargetKey(persistenceContextRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(persistenceContextRefInjectTargetKey)) {
+                            persistenceContextRef.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(persistenceContextRefInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                PersistenceContextRefType targetPersistenceContextRef = (PersistenceContextRefType) webApp.addNewPersistenceContextRef().set(srcPersistenceContextRef);
+                mergeContext.setAttribute(persistenceContextRefKey, new MergeItem(targetPersistenceContextRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetPersistenceContextRef.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createPersistenceContextRefInjectTargetKey(persistenceContextRefName, 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 (PersistenceContextRefType persistenceContextRef : webApp.getPersistenceContextRefArray()) {
+            String persistenceContextRefName = persistenceContextRef.getPersistenceContextRefName().getStringValue();
+            mergeContext.setAttribute(createPersistenceContextRefKey(persistenceContextRefName), new MergeItem(persistenceContextRef, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (persistenceContextRef.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createPersistenceContextRefInjectTargetConfiguredInWebXMLKey(persistenceContextRefName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : persistenceContextRef.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createPersistenceContextRefInjectTargetKey(persistenceContextRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createPersistenceContextRefInjectTargetConfiguredInWebXMLKey(String persistenceContextRefName) {
+        return PERSISTENCE_CONTEXT_REF_NAME_PREFIX + persistenceContextRefName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createPersistenceContextRefInjectTargetKey(String persistenceContextRefName, String injectTargetClassName, String injectTargetName) {
+        return PERSISTENCE_CONTEXT_REF_NAME_PREFIX + persistenceContextRefName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createPersistenceContextRefKey(String persistenceContextRefName) {
+        return PERSISTENCE_CONTEXT_REF_NAME_PREFIX + persistenceContextRefName;
+    }
+
+    public static boolean isPersistenceContextRefInjectTargetConfigured(String persistenceContextRefName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createPersistenceContextRefInjectTargetKey(persistenceContextRefName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isPersistenceContextRefInjectTargetsConfiguredInInitialWebXML(String persistenceContextRefName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createPersistenceContextRefInjectTargetConfiguredInWebXMLKey(persistenceContextRefName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceContextRefMergeHandler.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/PersistenceContextRefMergeHandler.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/PersistenceContextRefMergeHandler.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/PersistenceUnitRefMergeHandler.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/PersistenceUnitRefMergeHandler.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/PersistenceUnitRefMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceUnitRefMergeHandler.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.PersistenceUnitRefType;
+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 PersistenceUnitRefMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String PERSISTENCE_UNIT_REF_NAME_PREFIX = "persistence-unit-ref.persistence-unit-ref-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a persistence-unit-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 persistence-unit-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 (PersistenceUnitRefType srcPersistenceUnitRef : webFragment.getPersistenceUnitRefArray()) {
+            String persistenceUnitRefName = srcPersistenceUnitRef.getPersistenceUnitRefName().getStringValue();
+            String persistenceUnitRefKey = createPersistenceUnitRefKey(persistenceUnitRefName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(persistenceUnitRefKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("persistence-unit-ref", persistenceUnitRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isPersistenceUnitRefInjectTargetsConfiguredInInitialWebXML(persistenceUnitRefName, mergeContext)) {
+                    //Merge InjectTarget
+                    PersistenceUnitRefType persistenceUnitRef = (PersistenceUnitRefType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcPersistenceUnitRef.getInjectionTargetArray()) {
+                        String persistenceUnitRefInjectTargetKey = createPersistenceUnitRefInjectTargetKey(persistenceUnitRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(persistenceUnitRefInjectTargetKey)) {
+                            persistenceUnitRef.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(persistenceUnitRefInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                PersistenceUnitRefType targetPersistenceUnitRef = (PersistenceUnitRefType) webApp.addNewPersistenceUnitRef().set(srcPersistenceUnitRef);
+                mergeContext.setAttribute(persistenceUnitRefKey, new MergeItem(targetPersistenceUnitRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetPersistenceUnitRef.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createPersistenceUnitRefInjectTargetKey(persistenceUnitRefName, 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 (PersistenceUnitRefType persistenceUnitRef : webApp.getPersistenceUnitRefArray()) {
+            String persistenceUnitRefName = persistenceUnitRef.getPersistenceUnitRefName().getStringValue();
+            mergeContext.setAttribute(createPersistenceUnitRefKey(persistenceUnitRefName), new MergeItem(persistenceUnitRef, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (persistenceUnitRef.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createPersistenceUnitRefInjectTargetConfiguredInWebXMLKey(persistenceUnitRefName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : persistenceUnitRef.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createPersistenceUnitRefInjectTargetKey(persistenceUnitRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createPersistenceUnitRefInjectTargetConfiguredInWebXMLKey(String persistenceUnitRefName) {
+        return PERSISTENCE_UNIT_REF_NAME_PREFIX + persistenceUnitRefName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createPersistenceUnitRefInjectTargetKey(String persistenceUnitRefName, String injectTargetClassName, String injectTargetName) {
+        return PERSISTENCE_UNIT_REF_NAME_PREFIX + persistenceUnitRefName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createPersistenceUnitRefKey(String persistenceUnitRefName) {
+        return PERSISTENCE_UNIT_REF_NAME_PREFIX + persistenceUnitRefName;
+    }
+
+    public static boolean isPersistenceUnitRefInjectTargetConfigured(String persistenceUnitRefName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createPersistenceUnitRefInjectTargetKey(persistenceUnitRefName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isPersistenceUnitRefInjectTargetsConfiguredInInitialWebXML(String persistenceUnitRefName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createPersistenceUnitRefInjectTargetConfiguredInWebXMLKey(persistenceUnitRefName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PersistenceUnitRefMergeHandler.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/PersistenceUnitRefMergeHandler.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/PersistenceUnitRefMergeHandler.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/PostConstructMergeHandler.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/PostConstructMergeHandler.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/PostConstructMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PostConstructMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,54 @@
+/**
+ *  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.LifecycleCallbackType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PostConstructMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        if (mergeContext.containsAttribute(createPostConstructorConfiguredInWebXMLKey())) {
+            return;
+        }
+        for (LifecycleCallbackType lifecycleCallback : webFragment.getPostConstructArray()) {
+            webApp.addNewPostConstruct().set(lifecycleCallback);
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        context.setAttribute(createPostConstructorConfiguredInWebXMLKey(), webApp.getPostConstructArray().length > 0);
+    }
+
+    public static String createPostConstructorConfiguredInWebXMLKey() {
+        return "post-construct.configured_in_web_xml";
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PostConstructMergeHandler.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/PostConstructMergeHandler.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/PostConstructMergeHandler.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/PreDestroyMergeHandler.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/PreDestroyMergeHandler.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/PreDestroyMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PreDestroyMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,53 @@
+/**
+ *  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.LifecycleCallbackType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PreDestroyMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        if (mergeContext.containsAttribute(createPreDestroyConfiguredInWebXMLKey())) {
+            return;
+        }
+        for (LifecycleCallbackType lifecycleCallback : webFragment.getPreDestroyArray()) {
+            webApp.addNewPreDestroy().set(lifecycleCallback);
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        context.setAttribute(createPreDestroyConfiguredInWebXMLKey(), webApp.getPreDestroyArray().length > 0);
+    }
+
+    public static String createPreDestroyConfiguredInWebXMLKey() {
+        return "pre-destroy.configured_in_web_xml";
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/PreDestroyMergeHandler.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/PreDestroyMergeHandler.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/PreDestroyMergeHandler.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/ResourceEnvRefMergeHandler.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/ResourceEnvRefMergeHandler.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/ResourceEnvRefMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ResourceEnvRefMergeHandler.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.ResourceEnvRefType;
+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 ResourceEnvRefMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String RESOURCE_ENV_REF_NAME_PREFIX = "resource-env-ref.resource-env-ref-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a resource-env-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 resource-env-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 (ResourceEnvRefType srcResourceEnvRef : webFragment.getResourceEnvRefArray()) {
+            String resourceEnvRefName = srcResourceEnvRef.getResourceEnvRefName().getStringValue();
+            String resourceEnvRefKey = createResourceEnvRefKey(resourceEnvRefName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(resourceEnvRefKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("resource-env-ref", resourceEnvRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isResourceEnvRefInjectTargetsConfiguredInInitialWebXML(resourceEnvRefName, mergeContext)) {
+                    //Merge InjectTarget
+                    ResourceEnvRefType resourceEnvRef = (ResourceEnvRefType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcResourceEnvRef.getInjectionTargetArray()) {
+                        String resourceEnvRefInjectTargetKey = createResourceEnvRefInjectTargetKey(resourceEnvRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(resourceEnvRefInjectTargetKey)) {
+                            resourceEnvRef.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(resourceEnvRefInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                ResourceEnvRefType targetResourceEnvRef = (ResourceEnvRefType) webApp.addNewResourceEnvRef().set(srcResourceEnvRef);
+                mergeContext.setAttribute(resourceEnvRefKey, new MergeItem(targetResourceEnvRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetResourceEnvRef.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createResourceEnvRefInjectTargetKey(resourceEnvRefName, 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 (ResourceEnvRefType resourceEnvRef : webApp.getResourceEnvRefArray()) {
+            String resourceEnvRefName = resourceEnvRef.getResourceEnvRefName().getStringValue();
+            mergeContext.setAttribute(createResourceEnvRefKey(resourceEnvRefName), new MergeItem(resourceEnvRef, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (resourceEnvRef.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createResourceEnvRefInjectTargetConfiguredInWebXMLKey(resourceEnvRefName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : resourceEnvRef.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createResourceEnvRefInjectTargetKey(resourceEnvRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createResourceEnvRefInjectTargetConfiguredInWebXMLKey(String resourceEnvRefName) {
+        return RESOURCE_ENV_REF_NAME_PREFIX + resourceEnvRefName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createResourceEnvRefInjectTargetKey(String resourceEnvRefName, String injectTargetClassName, String injectTargetName) {
+        return RESOURCE_ENV_REF_NAME_PREFIX + resourceEnvRefName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createResourceEnvRefKey(String resourceEnvRefName) {
+        return RESOURCE_ENV_REF_NAME_PREFIX + resourceEnvRefName;
+    }
+
+    public static boolean isResourceEnvRefInjectTargetConfigured(String resourceEnvRefName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createResourceEnvRefInjectTargetKey(resourceEnvRefName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isResourceEnvRefInjectTargetsConfiguredInInitialWebXML(String resourceEnvRefName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createResourceEnvRefInjectTargetConfiguredInWebXMLKey(resourceEnvRefName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ResourceEnvRefMergeHandler.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/ResourceEnvRefMergeHandler.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/ResourceEnvRefMergeHandler.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/ResourceRefMergeHandler.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/ResourceRefMergeHandler.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/ResourceRefMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ResourceRefMergeHandler.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.ResourceRefType;
+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 ResourceRefMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String RESOURCE_REF_NAME_PREFIX = "resource-ref.res-ref-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a resource-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 resource-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 (ResourceRefType srcResourceRef : webFragment.getResourceRefArray()) {
+            String resourceRefName = srcResourceRef.getResRefName().getStringValue();
+            String resourceRefKey = createResourceRefKey(resourceRefName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(resourceRefKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("resource-ref", resourceRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isResourceRefInjectTargetsConfiguredInInitialWebXML(resourceRefName, mergeContext)) {
+                    //Merge InjectTarget
+                    ResourceRefType resourceRef = (ResourceRefType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcResourceRef.getInjectionTargetArray()) {
+                        String resourceRefInjectTargetKey = createResourceRefInjectTargetKey(resourceRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(resourceRefInjectTargetKey)) {
+                            resourceRef.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(resourceRefInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                ResourceRefType targetResourceRef = (ResourceRefType) webApp.addNewResourceRef().set(srcResourceRef);
+                mergeContext.setAttribute(resourceRefKey, new MergeItem(targetResourceRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetResourceRef.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createResourceRefInjectTargetKey(resourceRefName, 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 (ResourceRefType resourceRef : webApp.getResourceRefArray()) {
+            String resourceRefName = resourceRef.getResRefName().getStringValue();
+            mergeContext.setAttribute(createResourceRefKey(resourceRefName), new MergeItem(resourceRef, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (resourceRef.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createResourceRefInjectTargetConfiguredInWebXMLKey(resourceRefName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : resourceRef.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createResourceRefInjectTargetKey(resourceRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createResourceRefInjectTargetConfiguredInWebXMLKey(String resourceRefName) {
+        return RESOURCE_REF_NAME_PREFIX + resourceRefName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createResourceRefInjectTargetKey(String resourceRefName, String injectTargetClassName, String injectTargetName) {
+        return RESOURCE_REF_NAME_PREFIX + resourceRefName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createResourceRefKey(String resourceRefName) {
+        return RESOURCE_REF_NAME_PREFIX + resourceRefName;
+    }
+
+    public static boolean isResourceRefInjectTargetConfigured(String resourceRefName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createResourceRefInjectTargetKey(resourceRefName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isResourceRefInjectTargetsConfiguredInInitialWebXML(String resourceRefName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createResourceRefInjectTargetConfiguredInWebXMLKey(resourceRefName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ResourceRefMergeHandler.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/ResourceRefMergeHandler.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/ResourceRefMergeHandler.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/SecurityConstraintMergeHandler.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/SecurityConstraintMergeHandler.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/SecurityConstraintMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/SecurityConstraintMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,70 @@
+/**
+ *  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.SecurityConstraintType;
+import org.apache.geronimo.xbeans.javaee6.UrlPatternType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+import org.apache.geronimo.xbeans.javaee6.WebResourceCollectionType;
+
+/**
+ * FIXME For security-constraint, we just need to merge them to web.xml file, please correct me if I miss anything
+ * @version $Rev$ $Date$
+ */
+public class SecurityConstraintMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (SecurityConstraintType securityConstraint : webApp.getSecurityConstraintArray()) {
+            for (WebResourceCollectionType webResourceCollection : securityConstraint.getWebResourceCollectionArray()) {
+                for (UrlPatternType pattern : webResourceCollection.getUrlPatternArray()) {
+                    String urlPattern = pattern.getStringValue();
+                    if (!WebDeploymentValidationUtils.isUrlPatternValid(urlPattern)) {
+                        throw new DeploymentException(WebDeploymentMessageUtils.createInvalidUrlPatternErrorMessage("security-constraint", webResourceCollection.getWebResourceName().getStringValue(),
+                                urlPattern, "web-fragment.xml located in " + mergeContext.getCurrentJarUrl()));
+                    }
+                }
+            }
+            webApp.addNewSecurityConstraint().set(securityConstraint);
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (SecurityConstraintType securityConstraint : webApp.getSecurityConstraintArray()) {
+            for (WebResourceCollectionType webResourceCollection : securityConstraint.getWebResourceCollectionArray()) {
+                for (UrlPatternType pattern : webResourceCollection.getUrlPatternArray()) {
+                    String urlPattern = pattern.getStringValue();
+                    if (!WebDeploymentValidationUtils.isUrlPatternValid(urlPattern)) {
+                        throw new DeploymentException(WebDeploymentMessageUtils.createInvalidUrlPatternErrorMessage("security-constraint", webResourceCollection.getWebResourceName().getStringValue(),
+                                urlPattern, "web.xml "));
+                    }
+                }
+            }
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/SecurityConstraintMergeHandler.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/SecurityConstraintMergeHandler.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/SecurityConstraintMergeHandler.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/SecurityRoleMergeHandler.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/SecurityRoleMergeHandler.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/SecurityRoleMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/SecurityRoleMergeHandler.java Tue Apr  6 05:14:09 2010
@@ -0,0 +1,57 @@
+/**
+ *  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.SecurityRoleType;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WebFragmentType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SecurityRoleMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    @Override
+    public void merge(WebFragmentType webFragment, WebAppType webApp, MergeContext mergeContext) throws DeploymentException {
+        for (SecurityRoleType securityRole : webFragment.getSecurityRoleArray()) {
+            String securityRoleKey = createSecurityRoleKey(securityRole.getRoleName().getStringValue());
+            if (!mergeContext.containsAttribute(securityRoleKey)) {
+                mergeContext.setAttribute(securityRoleKey, Boolean.TRUE);
+                webApp.addNewSecurityRole().set(securityRole);
+            }
+        }
+    }
+
+    @Override
+    public void postProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        // TODO Auto-generated method stub
+    }
+
+    @Override
+    public void preProcessWebXmlElement(WebAppType webApp, MergeContext context) throws DeploymentException {
+        for (SecurityRoleType securityRole : webApp.getSecurityRoleArray()) {
+            context.setAttribute(createSecurityRoleKey(securityRole.getRoleName().getStringValue()), Boolean.TRUE);
+        }
+    }
+
+    public static String createSecurityRoleKey(String roleName) {
+        return "security-role.role-name." + roleName;
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/SecurityRoleMergeHandler.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/SecurityRoleMergeHandler.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/SecurityRoleMergeHandler.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/ServiceRefMergeHandler.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/ServiceRefMergeHandler.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/ServiceRefMergeHandler.java (added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServiceRefMergeHandler.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.ServiceRefType;
+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 ServiceRefMergeHandler implements WebFragmentMergeHandler<WebFragmentType, WebAppType> {
+
+    public static final String SERVICE_REF_NAME_PREFIX = "service-ref.service-ref-name.";
+
+    /**
+     * Steps :
+     * a. If we already have a service-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 service-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 (ServiceRefType srcServiceRef : webFragment.getServiceRefArray()) {
+            String serviceRefName = srcServiceRef.getServiceRefName().getStringValue();
+            String serviceRefKey = createServiceRefKey(serviceRefName);
+            MergeItem mergeItem = (MergeItem) mergeContext.getAttribute(serviceRefKey);
+            if (mergeItem != null) {
+                if (mergeItem.isFromWebFragment()) {
+                    throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateJNDIRefMessage("service-ref", serviceRefName, mergeItem.getBelongedURL(), mergeContext.getCurrentJarUrl()));
+                } else if (mergeItem.isFromWebXml() && !isServiceRefInjectTargetsConfiguredInInitialWebXML(serviceRefName, mergeContext)) {
+                    //Merge InjectTarget
+                    ServiceRefType serviceRef = (ServiceRefType) mergeItem.getValue();
+                    for (InjectionTargetType injectTarget : srcServiceRef.getInjectionTargetArray()) {
+                        String serviceRefInjectTargetKey = createServiceRefInjectTargetKey(serviceRefName, injectTarget.getInjectionTargetClass().getStringValue(), injectTarget
+                                .getInjectionTargetName().getStringValue());
+                        if (!mergeContext.containsAttribute(serviceRefInjectTargetKey)) {
+                            serviceRef.addNewInjectionTarget().set(injectTarget);
+                            mergeContext.setAttribute(serviceRefInjectTargetKey, Boolean.TRUE);
+                        }
+                    }
+                }
+            } else {
+                ServiceRefType targetServiceRef = (ServiceRefType) webApp.addNewServiceRef().set(srcServiceRef);
+                mergeContext.setAttribute(serviceRefKey, new MergeItem(targetServiceRef, mergeContext.getCurrentJarUrl(), ElementSource.WEB_FRAGMENT));
+                for (InjectionTargetType injectionTarget : targetServiceRef.getInjectionTargetArray()) {
+                    mergeContext.setAttribute(createServiceRefInjectTargetKey(serviceRefName, 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 (ServiceRefType serviceRef : webApp.getServiceRefArray()) {
+            String serviceRefName = serviceRef.getServiceRefName().getStringValue();
+            mergeContext.setAttribute(createServiceRefKey(serviceRefName), new MergeItem(serviceRef, null, ElementSource.WEB_XML));
+            //Create an attribute tag to indicate whether injectTarget is configured in web.xml file
+            if (serviceRef.getInjectionTargetArray().length > 0) {
+                mergeContext.setAttribute(createServiceRefInjectTargetConfiguredInWebXMLKey(serviceRefName), Boolean.TRUE);
+            }
+            for (InjectionTargetType injectionTarget : serviceRef.getInjectionTargetArray()) {
+                mergeContext.setAttribute(createServiceRefInjectTargetKey(serviceRefName, injectionTarget.getInjectionTargetClass().getStringValue(), injectionTarget.getInjectionTargetName()
+                        .getStringValue()), Boolean.TRUE);
+            }
+        }
+    }
+
+    public static String createServiceRefInjectTargetConfiguredInWebXMLKey(String serviceRefName) {
+        return SERVICE_REF_NAME_PREFIX + serviceRefName + ".inject_target_configured_in_web_xml";
+    }
+
+    public static String createServiceRefInjectTargetKey(String serviceRefName, String injectTargetClassName, String injectTargetName) {
+        return SERVICE_REF_NAME_PREFIX + serviceRefName + "." + injectTargetClassName + "." + injectTargetName;
+    }
+
+    public static String createServiceRefKey(String serviceRefName) {
+        return SERVICE_REF_NAME_PREFIX + serviceRefName;
+    }
+
+    public static boolean isServiceRefInjectTargetConfigured(String serviceRefName, String injectTargetClassName, String injectTargetName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createServiceRefInjectTargetKey(serviceRefName, injectTargetClassName, injectTargetName));
+    }
+
+    public static boolean isServiceRefInjectTargetsConfiguredInInitialWebXML(String serviceRefName, MergeContext mergeContext) {
+        return mergeContext.containsAttribute(createServiceRefInjectTargetConfiguredInWebXMLKey(serviceRefName));
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServiceRefMergeHandler.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/ServiceRefMergeHandler.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/ServiceRefMergeHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message