@Test void addPluginMultiThread(@TempDir final File temporaryFolder) throws InterruptedException { final File pluginFolder = new File(temporaryFolder, "test-plugins_" + UUID.randomUUID().toString()); pluginFolder.mkdirs(); final File plugin = pluginGenerator.createChainPlugin(pluginFolder, "plugin.jar"); DynamicContainerFinder.SERVICES.put(RecordBuilderFactory.class, new RecordBuilderFactoryImpl("plugin")); final String jvd = System.getProperty("java.version.date"); System.clearProperty("java.version.date"); try (final ComponentManager manager = new ComponentManager(new File("target/test-dependencies"), "META-INF/test/dependencies", null)) { final String pluginPath = plugin.getAbsolutePath(); Thread[] th = new Thread[5]; for (int ind = 0; ind < th.length; ind++) { final int indice = ind; th[ind] = new Thread(() -> { manager.addPlugin(pluginPath); }); } for (int ind = 0; ind < th.length; ind++) { th[ind].start(); } for (int ind = 0; ind < th.length; ind++) { th[ind].join(); } } finally { DynamicContainerFinder.SERVICES.clear(); doCleanup(pluginFolder); if (jvd != null) { System.setProperty("java.version.date", jvd); } } }
public synchronized String addPlugin(final String pluginRootFile) { final Optional<Container> pl = findPlugin(pluginRootFile); if (pl.isPresent()) { return pl.get().getId(); } final String id = this.container .builder(pluginRootFile) .withCustomizer(createContainerCustomizer(pluginRootFile)) .withAdditionalClasspath(findAdditionalClasspathFor(container.buildAutoIdFromName(pluginRootFile))) .create() .getId(); info("Adding plugin: " + pluginRootFile + ", as " + id); return id; }
ComponentManager implements AutoCloseable { public synchronized String addPlugin(final String pluginRootFile) { final Optional<Container> pl = findPlugin(pluginRootFile); if (pl.isPresent()) { return pl.get().getId(); } final String id = this.container .builder(pluginRootFile) .withCustomizer(createContainerCustomizer(pluginRootFile)) .withAdditionalClasspath(findAdditionalClasspathFor(container.buildAutoIdFromName(pluginRootFile))) .create() .getId(); info("Adding plugin: " + pluginRootFile + ", as " + id); return id; } }
ComponentManager implements AutoCloseable { public synchronized String addPlugin(final String pluginRootFile) { final Optional<Container> pl = findPlugin(pluginRootFile); if (pl.isPresent()) { return pl.get().getId(); } final String id = this.container .builder(pluginRootFile) .withCustomizer(createContainerCustomizer(pluginRootFile)) .withAdditionalClasspath(findAdditionalClasspathFor(container.buildAutoIdFromName(pluginRootFile))) .create() .getId(); info("Adding plugin: " + pluginRootFile + ", as " + id); return id; } ComponentManager(final File m2);  ComponentManager(final File m2, final String dependenciesResource, final String jmxNamePattern);  ComponentManager(final Path m2);  ComponentManager(final Path m2, final String dependenciesResource, final String jmxNamePattern); }
ComponentManager implements AutoCloseable { public synchronized String addPlugin(final String pluginRootFile) { final Optional<Container> pl = findPlugin(pluginRootFile); if (pl.isPresent()) { return pl.get().getId(); } final String id = this.container .builder(pluginRootFile) .withCustomizer(createContainerCustomizer(pluginRootFile)) .withAdditionalClasspath(findAdditionalClasspathFor(container.buildAutoIdFromName(pluginRootFile))) .create() .getId(); info("Adding plugin: " + pluginRootFile + ", as " + id); return id; } ComponentManager(final File m2);  ComponentManager(final File m2, final String dependenciesResource, final String jmxNamePattern);  ComponentManager(final Path m2);  ComponentManager(final Path m2, final String dependenciesResource, final String jmxNamePattern); static ComponentManager instance(); static Path findM2(); void addCallerAsPlugin(); Stream<T> find(final Function<Container, Stream<T>> mapper); Optional<Object> createComponent(final String plugin, final String name, final ComponentType componentType,
            final int version, final Map<String, String> configuration); void autoDiscoverPlugins(final boolean callers, final boolean classpath); Optional<Mapper> findMapper(final String plugin, final String name, final int version,
            final Map<String, String> configuration); Optional<org.talend.sdk.component.runtime.output.Processor> findProcessor(final String plugin,
            final String name, final int version, final Map<String, String> configuration); boolean hasPlugin(final String plugin); Optional<Container> findPlugin(final String plugin); synchronized String addPlugin(final String pluginRootFile); String addWithLocationPlugin(final String location, final String pluginRootFile); void removePlugin(final String id); @Override void close(); List<String> availablePlugins(); }
ComponentManager implements AutoCloseable { public synchronized String addPlugin(final String pluginRootFile) { final Optional<Container> pl = findPlugin(pluginRootFile); if (pl.isPresent()) { return pl.get().getId(); } final String id = this.container .builder(pluginRootFile) .withCustomizer(createContainerCustomizer(pluginRootFile)) .withAdditionalClasspath(findAdditionalClasspathFor(container.buildAutoIdFromName(pluginRootFile))) .create() .getId(); info("Adding plugin: " + pluginRootFile + ", as " + id); return id; } ComponentManager(final File m2);  ComponentManager(final File m2, final String dependenciesResource, final String jmxNamePattern);  ComponentManager(final Path m2);  ComponentManager(final Path m2, final String dependenciesResource, final String jmxNamePattern); static ComponentManager instance(); static Path findM2(); void addCallerAsPlugin(); Stream<T> find(final Function<Container, Stream<T>> mapper); Optional<Object> createComponent(final String plugin, final String name, final ComponentType componentType,
            final int version, final Map<String, String> configuration); void autoDiscoverPlugins(final boolean callers, final boolean classpath); Optional<Mapper> findMapper(final String plugin, final String name, final int version,
            final Map<String, String> configuration); Optional<org.talend.sdk.component.runtime.output.Processor> findProcessor(final String plugin,
            final String name, final int version, final Map<String, String> configuration); boolean hasPlugin(final String plugin); Optional<Container> findPlugin(final String plugin); synchronized String addPlugin(final String pluginRootFile); String addWithLocationPlugin(final String location, final String pluginRootFile); void removePlugin(final String id); @Override void close(); List<String> availablePlugins();  }