From 8c9bf242f243b0621e2b7419c5f8de73a710cf23 Mon Sep 17 00:00:00 2001 From: Jonathan Coustick Date: Tue, 17 Jul 2018 12:36:28 +0100 Subject: [PATCH] payara-web.xml is recongised --- .../deployment/xml/DTDRegistry.java | 8 +++++ .../deployment/xml/RuntimeTagNames.java | 2 ++ .../glassfish/lib/dtds/payara-web-app_4.dtd | 12 ++++---- .../org/glassfish/web/sniffer/WebSniffer.java | 2 ++ .../enterprise/glassfish/web/WarHandler.java | 30 +++++++++++++++---- .../com/sun/enterprise/web/WebModule.java | 2 +- .../internal/deployment/GenericSniffer.java | 2 +- .../deploy/shared/DeploymentPlanArchive.java | 13 ++++---- 8 files changed, 50 insertions(+), 21 deletions(-) diff --git a/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java b/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java index 5dafda76dad..8743cdfb38d 100644 --- a/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java +++ b/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/DTDRegistry.java @@ -37,6 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2018] Payara Foundation and/or affiliates // START OF IASRI 4661135 @@ -292,6 +293,13 @@ public final class DTDRegistry { "-//GlassFish.org//DTD GlassFish Application Server 3.1 EJB 3.1//EN"; public static final String GF_EJBJAR_311_DTD_SYSTEM_ID = "http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd"; + + + // Payara DTDs + + public static final String PAYARA_WEBAPP_4_DTD_PUBLIC_ID = "-//Payara.fish//DTD Payara Application Server 4 Servlet 3.0//EN"; + public static final String PAYARA_WEBAPP_4_DTD_SYSTEM_ID = "https://raw.githubusercontent.com/payara/Payara/master/appserver/deployment/dtds/src/main/resources/glassfish/lib/dtds/payara-web-app_4.dtd"; + } // END OF IASRI 4661135 diff --git a/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java b/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java index ded72dbe40c..c5e72f16510 100644 --- a/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java +++ b/appserver/deployment/dol/src/main/java/com/sun/enterprise/deployment/xml/RuntimeTagNames.java @@ -72,6 +72,8 @@ public interface RuntimeTagNames extends TagNames { public final static String PAYARA_SCANNING_INCLUDE = "scanning-include"; public final static String PAYARA_WHITELIST_PACKAGE = "whitelist-package"; public final static String PAYARA_JAXRS_ROLES_ALLOWED_ENABLED = "jaxrs-roles-allowed-enabled"; + public final static String PAYARA_APPLICATION_RUNTIME_TAG = "payara-application"; + public final static String PAYARA_WEB_RUNTIME_TAG = "payara-web-app"; // The name of the deployment context property used to disable implicit bean discovery for a // particular application deployment. diff --git a/appserver/deployment/dtds/src/main/resources/glassfish/lib/dtds/payara-web-app_4.dtd b/appserver/deployment/dtds/src/main/resources/glassfish/lib/dtds/payara-web-app_4.dtd index ee95891da49..e7bc30485dd 100644 --- a/appserver/deployment/dtds/src/main/resources/glassfish/lib/dtds/payara-web-app_4.dtd +++ b/appserver/deployment/dtds/src/main/resources/glassfish/lib/dtds/payara-web-app_4.dtd @@ -49,19 +49,19 @@ It must include a DOCTYPE of the following form: - + --> - - @@ -160,7 +160,7 @@ This element holds password text. max-entries Maximum number of entries this cache may hold. [4096] timeout-in-seconds Default timeout for the cache entries in seconds. [30] - enabled Is this cache enabled? [true] The default value is changed to true from 8.1 + enabled Is this cache enabled? [true] --> initDeploymentConfigurationPaths() { result.add("WEB-INF/web.xml"); result.add("WEB-INF/sun-web.xml"); result.add("WEB-INF/glassfish-web.xml"); + result.add("WEB-IND/payara-web.xml"); result.add("WEB-INF/weblogic.xml"); return result; } diff --git a/appserver/web/war-util/src/main/java/com/sun/enterprise/glassfish/web/WarHandler.java b/appserver/web/war-util/src/main/java/com/sun/enterprise/glassfish/web/WarHandler.java index 868cf23c260..62333cc3cff 100644 --- a/appserver/web/war-util/src/main/java/com/sun/enterprise/glassfish/web/WarHandler.java +++ b/appserver/web/war-util/src/main/java/com/sun/enterprise/glassfish/web/WarHandler.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016] [Payara Foundation] +// Portions Copyright [2016-2018] [Payara Foundation] package com.sun.enterprise.glassfish.web; @@ -95,6 +95,7 @@ public class WarHandler extends AbstractArchiveHandler { private static final String GLASSFISH_WEB_XML = "WEB-INF/glassfish-web.xml"; + private static final String PAYARA_WEB_XML = "WEB-INF/payara-web.xml"; private static final String SUN_WEB_XML = "WEB-INF/sun-web.xml"; private static final String WEBLOGIC_XML = "WEB-INF/weblogic.xml"; private static final String WAR_CONTEXT_XML = "META-INF/context.xml"; @@ -211,14 +212,13 @@ protected WebXmlParser getWebXmlParser(ReadableArchive archive, Application appl WebXmlParser webXmlParser = null; boolean hasWSLDD = archive.exists(WEBLOGIC_XML); - File runtimeAltDDFile = archive.getArchiveMetaData( - DeploymentProperties.RUNTIME_ALT_DD, File.class); - if (runtimeAltDDFile != null && - "glassfish-web.xml".equals(runtimeAltDDFile.getPath()) && - runtimeAltDDFile.isFile()) { + File runtimeAltDDFile = archive.getArchiveMetaData(DeploymentProperties.RUNTIME_ALT_DD, File.class); + if (runtimeAltDDFile != null && "glassfish-web.xml".equals(runtimeAltDDFile.getPath()) && runtimeAltDDFile.isFile()) { webXmlParser = new GlassFishWebXmlParser(archive, application); } else if (!gfDDOverWLSDD && !ignoreWLSDD && hasWSLDD) { webXmlParser = new WeblogicXmlParser(archive); + } else if (archive.exists(PAYARA_WEB_XML)){ + webXmlParser = new PayaraWebXmlParser(archive, application); } else if (archive.exists(GLASSFISH_WEB_XML)) { webXmlParser = new GlassFishWebXmlParser(archive, application); } else if (archive.exists(SUN_WEB_XML)) { @@ -637,6 +637,24 @@ protected String getRootElementName() { return "glassfish-web-app"; } } + + protected class PayaraWebXmlParser extends GlassFishWebXmlParser { + PayaraWebXmlParser(ReadableArchive archive, Application application) + throws XMLStreamException, IOException { + + super(archive, application); + } + + @Override + protected String getXmlFileName() { + return PAYARA_WEB_XML; + } + + @Override + protected String getRootElementName() { + return "payara-web-app"; + } + } protected class WeblogicXmlParser extends WebXmlParser { WeblogicXmlParser(ReadableArchive archive) diff --git a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java index 4edc88fb7a8..27a1346530c 100644 --- a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java +++ b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java @@ -332,7 +332,7 @@ public String getMonitoringNodeName() { } /** - * Sets the parameter encoding (i18n) info from web.xml and sun-web.xml and glassfish-web.xml. + * Sets the parameter encoding (i18n) info from web.xml, sun-web.xml, glassfish-web.xml and payara-web.xml. */ public void setI18nInfo() { diff --git a/nucleus/common/internal-api/src/main/java/org/glassfish/internal/deployment/GenericSniffer.java b/nucleus/common/internal-api/src/main/java/org/glassfish/internal/deployment/GenericSniffer.java index ac5220c9d66..e2a35bc99b5 100644 --- a/nucleus/common/internal-api/src/main/java/org/glassfish/internal/deployment/GenericSniffer.java +++ b/nucleus/common/internal-api/src/main/java/org/glassfish/internal/deployment/GenericSniffer.java @@ -328,7 +328,7 @@ public Map getDeploymentConfigurations(final ReadableArchive loca * default implementation to return a list of the deployment descriptors * that might appear in the type of Java EE application which the sniffer * recognizes. For example, the WebSniffer implementation of this method - * returns WEB-INF/web.xml, WEB-INF/glassfish-web.xml and + * returns WEB-INF/web.xml, WEB-INF/glassfish-web.xml, WEB-INF/payara-web.xml and * WEB-INF/sun-web.xml. * * @return list of paths in the archive where deployment configuration diff --git a/nucleus/deployment/common/src/main/java/com/sun/enterprise/deployment/deploy/shared/DeploymentPlanArchive.java b/nucleus/deployment/common/src/main/java/com/sun/enterprise/deployment/deploy/shared/DeploymentPlanArchive.java index 5a4565bbc95..8f6f3f38c3c 100644 --- a/nucleus/deployment/common/src/main/java/com/sun/enterprise/deployment/deploy/shared/DeploymentPlanArchive.java +++ b/nucleus/deployment/common/src/main/java/com/sun/enterprise/deployment/deploy/shared/DeploymentPlanArchive.java @@ -37,6 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2018] Payara Foundation and/or affiliates package com.sun.enterprise.deployment.deploy.shared; @@ -159,6 +160,7 @@ public Collection getDirectories() throws IOException { /** * @return an Enumeration of entries for this archive */ + @Override public Enumeration entries() { // Deployment Plan are organized flatly, @@ -183,12 +185,11 @@ public Enumeration entries() { String prefix = "META-INF/"; ArchiveType warType = locator.getService(ArchiveType.class, "war"); boolean isWar = DeploymentUtils.isArchiveOfType(getParentArchive(), warType, locator); - if (entryName.indexOf("sun-web.xml")!=-1 || - entryName.indexOf("glassfish-web.xml")!=-1) { + if (entryName.contains("sun-web.xml") || entryName.contains("glassfish-web.xml") || entryName.contains("payara-web.xml")) { prefix = "WEB-INF/"; - } else if (entryName.indexOf("glassfish-resources.xml")!=-1 && isWar) { + } else if ((entryName.contains("glassfish-resources.xml") || entryName.contains("payara-resources.xml")) && isWar) { prefix = "WEB-INF/"; - } else if (entryName.indexOf("glassfish-services.xml")!=-1 && isWar) { + } else if ((entryName.contains("glassfish-services.xml") || entryName.contains("payara-services.xml")) && isWar) { prefix = "WEB-INF/"; } if (subArchiveUri != null && entryName.startsWith(subArchiveUri)) { @@ -202,9 +203,7 @@ public Enumeration entries() { if (subArchiveUri==null) { // top level archive - if ((entryName.indexOf(".jar.")!=-1) || - (entryName.indexOf(".war.")!=-1) || - (entryName.indexOf(".rar."))!=-1) { + if ((entryName.contains(".jar.")) || (entryName.contains(".war.")) || entryName.contains(".rar.")) { // this element is in a sub archive continue;