Skip to content

Commit

Permalink
payara-web.xml is recongised
Browse files Browse the repository at this point in the history
  • Loading branch information
Cousjava committed Jul 17, 2018
1 parent a4e3a40 commit 8c9bf24
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 21 deletions.
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Up @@ -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.
Expand Down
Expand Up @@ -49,19 +49,19 @@

It must include a DOCTYPE of the following form:

<!DOCTYPE glassfish-web-app PUBLIC "-/Payara.fish//DTD Payara Application Server 4 Servlet 3.0//EN" "https://raw.githubusercontent.com/payara/Payara/master/appserver/deployment/dtds/src/main/resources/glassfish/lib/dtds/payara-web-app_4.dtd">
<!DOCTYPE payara-web-app PUBLIC "-//Payara.fish//DTD Payara Application Server 4 Servlet 3.0//EN" "https://raw.githubusercontent.com/payara/Payara/master/appserver/deployment/dtds/src/main/resources/glassfish/lib/dtds/payara-web-app_4.dtd">

-->

<!ENTITY % boolean "(yes | no | on | off | 1 | 0 | true | false)">

<!-- root element for vendor specific web application (module) configuration -->
<!ELEMENT glassfish-web-app (context-root?, security-role-mapping*, servlet*, idempotent-url-pattern*, session-config?,
<!ELEMENT payara-web-app (context-root?, security-role-mapping*, servlet*, idempotent-url-pattern*, session-config?,
ejb-ref*, resource-ref*, resource-env-ref*, service-ref*,
message-destination-ref*, cache?, class-loader?,
jsp-config?, locale-charset-info?, parameter-encoding?,
property*, valve*, message-destination*, webservice-description*, scanning-exclude*, scanning-include*, whitelist-package*, keep-state?, version-identifier?, container-initializer-enabled?, jaxrs-roles-allowed-enabled?)>
<!ATTLIST glassfish-web-app error-url CDATA ""
<!ATTLIST payara-web-app error-url CDATA ""
httpservlet-security-provider CDATA #IMPLIED>

<!--
Expand All @@ -75,7 +75,7 @@

<!--
Context Root for the web application when the war file is a standalone module.
When the war module is part of the Java EE Application, use the application.xml
When the war module is part of the Jakarta EE Application, use the application.xml
-->
<!ELEMENT context-root (#PCDATA)>

Expand Down Expand Up @@ -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]
-->
<!ELEMENT cache (cache-helper*, default-helper?, property*, cache-mapping*)>
<!ATTLIST cache max-entries CDATA "4096"
Expand Down Expand Up @@ -321,7 +321,7 @@ value element specifies the applicable value and a matching expression for a con
and resources within the WAR file or the
extra-class-path over those higher up in the
classloader hierarchy, unless those classes or
resources are part of the Java EE platform.
resources are part of the Jakarta EE platform.
If set to its default value of true, classes
and resources residing in container-wide library
JAR files are loaded in preference to classes
Expand Down
Expand Up @@ -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 org.glassfish.web.sniffer;

Expand Down Expand Up @@ -136,6 +137,7 @@ private static List<String> 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");

This comment has been minimized.

Copy link
@johnmanko

johnmanko May 30, 2019

Contributor

Shouldn't this be WEB-INF and not WEB-IND?

result.add("WEB-INF/weblogic.xml");
return result;
}
Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)
Expand Down
Expand Up @@ -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() {

Expand Down
Expand Up @@ -328,7 +328,7 @@ public Map<String,String> 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
Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -159,6 +160,7 @@ public Collection<String> getDirectories() throws IOException {
/**
* @return an Enumeration of entries for this archive
*/
@Override
public Enumeration entries() {
// Deployment Plan are organized flatly,

Expand All @@ -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)) {
Expand All @@ -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;
Expand Down

1 comment on commit 8c9bf24

@johnmanko
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe line 140 of WebSniffer.java should be result.add("WEB-INF/payara-web.xml"); and not result.add("WEB-IND/payara-web.xml");

Please sign in to comment.