Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-2761 Create payara-web.xml functionality #2964

Merged
merged 5 commits into from Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.io;

Expand All @@ -63,6 +64,8 @@ public interface DescriptorConstants {

/** Prefix used for GF xmls */
String GF_PREFIX = "glassfish-";

String PAYARA_PREFIX = "payara-";

/** The name of the deployment descriptor entry in the application ear. */
String APPLICATION_DD_ENTRY = "META-INF"+File.separator+"application.xml";
Expand Down Expand Up @@ -153,6 +156,18 @@ public interface DescriptorConstants {

/** The name of the glassfish deployment descriptor entry in the client jar. */
String GF_APP_CLIENT_JAR_ENTRY = "META-INF/"+ GF_PREFIX + "application-client.xml";

/** The name of the Payara deployment descriptor entry in web jar. */
String PAYARA_WEB_JAR_ENTRY = "WEB-INF/" + PAYARA_PREFIX + "web.xml";

/** The name of the Payara deployment descriptor entry in the ejb jar. */
String PAYARA_EJB_JAR_ENTRY = "META-INF/" + PAYARA_PREFIX + "ejb-jar.xml";

/** The name of the Payara deployment descriptor entry in the war. */
String PAYARA_EJB_IN_WAR_ENTRY = "WEB-INF/" + PAYARA_PREFIX + "ejb-jar.xml";

/** The name of the Payara deployment descriptor entry in the client jar. */
String PAYARA_APP_CLIENT_JAR_ENTRY = "META-INF/"+ PAYARA_PREFIX + "application-client.xml";

/** The name of the weblogic deployment descriptor entry in the war. */
String WLS_EJB_IN_WAR_ENTRY = "WEB-INF/" + WLS_PREFIX + "ejb-jar.xml";
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-2017] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.deployment.util;

Expand Down Expand Up @@ -410,16 +410,19 @@ public static boolean isIgnoreWLSDD() {
// present in the current archive */
private static List<ConfigurationDeploymentDescriptorFile> sortConfigurationDDFiles(List<ConfigurationDeploymentDescriptorFile> ddFiles, ArchiveType archiveType, ReadableArchive archive) {
ConfigurationDeploymentDescriptorFile wlsConfDD = null;
ConfigurationDeploymentDescriptorFile payaraConfDD = null;
ConfigurationDeploymentDescriptorFile gfConfDD = null;
ConfigurationDeploymentDescriptorFile sunConfDD = null;
for (ConfigurationDeploymentDescriptorFile ddFile : ddFiles) {
ddFile.setArchiveType(archiveType);
String ddPath = ddFile.getDeploymentDescriptorPath();
if (ddPath.indexOf(DescriptorConstants.WLS) != -1) {
if (ddPath.contains(DescriptorConstants.WLS)) {
wlsConfDD = ddFile;
} else if (ddPath.indexOf(DescriptorConstants.GF_PREFIX) != -1) {
} else if (ddPath.contains(DescriptorConstants.PAYARA_PREFIX)){
payaraConfDD = ddFile;
} else if (ddPath.contains(DescriptorConstants.GF_PREFIX)) {
gfConfDD = ddFile;
} else if (ddPath.indexOf(DescriptorConstants.S1AS_PREFIX) != -1) {
} else if (ddPath.contains(DescriptorConstants.S1AS_PREFIX)) {
sunConfDD = ddFile;
}
}
Expand All @@ -432,19 +435,24 @@ private static List<ConfigurationDeploymentDescriptorFile> sortConfigurationDDFi
if (runtimeAltDDFile != null && runtimeAltDDFile.exists() && runtimeAltDDFile.isFile()) {
String runtimeAltDDPath = runtimeAltDDFile.getPath();
validateRuntimeAltDDPath(runtimeAltDDPath);
if (runtimeAltDDPath.indexOf(
DescriptorConstants.GF_PREFIX) != -1 && gfConfDD != null) {
if (runtimeAltDDPath.contains(DescriptorConstants.PAYARA_PREFIX) && payaraConfDD != null) {
sortedConfDDFiles.add(payaraConfDD);
return sortedConfDDFiles;
} else if (runtimeAltDDPath.contains(DescriptorConstants.GF_PREFIX) && gfConfDD != null) {
sortedConfDDFiles.add(gfConfDD);
return sortedConfDDFiles;
}
}

// sort the deployment descriptor files by precedence order
// when they are present in the same archive

if (Boolean.valueOf(System.getProperty(GFDD_OVER_WLSDD))) {
// if this property set, it means we need to make GF deployment
// descriptors higher precedence
// descriptors higher precedence then weblogic
if (payaraConfDD != null){
sortedConfDDFiles.add(payaraConfDD);
}
if (gfConfDD != null) {
sortedConfDDFiles.add(gfConfDD);
}
Expand All @@ -457,11 +465,17 @@ private static List<ConfigurationDeploymentDescriptorFile> sortConfigurationDDFi
if (gfConfDD != null) {
sortedConfDDFiles.add(gfConfDD);
}
if (payaraConfDD != null){
sortedConfDDFiles.add(payaraConfDD);
}
} else {
// the default will be WLS DD has higher precedence
if (wlsConfDD != null) {
sortedConfDDFiles.add(wlsConfDD);
}
if (payaraConfDD != null){
sortedConfDDFiles.add(payaraConfDD);
}
if (gfConfDD != null) {
sortedConfDDFiles.add(gfConfDD);
}
Expand All @@ -479,7 +493,7 @@ private static List<ConfigurationDeploymentDescriptorFile> sortConfigurationDDFi
* @param runtimeAltDDPath
*/
public static void validateRuntimeAltDDPath(String runtimeAltDDPath) {
if (runtimeAltDDPath.indexOf(DescriptorConstants.GF_PREFIX) == -1) {
if (!runtimeAltDDPath.contains(DescriptorConstants.GF_PREFIX) && !runtimeAltDDPath.contains(DescriptorConstants.PAYARA_PREFIX)) {
String msg = localStrings.getLocalString(
"enterprise.deployment.util.unsupportedruntimealtdd", "Unsupported external runtime alternate deployment descriptor [{0}].", new Object[] {runtimeAltDDPath});
throw new IllegalArgumentException(msg);
Expand All @@ -496,8 +510,7 @@ public static void validateRuntimeAltDDPath(String runtimeAltDDPath) {
* @return
* @throws java.io.IOException */
public static List<ConfigurationDeploymentDescriptorFile> processConfigurationDDFiles(List<ConfigurationDeploymentDescriptorFile> ddFiles, ReadableArchive archive, ArchiveType archiveType) throws IOException {
File runtimeAltDDFile = archive.getArchiveMetaData(
DeploymentProperties.RUNTIME_ALT_DD, File.class);
File runtimeAltDDFile = archive.getArchiveMetaData(DeploymentProperties.RUNTIME_ALT_DD, File.class);
if (runtimeAltDDFile != null && runtimeAltDDFile.exists() && runtimeAltDDFile.isFile()) {
// if there are external runtime alternate deployment descriptor
// specified, the config DD files are already processed
Expand Down Expand Up @@ -528,17 +541,17 @@ public static void readAlternativeRuntimeDescriptor(ReadableArchive appArchive,
List<ConfigurationDeploymentDescriptorFile> archivistConfDDFiles = archivist.getConfigurationDDFiles();
for (ConfigurationDeploymentDescriptorFile ddFile : sortConfigurationDDFiles(archivistConfDDFiles, archivist.getModuleType(), embeddedArchive)) {
String ddPath = ddFile.getDeploymentDescriptorPath();
if (ddPath.indexOf(DescriptorConstants.WLS) != -1 &&
appArchive.exists(DescriptorConstants.WLS + altDDPath)) {
if (ddPath.contains(DescriptorConstants.WLS) && appArchive.exists(DescriptorConstants.WLS + altDDPath)) {
// TODO: need to revisit this for WLS alt-dd pattern
confDD = ddFile;
altRuntimeDDPath = DescriptorConstants.WLS + altDDPath;
} else if (ddPath.indexOf(DescriptorConstants.GF_PREFIX) != -1 &&
appArchive.exists(DescriptorConstants.GF_PREFIX + altDDPath)) {
} else if (ddPath.contains(DescriptorConstants.PAYARA_PREFIX) && appArchive.exists(DescriptorConstants.PAYARA_PREFIX + altDDPath)) {
confDD = ddFile;
altRuntimeDDPath = DescriptorConstants.PAYARA_PREFIX + altDDPath;
} else if (ddPath.contains(DescriptorConstants.GF_PREFIX) && appArchive.exists(DescriptorConstants.GF_PREFIX + altDDPath)) {
confDD = ddFile;
altRuntimeDDPath = DescriptorConstants.GF_PREFIX + altDDPath;
} else if (ddPath.indexOf(DescriptorConstants.S1AS_PREFIX) != -1
&& appArchive.exists(DescriptorConstants.S1AS_PREFIX + altDDPath)){
} else if (ddPath.contains(DescriptorConstants.S1AS_PREFIX) && appArchive.exists(DescriptorConstants.S1AS_PREFIX + altDDPath)){
confDD = ddFile;
altRuntimeDDPath = DescriptorConstants.S1AS_PREFIX + altDDPath;
}
Expand Down Expand Up @@ -769,7 +782,7 @@ public static boolean setElementValue(XMLElement element,
if (SCHEMA_LOCATION_TAG.equals(element.getCompleteName())) {
// we need to keep all the non j2ee/javaee schemaLocation tags
StringTokenizer st = new StringTokenizer(value);
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
while (st.hasMoreElements()) {
String namespace = (String) st.nextElement();
String schema;
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

// 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 Server 4 Servlet 3.0//EN";
public static final String PAYARA_WEBAPP_4_DTD_SYSTEM_ID = "https://docs.payara.fish/schemas/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