NX01: Converted x4o-driver to named module with workarounds for tests
All checks were successful
Run test asserts / Test-Asserts (push) Successful in 14s
All checks were successful
Run test asserts / Test-Asserts (push) Successful in 14s
This commit is contained in:
parent
7ce5c2fc91
commit
c8c5939d48
6 changed files with 33 additions and 29 deletions
|
|
@ -30,29 +30,26 @@
|
|||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
open module ᣕᕁᐤᣳ.ᕽᙾᐤ.ᒄᣗᑊᘁᓫᣗ {
|
||||
// TODO: if driver is module than ClassLoader.getResources from /META-INF/* don't work anymore
|
||||
// should work as docs say META-INF is no package thus can't be encapsulated, try again later
|
||||
// TODO: remove open after qa module, as all test resources only work if open...
|
||||
// thus local tests that remain, can only use inline xml if module is not open...
|
||||
|
||||
// TODO: move qa tests own project as we get duplicate resouces from "ONE" module filtered to last one which breaks testing
|
||||
|
||||
requires transitive ᣕᕁᐤᣳ.ᕽᙾᐤ.ᔆᣔᕽᕀᕀᕀ;
|
||||
requires transitive ᣕᕁᐤᣳ.ᕽᙾᐤ.ᔿᣔᑊᔆᒄᐤᒼ;
|
||||
requires transitive ᣕᕁᐤᣳ.ᕽᙾᐤ.ᣘᒼᣳᔥ;
|
||||
requires transitive java.logging;
|
||||
// TODO: remove EL, this breaks OSGI resolving
|
||||
//requires transitive org.apache.tomcat.jasper.el;
|
||||
|
||||
// TEMP for tests only
|
||||
// TEMP for tests only, until split to nx01-x4o-driver-qa module
|
||||
requires java.desktop;
|
||||
// M2E is correct for now allowing two module-info per project, missing;
|
||||
//test-requires java.desktop;
|
||||
//test-requires transitive org.junit.jupiter.engine;
|
||||
//test-requires transitive org.junit.jupiter.api;
|
||||
|
||||
exports META-INF/x4o-drivers.xml;
|
||||
|
||||
exports org.x4o.xml;
|
||||
exports org.x4o.xml.conv;
|
||||
exports org.x4o.xml.conv.text;
|
||||
exports org.x4o.xml.el;
|
||||
exports org.x4o.xml.eld;
|
||||
exports org.x4o.xml.eld.doc;
|
||||
exports org.x4o.xml.eld.lang;
|
||||
|
|
@ -27,7 +27,6 @@ import java.io.InputStream;
|
|||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -234,14 +233,12 @@ public final class X4ODriverManager {
|
|||
private void loadLanguageDrivers() {
|
||||
logger.finer("loading x4o drivers from: " + X4O_DRIVERS_RESOURCE);
|
||||
try {
|
||||
Enumeration<URL> e = Thread.currentThread().getContextClassLoader().getResources(X4O_DRIVERS_RESOURCE);
|
||||
while (e.hasMoreElements()) {
|
||||
URL u = e.nextElement();
|
||||
for (URL u : X4OLanguageClassLoader.getResourcesAll(X4O_DRIVERS_RESOURCE)) {
|
||||
loadDriversXml(u.openStream());
|
||||
}
|
||||
e = Thread.currentThread().getContextClassLoader().getResources("/" + X4O_DRIVERS_RESOURCE);
|
||||
while (e.hasMoreElements()) {
|
||||
URL u = e.nextElement();
|
||||
// TODO fix RM temp below and move x4o-drivers.xml + tests to "nx01-x4o-driver-qa" module
|
||||
// bug: if test source code also contains "x4o-driver.xml" than "x4o-driver.xml" from main code is not loaded when running from junit runner
|
||||
for (URL u : X4OLanguageClassLoader.getResourcesAll("META-INF/x4o-drivers-test.xml")) {
|
||||
loadDriversXml(u.openStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
@ -286,7 +283,7 @@ public final class X4ODriverManager {
|
|||
String language = attr.getValue("language");
|
||||
String className = attr.getValue("className");
|
||||
logger.finest("Driver className: " + className + " for language: " + language);
|
||||
if (classdrivers.containsKey(className) == false) {
|
||||
if (classdrivers.containsKey(language) == false) {
|
||||
classdrivers.put(language, className);
|
||||
}
|
||||
} else if ("defaultDriver".equals(tag)) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import java.io.InputStream;
|
|||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
@ -227,17 +226,8 @@ public class DefaultX4OLanguageLoader implements X4OLanguageLoader {
|
|||
|
||||
logger.finer("loading X4O language: " + language);
|
||||
try {
|
||||
Enumeration<URL> e = Thread.currentThread().getContextClassLoader().getResources(buf.toString());
|
||||
while (e.hasMoreElements()) {
|
||||
URL u = e.nextElement();
|
||||
logMessage(session, "Loading relative modules: " + u + " for: " + language);
|
||||
result.addAll(loadLanguageModulesXml(u.openStream(), u.toString()));
|
||||
}
|
||||
|
||||
e = Thread.currentThread().getContextClassLoader().getResources("/" + buf.toString());
|
||||
while (e.hasMoreElements()) {
|
||||
URL u = e.nextElement();
|
||||
logMessage(session, "Loading root modules: " + u + " for: " + language);
|
||||
for (URL u : X4OLanguageClassLoader.getResourcesAll(buf.toString())) {
|
||||
logMessage(session, "Loading resource modules: " + u + " for: " + language);
|
||||
result.addAll(loadLanguageModulesXml(u.openStream(), u.toString()));
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -22,9 +22,13 @@
|
|||
*/
|
||||
package org.x4o.xml.lang;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* X4OLanguageClassLoader is short hand for safe class loading.
|
||||
|
|
@ -40,6 +44,20 @@ public final class X4OLanguageClassLoader {
|
|||
private X4OLanguageClassLoader() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all the resources from local jar and other jars.
|
||||
*
|
||||
* NOTE: Set is workaround for maven junit runner duplicate resouces returned in tests if project is named module.
|
||||
*
|
||||
* @return Returns the set of resouces found.
|
||||
*/
|
||||
public static Set<URL> getResourcesAll(String resourceName) throws IOException {
|
||||
Set<URL> result = new HashSet<>();
|
||||
getClassLoader().getResources(resourceName).asIterator().forEachRemaining(result::add);
|
||||
getClassLoader().getResources("/" + resourceName).asIterator().forEachRemaining(result::add);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the thread classloader or the normal classloader.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@
|
|||
///
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
module ᣕᕁᐤᣳ.ᕽᙾᐤ.ᔿᣔᑊᔆᒄᐤᒼ {
|
||||
open module ᣕᕁᐤᣳ.ᕽᙾᐤ.ᔿᣔᑊᔆᒄᐤᒼ {
|
||||
//note: open for classloader resources(js/css) loading from this module
|
||||
|
||||
requires transitive ᣕᕁᐤᣳ.ᕽᙾᐤ.ᔆᣔᕽᕀᕀᕀ;
|
||||
requires transitive java.logging;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue