Skip to content

feat: support getWebAppClassLoader from context #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions jmg-core/src/main/java/jmg/core/template/BESFilterInjectorTpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,18 @@ public Thread[] getThreads() {
return var0;
}

private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object loader = invokeMethod(context, "getLoader", null, null);
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
}
}

private Object getFilter(Object context) throws Exception {
Object filter = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = getWebAppClassLoader(context);
try {
filter = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,18 @@ public Thread[] getThreads() {
return var0;
}

private Object getListener(Object context) throws Exception {
Object listener = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object loader = invokeMethod(context, "getLoader", null, null);
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
}
}

private Object getListener(Object context) throws Exception {
Object listener = null;
ClassLoader classLoader = getWebAppClassLoader(context);
try {
listener = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ public List<Object> getContext() throws IllegalAccessException, NoSuchMethodExce
return contexts;
}

private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object loader = invokeMethod(context, "getLoader", null, null);
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
}
}

private Object getFilter(Object context) throws Exception {
Object filter = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = getWebAppClassLoader(context);
try {
filter = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ public List<Object> getContext() throws IllegalAccessException, NoSuchMethodExce
return contexts;
}

private Object getListener(Object context) throws Exception {
Object listener = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object loader = invokeMethod(context, "getLoader", null, null);
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
}
}

private Object getListener(Object context) throws Exception {
Object listener = null;
ClassLoader classLoader = getWebAppClassLoader(context);
try {
listener = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,17 @@ private Object getContextFromHttpConnection(Thread thread) throws Exception {
throw new Exception("HttpConnection not found");
}

public ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader"));
} catch (Exception e) {
return ((ClassLoader) getFV(context, "_classLoader"));
}
}

private Object getFilter(Object context) {

private Object getFilter(Object context) throws Exception {
Object filter = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = getWebAppClassLoader(context);
try {
filter = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,17 @@ private Object getContextFromHttpConnection(Thread thread) throws Exception {
throw new Exception("HttpConnection not found");
}

public ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader"));
} catch (Exception e) {
return ((ClassLoader) getFV(context, "_classLoader"));
}
}

private Object getListener(Object context) {
private Object getListener(Object context) throws Exception {
Object listener = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = getWebAppClassLoader(context);
try {
listener = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,17 @@ public List<Object> getContext() {

}

private Object getFilter(Object context) {
Object filter = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
return ((ClassLoader) getFV(context, "_classLoader"));
}
}

private Object getFilter(Object context) throws Exception {
Object filter = null;
ClassLoader classLoader = getWebAppClassLoader(context);
try {
filter = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ public List<Object> getContext() {

}

private Object getListener(Object context) {
Object listener = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
return ((ClassLoader) getFV(context, "_classLoader"));
}
}

private Object getListener(Object context) throws Exception {
Object listener = null;
ClassLoader classLoader = getWebAppClassLoader(context);
try {
listener = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,19 @@ else if (thread.getContextClassLoader() != null && (thread.getContextClassLoader
return contexts;
}

private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object loader = invokeMethod(context, "getLoader", null, null);
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
}
}

private Object getFilter(Object context) {
private Object getFilter(Object context) throws Exception {

Object filter = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = getWebAppClassLoader(context);
try {
filter = classLoader.loadClass(getClassName());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ else if (thread.getContextClassLoader() != null && (thread.getContextClassLoader
return contexts;
}

private Object getListener(Object context) {
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object loader = invokeMethod(context, "getLoader", null, null);
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
}
}

private Object getListener(Object context) throws Exception {

Object listener = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = getWebAppClassLoader(context);
try {
listener = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ else if (thread.getContextClassLoader() != null && (thread.getContextClassLoader

private Object getValve(Object context) {
Object valve = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = context.getClass().getClassLoader();
try {
valve = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,18 @@ public Thread[] getThreads() throws Exception {
return var0;
}

private Object getListener(Object context) throws IllegalAccessException {
Object listener = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object loader = invokeMethod(context, "getLoader", null, null);
return ((ClassLoader) invokeMethod(loader, "getClassLoader", null, null));
}
}

private Object getListener(Object context) throws Exception {
Object listener = null;
ClassLoader classLoader = getWebAppClassLoader(context);
try {
listener = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ public List<Object> getContext() throws IllegalAccessException, NoSuchMethodExce
return contexts;
}

private Object getFilter(Object context) {
Object filter = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object deploymentInfo = getFV(context, "deploymentInfo");
return ((ClassLoader) invokeMethod(deploymentInfo, "getClassLoader", null, null));
}
}

private Object getFilter(Object context) throws Exception {
Object filter = null;
ClassLoader classLoader = getWebAppClassLoader(context);
try {
filter = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ public List<Object> getContext() throws IllegalAccessException, NoSuchMethodExce
return contexts;
}

private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
Object deploymentInfo = getFV(context, "deploymentInfo");
return ((ClassLoader) invokeMethod(deploymentInfo, "getClassLoader", null, null));
}
}

private Object getListener(Object context) {
private Object getListener(Object context) throws Exception {
Object listener = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = getWebAppClassLoader(context);
try {
listener = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,17 @@ public static Object[] getContext() {
return webappContexts.toArray();
}

private Object getFilter(Object context) {
Object filter = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
return ((ClassLoader) getFV(context, "classLoader"));
}
}

private Object getFilter(Object context) throws Exception {
Object filter = null;
ClassLoader classLoader = getWebAppClassLoader(context);
try {
filter = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,18 @@ public static Object[] getContext() {
return webappContexts.toArray();
}

private Object getListener(Object context) {
public ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
return ((ClassLoader) getFV(context, "classLoader"));
}
}

private Object getListener(Object context) throws Exception {

Object listener = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
}
ClassLoader classLoader = getWebAppClassLoader(context);
try {
listener = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,17 @@ public static synchronized Object invokeMethod(final Object obj, final String me
}
}

public Object getFilter(Object context) {
Object filter = null;
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = context.getClass().getClassLoader();
private ClassLoader getWebAppClassLoader(Object context) throws Exception {
try {
return ((ClassLoader) invokeMethod(context, "getClassLoader", null, null));
} catch (Exception e) {
return ((ClassLoader) getFV(context, "loader"));
}
}

public Object getFilter(Object context) throws Exception {
Object filter = null;
ClassLoader classLoader = getWebAppClassLoader(context);
try {
filter = classLoader.loadClass(getClassName()).newInstance();
} catch (Exception e) {
Expand Down
Loading