Skip to content

Commit

Permalink
WebappClassLoader is parallel capable
Browse files Browse the repository at this point in the history
- but it should be optimized.

Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Jan 15, 2023
1 parent 488acdc commit 98abd41
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
9 changes: 9 additions & 0 deletions appserver/web/war-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,14 @@
<artifactId>security-ee</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@
public class WebappClassLoader extends GlassfishUrlClassLoader
implements Reloader, InstrumentableClassLoader, PreDestroy, DDPermissionsLoader, JarFileResourcesProvider {

static {
registerAsParallelCapable();
}

/** First try parent classloader, then own resources. */
public static final boolean DELEGATE_DEFAULT = true;
private static final Logger logger = LogFacade.getLogger();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2023 Eclipse Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.web.loader;

import java.net.URL;
import java.net.URLClassLoader;

import org.glassfish.common.util.GlassfishUrlClassLoader;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author David Matejcek
*/
public class WebappClassLoaderTest {

@Test
public void isParallel() {
assertAll(
() -> assertTrue(new URLClassLoader(new URL[0]).isRegisteredAsParallelCapable()),
() -> assertTrue(new GlassfishUrlClassLoader(new URL[0]).isRegisteredAsParallelCapable()),
() -> assertTrue(new WebappClassLoader().isRegisteredAsParallelCapable())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
*/
public class GlassfishUrlClassLoader extends URLClassLoader {

static {
registerAsParallelCapable();
}


/**
* Initializes the internal classpath.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2023 Eclipse Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.common.util;

import java.net.URL;
import java.net.URLClassLoader;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author David Matejcek
*/
public class GlassfishUrlClassLoaderTest {

@Test
public void isParallel() {
assertAll(
() -> assertTrue(new URLClassLoader(new URL[0]).isRegisteredAsParallelCapable()),
() -> assertTrue(new GlassfishUrlClassLoader(new URL[0]).isRegisteredAsParallelCapable())
);
}
}

0 comments on commit 98abd41

Please sign in to comment.