Hisoka-X commented on code in PR #2193:
URL:
https://github.com/apache/incubator-seatunnel/pull/2193#discussion_r923077654
##########
seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/AbstractPluginDiscovery.java:
##########
@@ -40,15 +43,34 @@
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.BiConsumer;
import java.util.stream.Collectors;
public abstract class AbstractPluginDiscovery<T> implements PluginDiscovery<T>
{
private static final Logger LOGGER =
LoggerFactory.getLogger(AbstractPluginDiscovery.class);
private final Path pluginDir;
+ /**
+ * Add jar url to classloader. The different engine should have different
logic to add url into
+ * their own classloader
+ */
+ private BiConsumer<ClassLoader, URL> addURLToClassLoader = (classLoader,
url) -> {
+ if (classLoader instanceof URLClassLoader) {
+ ReflectionUtils.invoke(classLoader, "addURL", url);
+ } else {
+ throw new UnsupportedOperationException("can't support custom load
jar");
+ }
+ };
+
protected final ConcurrentHashMap<PluginIdentifier, Optional<URL>>
pluginJarPath =
- new ConcurrentHashMap<>(Common.COLLECTION_SIZE);
+ new ConcurrentHashMap<>(Common.COLLECTION_SIZE);
+
+ public AbstractPluginDiscovery(String pluginSubDir,
BiConsumer<ClassLoader, URL> addURLToClassloader) {
Review Comment:
This BiConsumer mean engine use their classloader to add url into itself. So
caller should tell `AbstractPluginDiscovery ` how to add url into their
classloader. The `AbstractPluginDiscovery` is without engine. So it can't
decide how to add url into classloader( but also have default implement).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]