Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lprimak committed Dec 4, 2024
1 parent e81e418 commit b981b61
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2024] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2023] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.glassfish.web;

Expand All @@ -56,7 +56,6 @@
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
Expand All @@ -80,9 +79,6 @@
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 @@ -132,8 +128,6 @@ public class WarHandler extends AbstractArchiveHandler {

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

@Override
public String getArchiveType() {
Expand Down Expand Up @@ -197,6 +191,7 @@ public WebappClassLoader run() {
WebXmlParser webXmlParser = getWebXmlParser(context.getSource(), application);
configureLoaderAttributes(cloader, webXmlParser, base);
configureLoaderProperties(cloader, webXmlParser, base);

configureContextXmlAttribute(cloader, base, context);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,16 @@ public boolean modified() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (isInternal()) {
Predicate<String> matchesInternal = str -> str.matches(".*generated/.*__.*");
boolean isInternal = false;
if (repositoryURLs != null) {
isInternal = Arrays.stream(repositoryURLs).map(URL::toString)
.filter(matchesInternal).findAny().isPresent();
}
if (canonicalLoaderDir != null && matchesInternal.test(canonicalLoaderDir)) {
isInternal = true;
}
if (isInternal) {
sb.append("(internal) ");
}
sb.append("WebappClassLoader (delegate=");
Expand Down Expand Up @@ -2100,17 +2109,6 @@ public void stop() throws Exception {
}
}

public boolean isInternal() {
Predicate<String> matchesInternal = str -> str.matches(".*generated/.*__.*");
if (repositoryURLs != null) {
return Arrays.stream(repositoryURLs).map(URL::toString)
.filter(matchesInternal).findAny().isPresent();
}
if (canonicalLoaderDir != null && matchesInternal.test(canonicalLoaderDir)) {
return true;
}
return false;
}

/**
* Used to periodically signal to the classloader to release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2024] [Payara Foundation and/or its affiliates]

package org.glassfish.web.deployment.annotation.impl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@

import com.sun.enterprise.deploy.shared.ArchiveFactory;
import com.sun.enterprise.deployment.Application;
import com.sun.enterprise.deployment.BundleDescriptor;
import com.sun.enterprise.deployment.EarType;
import javassist.runtime.Desc;
import org.glassfish.deployment.common.Descriptor;
import org.glassfish.deployment.common.InstalledLibrariesResolver;
import org.glassfish.deployment.common.RootDeploymentDescriptor;
import com.sun.enterprise.deployment.EjbBundleDescriptor;
Expand Down Expand Up @@ -82,7 +79,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.File;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Enumeration;
Expand All @@ -92,7 +88,6 @@
import java.util.Map;
import java.util.Set;
import java.net.URL;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -381,7 +376,7 @@ protected void postAnnotationProcess(WebBundleDescriptorImpl descriptor,
}
}
DeploymentUtils.getWarLibraryCache().putIfAbsent(wfDesc.getWarLibraryPath(),
new DeploymentUtils.WarLibraryDescriptor(wfDesc, computeTypes(wfDesc)));
new DeploymentUtils.WarLibraryDescriptor(wfDesc, filterTypesByWarLibrary(wfDesc)));
}
} else {
super.readAnnotations(archive, wfDesc, localExtensions);
Expand Down Expand Up @@ -423,8 +418,11 @@ protected void postAnnotationProcess(WebBundleDescriptorImpl descriptor,
descriptor.addDefaultWebBundleDescriptor(defaultWebBundleDescriptor);
}

private List<Type> computeTypes(WebFragmentDescriptor wfDesc) {
private List<Type> filterTypesByWarLibrary(WebFragmentDescriptor wfDesc) {
Types types = deployment.getCurrentDeploymentContext().getTransientAppMetaData(Types.class.getName(), Types.class);
if (types == null) {
return List.of();
}
return types.getAllTypes().stream().filter(key -> key.wasDefinedIn(
List.of(Path.of(wfDesc.getWarLibraryPath()).toUri()))).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import org.glassfish.loader.util.ASClassLoaderUtil;

import java.lang.ref.WeakReference;
import java.nio.file.Path;
import java.util.*;
import java.util.logging.Logger;
import java.io.File;
Expand All @@ -74,10 +73,6 @@
import com.sun.enterprise.util.io.FileUtils;
import fish.payara.nucleus.hotdeploy.ApplicationState;
import fish.payara.nucleus.hotdeploy.HotDeployService;
import java.io.Closeable;
import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.FINEST;
import org.glassfish.api.deployment.DeployCommandParameters;
Expand Down

0 comments on commit b981b61

Please sign in to comment.