From d47ba52a02611285f68fb89fcc277085dc634f88 Mon Sep 17 00:00:00 2001 From: lprimak Date: Mon, 2 Dec 2024 02:26:01 -0600 Subject: [PATCH] using useWarLibraries() --- .../java/com/sun/enterprise/glassfish/web/WarHandler.java | 6 +++++- .../glassfish/web/deployment/archivist/WebArchivist.java | 2 +- .../org/glassfish/deployment/common/DeploymentUtils.java | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) 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 2078de1a85d..7e4563d018a 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 @@ -80,7 +80,9 @@ import org.glassfish.api.deployment.archive.ArchiveDetector; import org.glassfish.api.deployment.archive.ReadableArchive; import org.glassfish.deployment.common.DeploymentProperties; +import org.glassfish.deployment.common.DeploymentUtils; import org.glassfish.deployment.common.InstalledLibrariesResolver; +import org.glassfish.internal.deployment.Deployment; import org.glassfish.loader.util.ASClassLoaderUtil; import org.glassfish.web.loader.LogFacade; import org.glassfish.web.loader.WebappClassLoader; @@ -130,6 +132,8 @@ public class WarHandler extends AbstractArchiveHandler { @Inject private ServerEnvironment serverEnvironment; + @Inject + private Deployment deployment; @Override public String getArchiveType() { @@ -193,7 +197,7 @@ public WebappClassLoader run() { WebXmlParser webXmlParser = getWebXmlParser(context.getSource(), application); configureLoaderAttributes(cloader, webXmlParser, base); configureLoaderProperties(cloader, webXmlParser, base); - if (!cloader.isInternal()) { + if (!cloader.isInternal() && DeploymentUtils.useWarLibraries(deployment.getCurrentDeploymentContext())) { for (Path warLibrary : InstalledLibrariesResolver.getWarLibraries()) { cloader.addJar(warLibrary.toString(), new JarFile(warLibrary.toFile()), warLibrary.toFile()); cloader.closeJARs(true); diff --git a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java index 0157936ca7b..8baaf69eb42 100644 --- a/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java +++ b/appserver/web/web-glue/src/main/java/org/glassfish/web/deployment/archivist/WebArchivist.java @@ -317,7 +317,7 @@ public Set getLibraries(ReadableArchive archive) throws IOException { extractLibraries(parentArchive.getSubArchive("lib"), false, libraries); } // Webapp shared libraries - if(!deployment.getCurrentDeploymentContext().getCommandParameters(DeployCommandParameters.class).name().startsWith("__")) { + if(DeploymentUtils.useWarLibraries(deployment.getCurrentDeploymentContext())) { InstalledLibrariesResolver.getWarLibraries().forEach(warLibrary -> libraries.add(warLibrary.toString())); } return libraries; diff --git a/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/DeploymentUtils.java b/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/DeploymentUtils.java index f26b2410c3e..d7a623fac6a 100644 --- a/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/DeploymentUtils.java +++ b/nucleus/deployment/common/src/main/java/org/glassfish/deployment/common/DeploymentUtils.java @@ -446,12 +446,16 @@ public static List getExternalLibraries(ReadableArchive archive) { try { context = Globals.getDefaultHabitat().getService(Deployment.class).getCurrentDeploymentContext(); } catch (Exception e) { } - if(context != null && !context.getCommandParameters(DeployCommandParameters.class).name().startsWith("__")) { + if(useWarLibraries(context)) { InstalledLibrariesResolver.getWarLibraries().stream().map(Path::toUri).forEach(externalLibURIs::add); } return externalLibURIs; } + public static boolean useWarLibraries(DeploymentContext context) { + return context != null && Boolean.parseBoolean(context.getAppProps().getProperty("warlibs")); + } + /** * Opens the specified file as an archive, using the provided archive factory. * @param dir directory to be opened as an archive