private ClassLoader lookupClassLoader() { final Class<?>[] classStack = contextSecurityManager.getExecutionStack(); for (Class<?> currentClass : classStack) { final Class<?> narClass = findNarClass(currentClass); if (narClass != null) { final ClassLoader desiredClassLoader = narClass.getClassLoader(); // When new Threads are created, the new Thread inherits the ClassLoaderContext of // the caller. However, the call stack of that new Thread may not trace back to any NiFi-specific // code. Therefore, the NarThreadContextClassLoader will be unable to find the appropriate NAR // ClassLoader. As a result, we want to set the ContextClassLoader to the NAR ClassLoader that // contains the class or resource that we are looking for. // This locks the current Thread into the appropriate NAR ClassLoader Context. The framework will change // the ContextClassLoader back to the NarThreadContextClassLoader as appropriate via the // {@link FlowEngine.beforeExecute(Thread, Runnable)} and // {@link FlowEngine.afterExecute(Thread, Runnable)} methods. if (desiredClassLoader instanceof NarClassLoader) { Thread.currentThread().setContextClassLoader(desiredClassLoader); } return desiredClassLoader; } } return forward; }
private ClassLoader lookupClassLoader() { final Class<?>[] classStack = contextSecurityManager.getExecutionStack(); for (Class<?> currentClass : classStack) { final Class<?> narClass = findNarClass(currentClass); if (narClass != null) { final ClassLoader desiredClassLoader = narClass.getClassLoader(); // When new Threads are created, the new Thread inherits the ClassLoaderContext of // the caller. However, the call stack of that new Thread may not trace back to any NiFi-specific // code. Therefore, the NarThreadContextClassLoader will be unable to find the appropriate NAR // ClassLoader. As a result, we want to set the ContextClassLoader to the NAR ClassLoader that // contains the class or resource that we are looking for. // This locks the current Thread into the appropriate NAR ClassLoader Context. The framework will change // the ContextClassLoader back to the NarThreadContextClassLoader as appropriate via the // {@link FlowEngine.beforeExecute(Thread, Runnable)} and // {@link FlowEngine.afterExecute(Thread, Runnable)} methods. if (desiredClassLoader instanceof NarClassLoader) { Thread.currentThread().setContextClassLoader(desiredClassLoader); } return desiredClassLoader; } } return forward; }
private ClassLoader lookupClassLoader() { final Class<?>[] classStack = contextSecurityManager.getExecutionStack(); for (Class<?> currentClass : classStack) { final Class<?> narClass = findNarClass(currentClass); if (narClass != null) { final ClassLoader desiredClassLoader = narClass.getClassLoader(); // When new Threads are created, the new Thread inherits the ClassLoaderContext of // the caller. However, the call stack of that new Thread may not trace back to any NiFi-specific // code. Therefore, the NarThreadContextClassLoader will be unable to find the appropriate NAR // ClassLoader. As a result, we want to set the ContextClassLoader to the NAR ClassLoader that // contains the class or resource that we are looking for. // This locks the current Thread into the appropriate NAR ClassLoader Context. The framework will change // the ContextClassLoader back to the NarThreadContextClassLoader as appropriate via the // {@link FlowEngine.beforeExecute(Thread, Runnable)} and // {@link FlowEngine.afterExecute(Thread, Runnable)} methods. if (desiredClassLoader instanceof NarClassLoader) { Thread.currentThread().setContextClassLoader(desiredClassLoader); } return desiredClassLoader; } } return forward; }
Class<?>[] getExecutionStack() { return getClassContext(); } }
Class<?>[] getExecutionStack() { return getClassContext(); } }
Class<?>[] getExecutionStack() { return getClassContext(); } }