-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LDEV-5040 - completely reorganise how javasettings are loaded
- Loading branch information
1 parent
93cfb65
commit 4300d16
Showing
23 changed files
with
317 additions
and
389 deletions.
There are no files selected for viewing
62 changes: 22 additions & 40 deletions
62
core/src/main/java/lucee/commons/io/res/util/MavenClassLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,25 @@ | ||
package lucee.commons.io.res.util; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import lucee.runtime.mvn.POM; | ||
|
||
public class MavenClassLoader extends ResourceClassLoader { | ||
|
||
private static Map<String, MavenClassLoader> instances = new ConcurrentHashMap<>(); | ||
private POM pom; | ||
|
||
public MavenClassLoader(POM pom, ClassLoader parent) throws IOException { | ||
super(pom.getJars(), parent); | ||
this.pom = pom; | ||
} | ||
|
||
public static MavenClassLoader getInstance(POM pom, ClassLoader parent) throws IOException { | ||
MavenClassLoader mcl = instances.get(pom.hash()); | ||
if (mcl == null) { | ||
mcl = new MavenClassLoader(pom, parent); | ||
instances.put(pom.hash(), mcl); | ||
} | ||
return mcl; | ||
} | ||
|
||
public static MavenClassLoader getInstance(POM[] poms, ClassLoader parent) throws IOException { | ||
if (poms == null || poms.length == 0) throw new IOException("you need to define at least one POM."); | ||
|
||
Arrays.sort(poms, (pom1, pom2) -> pom1.id().compareTo(pom2.id())); | ||
|
||
for (POM pom: poms) { | ||
parent = getInstance(pom, parent); | ||
} | ||
return (MavenClassLoader) parent; | ||
} | ||
|
||
public POM getPOM() { | ||
return pom; | ||
} | ||
public class MavenClassLoader {// extends ResourceClassLoader { | ||
/* | ||
* private static Map<String, MavenClassLoader> instances = new ConcurrentHashMap<>(); private POM | ||
* pom; | ||
* | ||
* public MavenClassLoader(POM pom, ClassLoader parent) throws IOException { super(pom.getJars(), | ||
* parent); this.pom = pom; } | ||
* | ||
* public static MavenClassLoader getInstance(POM pom, ClassLoader parent) throws IOException { | ||
* MavenClassLoader mcl = instances.get(pom.hash()); if (mcl == null) { mcl = new | ||
* MavenClassLoader(pom, parent); instances.put(pom.hash(), mcl); } return mcl; } | ||
* | ||
* public static MavenClassLoader getInstance(POM[] poms, ClassLoader parent) throws IOException { | ||
* if (poms == null || poms.length == 0) throw new | ||
* IOException("you need to define at least one POM."); | ||
* | ||
* Arrays.sort(poms, (pom1, pom2) -> pom1.id().compareTo(pom2.id())); | ||
* | ||
* for (POM pom: poms) { parent = getInstance(pom, parent); } return (MavenClassLoader) parent; } | ||
* | ||
* public POM getPOM() { return pom; } | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.