Skip to content

Commit

Permalink
using useWarLibraries()
Browse files Browse the repository at this point in the history
  • Loading branch information
lprimak committed Dec 2, 2024
1 parent bb07577 commit d47ba52
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -130,6 +132,8 @@ public class WarHandler extends AbstractArchiveHandler {

@Inject
private ServerEnvironment serverEnvironment;
@Inject
private Deployment deployment;

@Override
public String getArchiveType() {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public Set<String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,16 @@ public static List<URI> 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
Expand Down

0 comments on commit d47ba52

Please sign in to comment.