From f692cadf02ace8808ccaa4a61e09da5b24191ae1 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 23 Oct 2025 00:32:01 +0200 Subject: [PATCH 01/41] chore(QTDI-1914): Sample dynamic schema connector. --- sample-parent/pom.xml | 3 +- .../dynamic-dependencies/pom.xml | 97 ++++++++++++ .../dynamicdependencies/config/Config.java | 43 ++++++ .../dynamicdependencies/config/Dataset.java | 69 +++++++++ .../dynamicdependencies/config/Datastore.java | 36 +++++ .../input/DynamicDependenciesInput.java | 81 ++++++++++ .../dynamicdependencies/package-info.java | 23 +++ .../service/DynamicDependenciesService.java | 144 ++++++++++++++++++ .../src/main/resources/icons/dark/icon.svg | 60 ++++++++ .../src/main/resources/icons/light/icon.svg | 60 ++++++++ .../dynamicdependencies/Messages.properties | 19 +++ .../config/Messages.properties | 30 ++++ .../input/Messages.properties | 17 +++ 13 files changed, 681 insertions(+), 1 deletion(-) create mode 100644 sample-parent/sample-features/dynamic-dependencies/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/dark/icon.svg create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/light/icon.svg create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties diff --git a/sample-parent/pom.xml b/sample-parent/pom.xml index 605c9b9796ede..21820ccab9d8a 100644 --- a/sample-parent/pom.xml +++ b/sample-parent/pom.xml @@ -33,6 +33,7 @@ documentation-sample sample-connector sample-features + sample-features/dynamic-dependencies @@ -97,4 +98,4 @@ - + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml new file mode 100644 index 0000000000000..236c1fc3797f1 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.talend.sdk.component + sample-features + 1.86.0-SNAPSHOT + + + dynamicdependencies + jar + + Component Runtime :: Sample Feature @DynamicDependency + + + + + org.talend.sdk.component + talend-component-maven-plugin + ${project.version} + + + + + talend-dependencies + + dependencies + + process-classes + + + talend-component-bundle + + car + + package + + + talend-scan-descriptor + + scan-descriptor + + + + talend-component-validate + + validate + + process-classes + + true + true + false + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java new file mode 100644 index 0000000000000..7dbbbd6cb8b7d --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +/** + * For this sample, the same configuration is used for all connectors input/processor/output. + */ +@Data +@GridLayout({ + @GridLayout.Row({ "dse" }) +}) +public class Config implements Serializable { + + @Option + @Documentation("The dataset configuration.") + private Dataset dse = new Dataset(); + + @Option + @Documentation("If enable throw an exception for any error, if not just log the error.") + private boolean dieOnError = false; + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java new file mode 100644 index 0000000000000..c0accd24d8d49 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.config; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DataSet; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@DataSet("dyndepsdse") +@GridLayout(value = { + @GridLayout.Row({ "dso" }), + @GridLayout.Row({ "dependencies" }) +}) +public class Dataset implements Serializable { + + @Option + @Documentation("A datastore.") + private Datastore dso = new Datastore(); + + @Option + @Documentation("The dependencies to load dynamically.") + private List dependencies = new ArrayList<>(); + + @Data + @GridLayout(value = { + @GridLayout.Row({ "groupId", "artifactId", "version", "clazz" }) + }) + public static class Dependency implements Serializable { + + @Option + @Documentation("The groupId of the dependency.") + private String groupId; + + @Option + @Documentation("The artifactId of the dependency.") + private String artifactId; + + @Option + @Documentation("The version of the dependency.") + private String version; + + @Option + @Documentation("The class to try to load from this dependency.") + private String clazz; + + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java new file mode 100644 index 0000000000000..d2056190a6bb5 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DataStore; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@DataStore("dyndepsdso") +@GridLayout(value = { @GridLayout.Row({ "input" }) }) +public class Datastore implements Serializable { + + @Option + @Documentation("An input string that is not used.") + private String input; + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java new file mode 100644 index 0000000000000..870a07a5208ef --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.input; + +import java.io.Serializable; +import java.util.Iterator; + +import javax.annotation.PostConstruct; + +import org.talend.sdk.component.api.component.Icon; +import org.talend.sdk.component.api.component.Version; +import org.talend.sdk.component.api.input.Emitter; +import org.talend.sdk.component.api.input.Producer; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.api.service.schema.FixedSchema; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService; + +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Version +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +@Emitter(name = "Input") +@FixedSchema(DynamicDependenciesService.FIXEDSCHEMA_ACTION) +@Documentation("Dynamic dependencies sample input connector.") +public class DynamicDependenciesInput implements Serializable { + + private final Config config; + + private final DynamicDependenciesService service; + + private Iterator recordIterator; + + public DynamicDependenciesInput(final Config config, final DynamicDependenciesService service) { + this.config = config; + this.service = service; + } + + @PostConstruct + public void init() { + this.recordIterator = this.service.loadIterator(this.config); + } + + @Producer + public Record next() { + if (recordIterator == null || !recordIterator.hasNext()) { + return null; + } + + return recordIterator.next(); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java new file mode 100644 index 0000000000000..d7b5b6f6dbc76 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java @@ -0,0 +1,23 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Components( + family = "dynamicDependencies", + categories = "sample") +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +package org.talend.sdk.component.sample.feature.dynamicdependencies; + +import org.talend.sdk.component.api.component.Components; +import org.talend.sdk.component.api.component.Icon; \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java new file mode 100644 index 0000000000000..b5bfcb76db562 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java @@ -0,0 +1,144 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.service; + +import java.io.Serializable; +import java.security.CodeSource; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.exception.ComponentException; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.api.record.Record.Builder; +import org.talend.sdk.component.api.record.Schema; +import org.talend.sdk.component.api.record.Schema.Type; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.api.service.dependency.DynamicDependencies; +import org.talend.sdk.component.api.service.record.RecordBuilderFactory; +import org.talend.sdk.component.api.service.schema.DiscoverSchema; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset.Dependency; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class DynamicDependenciesService implements Serializable { + + public static final String DEPENDENCY_ACTION = "DEPENDENCY_ACTION"; + + public static final String FIXEDSCHEMA_ACTION = "FIXEDSCHEMA_ACTION"; + + public static final String ENTRY_MAVEN = "maven"; + + public static final String ENTRY_CLASS = "clazz"; + + public static final String ENTRY_IS_LOADED = "is_loaded"; + + public static final String ENTRY_CLASSLOADER = "classloader"; + + public static final String ENTRY_FROM_LOCATION = "from_location"; + + public static final String ENTRY_IS_TCK_CONTAINER = "is_tck_container"; + + public static final String ENTRY_IS_LOADED_IN_TCK = "is_loaded_in_tck_manager"; + + @Service + private RecordBuilderFactory factory; + + public Iterator loadIterator(final Config config) { + Schema schema = buildSchema(); + + List records = new ArrayList<>(); + for (Dependency dependency : config.getDse().getDependencies()) { + Builder builder = factory.newRecordBuilder(schema); + + String maven = String.format("%s:%s:%s", dependency.getGroupId(), dependency.getArtifactId(), + dependency.getVersion()); + + boolean isLoaded = false; + String classLoaderId = "N/A"; + String fromLocation = "N/A"; + try { + Class clazz = Class.forName(dependency.getClazz()); + isLoaded = true; + classLoaderId = clazz.getClassLoader().toString(); + + CodeSource codeSource = clazz.getProtectionDomain().getCodeSource(); + if (codeSource != null) { + fromLocation = codeSource.getLocation().getPath(); + } else { + fromLocation = "CodeSource is null for this class."; + } + } catch (ClassNotFoundException e) { + manageException(config.isDieOnError(), + "Cannot load class %s from system classloader".formatted(dependency.getClazz()), e); + } + + boolean isTckContainer = false; // to improve + boolean isLoadedInTck = false; // to improve + + Record record = builder + .withString(ENTRY_MAVEN, maven) + .withString(ENTRY_CLASS, dependency.getClazz()) + .withBoolean(ENTRY_IS_LOADED, isLoaded) + .withString(ENTRY_CLASSLOADER, classLoaderId) + .withString(ENTRY_FROM_LOCATION, fromLocation) + .withBoolean(ENTRY_IS_TCK_CONTAINER, isTckContainer) + .withBoolean(ENTRY_IS_LOADED_IN_TCK, isLoadedInTck) + .build(); + records.add(record); + } + + return records.iterator(); + } + + private Schema buildSchema() { + return factory.newSchemaBuilder(Type.RECORD) + .withEntry(factory.newEntryBuilder().withName(ENTRY_MAVEN).withType(Type.STRING).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_CLASS).withType(Type.STRING).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_LOADED).withType(Type.BOOLEAN).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_CLASSLOADER).withType(Type.STRING).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_FROM_LOCATION).withType(Type.STRING).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_TCK_CONTAINER).withType(Type.BOOLEAN).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_LOADED_IN_TCK).withType(Type.BOOLEAN).build()) + .build(); + } + + private void manageException(final boolean dieOnError, final String message, final Exception e) { + String msg = "Dynamic dependencies connector raised an exception: %s : %s".formatted(message, e.getMessage()); + log.error(msg, e); + if (dieOnError) { + throw new ComponentException(msg, e); + } + } + + @DynamicDependencies(DEPENDENCY_ACTION) + public List getDynamicDependencies(@Option("configuration") final Dataset dataset) { + return dataset.getDependencies() + .stream() + .map(d -> String.format("%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion())) + .toList(); + } + + @DiscoverSchema(FIXEDSCHEMA_ACTION) + public Schema guessSchema4Input(final Dataset dse) { + return buildSchema(); + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/dark/icon.svg new file mode 100644 index 0000000000000..6e254d5c33ec9 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/dark/icon.svg @@ -0,0 +1,60 @@ + + + + + + DynamicDependencies + diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/light/icon.svg new file mode 100644 index 0000000000000..6e254d5c33ec9 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/light/icon.svg @@ -0,0 +1,60 @@ + + + + + + DynamicDependencies + diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties new file mode 100644 index 0000000000000..570dc7802755e --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties @@ -0,0 +1,19 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependencies.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies +dynamicDependencies.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies +dynamicDependencies.actions.schema.FIXEDSCHEMA_ACTION._displayName = Fixed Schema for dynamic dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties new file mode 100644 index 0000000000000..5a8b582a1eed3 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties @@ -0,0 +1,30 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +Dataset.dso._displayName = +Dataset.dependencies._displayName = +Dependency.groupId._displayName = +Dependency.artifactId._displayName = +Dependency.version._displayName = +Dependency.clazz._displayName = +Config.dse._displayName = +Config.dieOnError._displayName = +Dependency.groupId._placeholder = +Dependency.artifactId._placeholder = +Dependency.version._placeholder = +Dependency.clazz._placeholder = +Datastore.input._displayName = +Datastore.input._placeholder = \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties new file mode 100644 index 0000000000000..601aeca6c086c --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties @@ -0,0 +1,17 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependencies.Input._displayName = Dynamic Dependencies Input \ No newline at end of file From e53256c5f4ccf8f402694bd38cb498e643385306 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Thu, 23 Oct 2025 15:31:23 +0800 Subject: [PATCH 02/41] Add 2 params --- .../feature/dynamicdependencies/config/Config.java | 8 ++++++++ .../service/DynamicDependenciesService.java | 10 ++++++++++ .../dynamicdependencies/config/Messages.properties | 2 ++ 3 files changed, 20 insertions(+) diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java index 7dbbbd6cb8b7d..0bdb8be6994ab 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java @@ -40,4 +40,12 @@ public class Config implements Serializable { @Documentation("If enable throw an exception for any error, if not just log the error.") private boolean dieOnError = false; + @Option + @Documentation("The info about root repository.") + private boolean rootRepository = false; + + @Option + @Documentation("The info about Runtime classpath.") + private boolean runtimeClassPath = false; + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java index b5bfcb76db562..44d85f89864db 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java @@ -59,6 +59,10 @@ public class DynamicDependenciesService implements Serializable { public static final String ENTRY_IS_LOADED_IN_TCK = "is_loaded_in_tck_manager"; + public static final String ENTRY_ROOT_REPOSITORY = "root_repository"; + + public static final String ENTRY_RUNTIME_CLASSPATH = "runtime_classpath"; + @Service private RecordBuilderFactory factory; @@ -93,6 +97,8 @@ public Iterator loadIterator(final Config config) { boolean isTckContainer = false; // to improve boolean isLoadedInTck = false; // to improve + String rootRepository = config.isRootRepository() ? System.getProperty("talend.component.manager.m2.repository") : ""; + String runtimeClasspath = ""; Record record = builder .withString(ENTRY_MAVEN, maven) @@ -102,6 +108,8 @@ public Iterator loadIterator(final Config config) { .withString(ENTRY_FROM_LOCATION, fromLocation) .withBoolean(ENTRY_IS_TCK_CONTAINER, isTckContainer) .withBoolean(ENTRY_IS_LOADED_IN_TCK, isLoadedInTck) + .withString(ENTRY_ROOT_REPOSITORY, rootRepository) + .withString(ENTRY_RUNTIME_CLASSPATH, runtimeClasspath) .build(); records.add(record); } @@ -118,6 +126,8 @@ private Schema buildSchema() { .withEntry(factory.newEntryBuilder().withName(ENTRY_FROM_LOCATION).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_TCK_CONTAINER).withType(Type.BOOLEAN).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_LOADED_IN_TCK).withType(Type.BOOLEAN).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_ROOT_REPOSITORY).withType(Type.STRING).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_RUNTIME_CLASSPATH).withType(Type.STRING).build()) .build(); } diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties index 5a8b582a1eed3..7b8e871ca2b55 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties @@ -22,6 +22,8 @@ Dependency.version._displayName = Dependency.clazz._displayName = Config.dse._displayName = Config.dieOnError._displayName = +Config.rootRepository._displayName = +Config.runtimeClassPath._displayName = Dependency.groupId._placeholder = Dependency.artifactId._placeholder = Dependency.version._placeholder = From b4705a0366e88353b2cf9a6bd67b4329302e0078 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 23 Oct 2025 23:11:28 +0200 Subject: [PATCH 03/41] chore(QTDI-1914): remove unused option in dso, environment info management, better clazz location. --- .../dynamicdependencies/config/Config.java | 11 +-- .../dynamicdependencies/config/Datastore.java | 10 +- .../input/DynamicDependenciesInput.java | 2 - .../service/DynamicDependenciesService.java | 96 ++++++++++++------- .../dynamicdependencies/Messages.properties | 2 +- .../config/Messages.properties | 3 +- 6 files changed, 72 insertions(+), 52 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java index 0bdb8be6994ab..5bb218e825826 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java @@ -28,7 +28,8 @@ */ @Data @GridLayout({ - @GridLayout.Row({ "dse" }) + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "environmentInformation" }) }) public class Config implements Serializable { @@ -41,11 +42,7 @@ public class Config implements Serializable { private boolean dieOnError = false; @Option - @Documentation("The info about root repository.") - private boolean rootRepository = false; - - @Option - @Documentation("The info about Runtime classpath.") - private boolean runtimeClassPath = false; + @Documentation("More environment information.") + private boolean environmentInformation = false; } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java index d2056190a6bb5..21f23b347e87a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java @@ -17,20 +17,14 @@ import java.io.Serializable; -import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.configuration.type.DataStore; -import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; -import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.api.configuration.ui.layout.AutoLayout; import lombok.Data; @Data @DataStore("dyndepsdso") -@GridLayout(value = { @GridLayout.Row({ "input" }) }) +@AutoLayout public class Datastore implements Serializable { - @Option - @Documentation("An input string that is not used.") - private String input; - } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java index 870a07a5208ef..4a70da9d5d4a0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java @@ -26,7 +26,6 @@ import org.talend.sdk.component.api.input.Producer; import org.talend.sdk.component.api.meta.Documentation; import org.talend.sdk.component.api.record.Record; -import org.talend.sdk.component.api.service.schema.FixedSchema; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; import org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService; @@ -49,7 +48,6 @@ @Version @Icon(value = Icon.IconType.CUSTOM, custom = "icon") @Emitter(name = "Input") -@FixedSchema(DynamicDependenciesService.FIXEDSCHEMA_ACTION) @Documentation("Dynamic dependencies sample input connector.") public class DynamicDependenciesInput implements Serializable { diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java index 44d85f89864db..2072975a058f7 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java @@ -16,7 +16,7 @@ package org.talend.sdk.component.sample.feature.dynamicdependencies.service; import java.io.Serializable; -import java.security.CodeSource; +import java.net.URL; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -30,7 +30,7 @@ import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.api.service.dependency.DynamicDependencies; import org.talend.sdk.component.api.service.record.RecordBuilderFactory; -import org.talend.sdk.component.api.service.schema.DiscoverSchema; +import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset.Dependency; @@ -43,7 +43,7 @@ public class DynamicDependenciesService implements Serializable { public static final String DEPENDENCY_ACTION = "DEPENDENCY_ACTION"; - public static final String FIXEDSCHEMA_ACTION = "FIXEDSCHEMA_ACTION"; + public static final String DISCOVERSCHEMA_ACTION = "DISCOVERSCHEMA_ACTION"; public static final String ENTRY_MAVEN = "maven"; @@ -51,7 +51,9 @@ public class DynamicDependenciesService implements Serializable { public static final String ENTRY_IS_LOADED = "is_loaded"; - public static final String ENTRY_CLASSLOADER = "classloader"; + public static final String ENTRY_CONNECTOR_CLASSLOADER = "connector_classloader"; + + public static final String ENTRY_CLAZZ_CLASSLOADER = "clazz_classloader"; public static final String ENTRY_FROM_LOCATION = "from_location"; @@ -67,7 +69,7 @@ public class DynamicDependenciesService implements Serializable { private RecordBuilderFactory factory; public Iterator loadIterator(final Config config) { - Schema schema = buildSchema(); + Schema schema = buildSchema(config); List records = new ArrayList<>(); for (Dependency dependency : config.getDse().getDependencies()) { @@ -77,58 +79,74 @@ public Iterator loadIterator(final Config config) { dependency.getVersion()); boolean isLoaded = false; - String classLoaderId = "N/A"; + String connectorClassLoaderId = this.getClass().getClassLoader().toString(); + String clazzClassLoaderId = "N/A"; String fromLocation = "N/A"; try { Class clazz = Class.forName(dependency.getClazz()); isLoaded = true; - classLoaderId = clazz.getClassLoader().toString(); - - CodeSource codeSource = clazz.getProtectionDomain().getCodeSource(); - if (codeSource != null) { - fromLocation = codeSource.getLocation().getPath(); - } else { - fromLocation = "CodeSource is null for this class."; - } + clazzClassLoaderId = clazz.getClassLoader().toString(); + + // This way to retrieve the location works even if the jar from where clazz comes from + // is nested into another jar (uber jar scenario) + String classPath = clazz.getName().replace('.', '/') + ".class"; + URL url = clazz.getClassLoader().getResource(classPath); + fromLocation = String.valueOf(url); } catch (ClassNotFoundException e) { manageException(config.isDieOnError(), "Cannot load class %s from system classloader".formatted(dependency.getClazz()), e); } - boolean isTckContainer = false; // to improve + boolean isTckContainer = isTCKContainer(fromLocation); + // package-info@Components boolean isLoadedInTck = false; // to improve - String rootRepository = config.isRootRepository() ? System.getProperty("talend.component.manager.m2.repository") : ""; - String runtimeClasspath = ""; - Record record = builder + Builder recordBuilder = builder .withString(ENTRY_MAVEN, maven) .withString(ENTRY_CLASS, dependency.getClazz()) .withBoolean(ENTRY_IS_LOADED, isLoaded) - .withString(ENTRY_CLASSLOADER, classLoaderId) + .withString(ENTRY_CONNECTOR_CLASSLOADER, connectorClassLoaderId) + .withString(ENTRY_CLAZZ_CLASSLOADER, clazzClassLoaderId) .withString(ENTRY_FROM_LOCATION, fromLocation) .withBoolean(ENTRY_IS_TCK_CONTAINER, isTckContainer) - .withBoolean(ENTRY_IS_LOADED_IN_TCK, isLoadedInTck) - .withString(ENTRY_ROOT_REPOSITORY, rootRepository) - .withString(ENTRY_RUNTIME_CLASSPATH, runtimeClasspath) - .build(); + .withBoolean(ENTRY_IS_LOADED_IN_TCK, isLoadedInTck); + + if (config.isEnvironmentInformation()) { + String rootRepository = System.getProperty("talend.component.manager.m2.repository"); + String runtimeClasspath = System.getProperty("java.class.path"); + + recordBuilder = recordBuilder + .withString(ENTRY_ROOT_REPOSITORY, rootRepository) + .withString(ENTRY_RUNTIME_CLASSPATH, runtimeClasspath); + } + + Record record = recordBuilder.build(); records.add(record); } return records.iterator(); } - private Schema buildSchema() { - return factory.newSchemaBuilder(Type.RECORD) + private Schema buildSchema(final Config config) { + Schema.Builder builder = factory.newSchemaBuilder(Type.RECORD) .withEntry(factory.newEntryBuilder().withName(ENTRY_MAVEN).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_CLASS).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_LOADED).withType(Type.BOOLEAN).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_CLASSLOADER).withType(Type.STRING).build()) + .withEntry( + factory.newEntryBuilder().withName(ENTRY_CONNECTOR_CLASSLOADER).withType(Type.STRING).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_CLAZZ_CLASSLOADER).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_FROM_LOCATION).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_TCK_CONTAINER).withType(Type.BOOLEAN).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_LOADED_IN_TCK).withType(Type.BOOLEAN).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_ROOT_REPOSITORY).withType(Type.STRING).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_RUNTIME_CLASSPATH).withType(Type.STRING).build()) - .build(); + .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_LOADED_IN_TCK).withType(Type.BOOLEAN).build()); + + if (config.isEnvironmentInformation()) { + builder = builder + .withEntry(factory.newEntryBuilder().withName(ENTRY_ROOT_REPOSITORY).withType(Type.STRING).build()) + .withEntry( + factory.newEntryBuilder().withName(ENTRY_RUNTIME_CLASSPATH).withType(Type.STRING).build()); + } + + return builder.build(); } private void manageException(final boolean dieOnError, final String message, final Exception e) { @@ -147,8 +165,20 @@ public List getDynamicDependencies(@Option("configuration") final Datase .toList(); } - @DiscoverSchema(FIXEDSCHEMA_ACTION) - public Schema guessSchema4Input(final Dataset dse) { - return buildSchema(); + @DiscoverSchemaExtended(DISCOVERSCHEMA_ACTION) + public Schema guessSchema4Input(final @Option("configuration") Config config) { + return buildSchema(config); + } + + /** + * Return true if the given path correspond to a class that has been loaded from a jar that contains + * a TALEND-INF/dependencies.txt file. + * + * @param path The clazz location + * @return true if the given path correspond to a TCK container + */ + private boolean isTCKContainer(final String path) { + // TO DO + return false; } } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties index 570dc7802755e..80342c6c8f436 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties @@ -16,4 +16,4 @@ dynamicDependencies.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies dynamicDependencies.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies -dynamicDependencies.actions.schema.FIXEDSCHEMA_ACTION._displayName = Fixed Schema for dynamic dependencies \ No newline at end of file +dynamicDependencies.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties index 7b8e871ca2b55..aa1d1d58b4ea8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties @@ -29,4 +29,5 @@ Dependency.artifactId._placeholder = Dependency.version._placeholder = Dependency.clazz._placeholder = Datastore.input._displayName = -Datastore.input._placeholder = \ No newline at end of file +Datastore.input._placeholder = +Config.environmentInformation._displayName = \ No newline at end of file From 1a76af5be86b6b701f5cde0c1e344fa651f33ee4 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Mon, 27 Oct 2025 15:03:01 +0800 Subject: [PATCH 04/41] Add 2 connectors: dataset, datastore with tests --- sample-parent/pom.xml | 1 - .../dynamic-dependencies-common/pom.xml | 63 ++++++++++++++ .../dynamicdependencies/config/Config.java | 0 .../dynamicdependencies/config/Dataset.java | 0 .../dynamicdependencies/config/Datastore.java | 0 .../src/main/resources/icons/dark/icon.svg | 0 .../src/main/resources/icons/light/icon.svg | 0 .../dynamicdependencies/Messages.properties | 0 .../config/Messages.properties | 0 .../dynamic-dependencies-with-dataset/pom.xml | 73 +++++++++++++++++ .../input/DynamicDependenciesInput.java | 16 ---- .../dynamicdependencies/package-info.java | 0 .../service/DynamicDependenciesService.java | 2 +- .../src/main/resources/icons/dark/icon.svg | 60 ++++++++++++++ .../src/main/resources/icons/light/icon.svg | 60 ++++++++++++++ .../input/Messages.properties | 0 .../DynamicDependenciesServiceTest.java | 82 +++++++++++++++++++ .../pom.xml | 44 ++++++++++ .../src/main/resources/icons/dark/icon.svg | 60 ++++++++++++++ .../src/main/resources/icons/light/icon.svg | 60 ++++++++++++++ .../dynamic-dependencies/pom.xml | 73 ++--------------- sample-parent/sample-features/pom.xml | 1 + 22 files changed, 510 insertions(+), 85 deletions(-) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-common}/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java (100%) rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-common}/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java (100%) rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-common}/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java (100%) rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-common}/src/main/resources/icons/dark/icon.svg (100%) rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-common}/src/main/resources/icons/light/icon.svg (100%) rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-common}/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties (100%) rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-common}/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties (100%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-with-dataset}/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java (77%) rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-with-dataset}/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java (100%) rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-with-dataset}/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java (99%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/dark/icon.svg create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/light/icon.svg rename sample-parent/sample-features/dynamic-dependencies/{ => dynamic-dependencies-with-dataset}/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties (100%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/dark/icon.svg create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/light/icon.svg diff --git a/sample-parent/pom.xml b/sample-parent/pom.xml index 21820ccab9d8a..2e8a1d3813096 100644 --- a/sample-parent/pom.xml +++ b/sample-parent/pom.xml @@ -33,7 +33,6 @@ documentation-sample sample-connector sample-features - sample-features/dynamic-dependencies diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml new file mode 100644 index 0000000000000..84ed1e94c5cc5 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + org.talend.sdk.component + dynamicdependencies + 1.86.0-SNAPSHOT + + + dynamic-dependencies-common + jar + Component Runtime :: Sample Feature @DynamicDependency Common + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dynamic.dependencies.common + + + + + + org.talend.sdk.component + talend-component-maven-plugin + ${project.version} + + + + + talend-component-validate + + false + + false + + false + + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/dark/icon.svg similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/dark/icon.svg rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/dark/icon.svg diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/light/icon.svg similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/resources/icons/light/icon.svg rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/light/icon.svg diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml new file mode 100644 index 0000000000000..10aa69e38ed9b --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + org.talend.sdk.component + dynamicdependencies + 1.86.0-SNAPSHOT + + + dynamic-dependencies-with-dataset + jar + Component Runtime :: Sample Feature @DynamicDependency with Dataset + + + + org.talend.sdk.component + dynamic-dependencies-common + 1.86.0-SNAPSHOT + + + org.talend.sdk.component + component-runtime-junit + 1.86.0-SNAPSHOT + test + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dynamic.dependencies.dataset + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java similarity index 77% rename from sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java index 4a70da9d5d4a0..6bdbd5a1506cc 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java @@ -29,22 +29,6 @@ import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; import org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService; -/** - * Copyright (C) 2006-2025 Talend Inc. - www.talend.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - @Version @Icon(value = Icon.IconType.CUSTOM, custom = "icon") @Emitter(name = "Input") diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java similarity index 99% rename from sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java index 2072975a058f7..a10e01ee9833d 100644 --- a/sample-parent/sample-features/dynamic-dependencies/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java @@ -173,7 +173,7 @@ public Schema guessSchema4Input(final @Option("configuration") Config config) { /** * Return true if the given path correspond to a class that has been loaded from a jar that contains * a TALEND-INF/dependencies.txt file. - * + * * @param path The clazz location * @return true if the given path correspond to a TCK container */ diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/dark/icon.svg new file mode 100644 index 0000000000000..6e254d5c33ec9 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/dark/icon.svg @@ -0,0 +1,60 @@ + + + + + + DynamicDependencies + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/light/icon.svg new file mode 100644 index 0000000000000..6e254d5c33ec9 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/light/icon.svg @@ -0,0 +1,60 @@ + + + + + + DynamicDependencies + diff --git a/sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java new file mode 100644 index 0000000000000..79b45edb7e992 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java @@ -0,0 +1,82 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.service; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Datastore; + +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_CLASS; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_FROM_LOCATION; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_MAVEN; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_ROOT_REPOSITORY; + +@Slf4j +@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies") +public class DynamicDependenciesServiceTest { + + @Service + DynamicDependenciesService dynamicDependenciesServiceService; + + private Config config; + + @BeforeEach + void setUp() { + // Any setup required before each test can be done here + config = new Config(); + Dataset dse = new Dataset(); + Datastore dso = new Datastore(); + List depends = new ArrayList<>(); + Dataset.Dependency depend = new Dataset.Dependency(); + depend.setArtifactId("commons-numbers-primes"); + depend.setVersion("1.2"); + depend.setGroupId("org.apache.commons"); + depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); + depends.add(depend); + + dse.setDependencies(depends); + dse.setDso(dso); + config.setDse(dse); + } + + @Test + void testloadIterator(){ + final Iterator result = dynamicDependenciesServiceService.loadIterator(config); + + Assertions.assertTrue(result.hasNext()); + final Record record = result.next(); + Assertions.assertNotNull(record); + Assertions.assertEquals(" ", record.getString(ENTRY_CLASSLOADER)); + Assertions.assertEquals(" ", record.getString(ENTRY_MAVEN)); + Assertions.assertEquals(" ", record.getString(ENTRY_CLASS)); + Assertions.assertEquals(" ", record.getString(ENTRY_FROM_LOCATION)); + Assertions.assertEquals(" ", record.getString(ENTRY_ROOT_REPOSITORY)); + Assertions.assertEquals(" ", record.getString(ENTRY_RUNTIME_CLASSPATH)); + Assertions.assertFalse(result.hasNext()); + } +} diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml new file mode 100644 index 0000000000000..9d5d9524c22fa --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml @@ -0,0 +1,44 @@ + + + + 4.0.0 + + org.talend.sdk.component + dynamicdependencies + 1.86.0-SNAPSHOT + + + dynamic-dependencies-with-datastore + jar + Component Runtime :: Sample Feature @DynamicDependency with Datastore + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dynamic.dependencies.datastore + + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/dark/icon.svg new file mode 100644 index 0000000000000..6e254d5c33ec9 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/dark/icon.svg @@ -0,0 +1,60 @@ + + + + + + DynamicDependencies + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/light/icon.svg new file mode 100644 index 0000000000000..6e254d5c33ec9 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/light/icon.svg @@ -0,0 +1,60 @@ + + + + + + DynamicDependencies + diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml index 236c1fc3797f1..0abbd2b1d5ca6 100644 --- a/sample-parent/sample-features/dynamic-dependencies/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -24,74 +24,13 @@ dynamicdependencies - jar + pom Component Runtime :: Sample Feature @DynamicDependency - - - - - org.talend.sdk.component - talend-component-maven-plugin - ${project.version} - - - - - talend-dependencies - - dependencies - - process-classes - - - talend-component-bundle - - car - - package - - - talend-scan-descriptor - - scan-descriptor - - - - talend-component-validate - - validate - - process-classes - - true - true - false - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - true - - - - - - + + dynamic-dependencies-common + dynamic-dependencies-with-dataset + dynamic-dependencies-with-datastore + \ No newline at end of file diff --git a/sample-parent/sample-features/pom.xml b/sample-parent/sample-features/pom.xml index 7121838d50b26..972f99859d146 100644 --- a/sample-parent/sample-features/pom.xml +++ b/sample-parent/sample-features/pom.xml @@ -35,6 +35,7 @@ checkpoint-runner configuration-form entry-with-error + dynamic-dependencies From 8c10ae1dde2eab36f62751515aac60d8cdb664e5 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Mon, 27 Oct 2025 15:08:48 +0800 Subject: [PATCH 05/41] Add 2 connectors: dataset, datastore with tests --- .../service/DynamicDependenciesServiceTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java index 79b45edb7e992..c70b45d2945db 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java @@ -30,7 +30,6 @@ import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Datastore; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_CLASS; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_CLASSLOADER; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_FROM_LOCATION; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_MAVEN; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; @@ -71,7 +70,7 @@ void testloadIterator(){ Assertions.assertTrue(result.hasNext()); final Record record = result.next(); Assertions.assertNotNull(record); - Assertions.assertEquals(" ", record.getString(ENTRY_CLASSLOADER)); + // Assertions.assertEquals(" ", record.getString(ENTRY_CLASSLOADER)); Assertions.assertEquals(" ", record.getString(ENTRY_MAVEN)); Assertions.assertEquals(" ", record.getString(ENTRY_CLASS)); Assertions.assertEquals(" ", record.getString(ENTRY_FROM_LOCATION)); From 189ac9e83ee64589e445b998f2a3e93d0fd6566d Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Mon, 27 Oct 2025 13:12:34 +0100 Subject: [PATCH 06/41] chore(QTDI-1914): Some adjustments. --- .../dynamic-dependencies-common/pom.xml | 5 +--- .../dynamic-dependencies-with-dataset/pom.xml | 25 ++----------------- .../DynamicDependenciesServiceTest.java | 18 +++++++------ .../dynamic-dependencies/pom.xml | 13 ++++++++-- 4 files changed, 24 insertions(+), 37 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index 84ed1e94c5cc5..adb359f7664c7 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -17,7 +17,7 @@ 4.0.0 org.talend.sdk.component - dynamicdependencies + dynamic-dependencies 1.86.0-SNAPSHOT @@ -49,11 +49,8 @@ talend-component-validate false - false - false - diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index 10aa69e38ed9b..544180efc7747 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -17,7 +17,7 @@ 4.0.0 org.talend.sdk.component - dynamicdependencies + dynamic-dependencies 1.86.0-SNAPSHOT @@ -31,27 +31,6 @@ dynamic-dependencies-common 1.86.0-SNAPSHOT - - org.talend.sdk.component - component-runtime-junit - 1.86.0-SNAPSHOT - test - - @@ -63,7 +42,7 @@ - dynamic.dependencies.dataset + org.talend.sdk.component.dynamic.dependencies.withdataset diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java index c70b45d2945db..f3fad870ec787 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java @@ -15,10 +15,16 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.service; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_CLASS; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_FROM_LOCATION; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_MAVEN; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_ROOT_REPOSITORY; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import lombok.extern.slf4j.Slf4j; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,11 +35,7 @@ import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Datastore; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_CLASS; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_FROM_LOCATION; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_MAVEN; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_ROOT_REPOSITORY; +import lombok.extern.slf4j.Slf4j; @Slf4j @WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies") @@ -64,13 +66,13 @@ void setUp() { } @Test - void testloadIterator(){ + void testloadIterator() { final Iterator result = dynamicDependenciesServiceService.loadIterator(config); Assertions.assertTrue(result.hasNext()); final Record record = result.next(); Assertions.assertNotNull(record); - // Assertions.assertEquals(" ", record.getString(ENTRY_CLASSLOADER)); + // Assertions.assertEquals(" ", record.getString(ENTRY_CLASSLOADER)); Assertions.assertEquals(" ", record.getString(ENTRY_MAVEN)); Assertions.assertEquals(" ", record.getString(ENTRY_CLASS)); Assertions.assertEquals(" ", record.getString(ENTRY_FROM_LOCATION)); diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml index 0abbd2b1d5ca6..c25c4f634f7e8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -23,14 +23,23 @@ 1.86.0-SNAPSHOT - dynamicdependencies + dynamic-dependencies pom Component Runtime :: Sample Feature @DynamicDependency dynamic-dependencies-common dynamic-dependencies-with-dataset - dynamic-dependencies-with-datastore + + + + org.talend.sdk.component + component-runtime-junit + ${project.version} + test + + + \ No newline at end of file From 51c283867f1375cea650c6b124eb960e5465c2f6 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Mon, 27 Oct 2025 18:35:32 +0100 Subject: [PATCH 07/41] chore(QTDI-1914): Working unit test. --- .../dynamic-dependencies-with-dataset/pom.xml | 10 +++- .../input/DynamicDependenciesInput.java | 4 +- .../{ => withdataset}/package-info.java | 2 +- .../service/DynamicDependenciesService.java | 2 +- .../input/Messages.properties | 0 .../DynamicDependenciesServiceTest.java | 46 ++++++++++++------- 6 files changed, 42 insertions(+), 22 deletions(-) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/{ => withdataset}/input/DynamicDependenciesInput.java (96%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/{ => withdataset}/package-info.java (98%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/{ => withdataset}/service/DynamicDependenciesService.java (99%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/{ => withdataset}/input/Messages.properties (100%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/{ => withdataset}/service/DynamicDependenciesServiceTest.java (54%) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index 544180efc7747..efe520d57f7b0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -29,9 +29,15 @@ org.talend.sdk.component dynamic-dependencies-common - 1.86.0-SNAPSHOT + ${project.version} + + + + org.apache.commons + commons-numbers-primes + 1.2 + test - diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesInput.java similarity index 96% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesInput.java index 6bdbd5a1506cc..15847e1caf448 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/input/DynamicDependenciesInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesInput.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.input; +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.input; import java.io.Serializable; import java.util.Iterator; @@ -27,7 +27,7 @@ import org.talend.sdk.component.api.meta.Documentation; import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService; @Version @Icon(value = Icon.IconType.CUSTOM, custom = "icon") diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java similarity index 98% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java index d7b5b6f6dbc76..3610f69bb331a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/package-info.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java @@ -17,7 +17,7 @@ family = "dynamicDependencies", categories = "sample") @Icon(value = Icon.IconType.CUSTOM, custom = "icon") -package org.talend.sdk.component.sample.feature.dynamicdependencies; +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset; import org.talend.sdk.component.api.component.Components; import org.talend.sdk.component.api.component.Icon; \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesService.java similarity index 99% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesService.java index a10e01ee9833d..5b775e7000361 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesService.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.service; +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; import java.io.Serializable; import java.net.URL; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/input/Messages.properties rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesServiceTest.java similarity index 54% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesServiceTest.java index f3fad870ec787..10cb16c47b8b8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/DynamicDependenciesServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesServiceTest.java @@ -13,13 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.service; +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_CLASS; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_FROM_LOCATION; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_MAVEN; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_ROOT_REPOSITORY; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.DynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_CLASS; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_CLAZZ_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_CONNECTOR_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_FROM_LOCATION; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_IS_LOADED; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_MAVEN; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_ROOT_REPOSITORY; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; import java.util.ArrayList; import java.util.Iterator; @@ -38,7 +41,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j -@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies") +@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset") public class DynamicDependenciesServiceTest { @Service @@ -48,7 +51,6 @@ public class DynamicDependenciesServiceTest { @BeforeEach void setUp() { - // Any setup required before each test can be done here config = new Config(); Dataset dse = new Dataset(); Datastore dso = new Datastore(); @@ -59,25 +61,37 @@ void setUp() { depend.setGroupId("org.apache.commons"); depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); depends.add(depend); - dse.setDependencies(depends); dse.setDso(dso); config.setDse(dse); + config.setEnvironmentInformation(true); } @Test void testloadIterator() { + System.setProperty("talend.component.manager.m2.repository", "./lib/"); + final Iterator result = dynamicDependenciesServiceService.loadIterator(config); Assertions.assertTrue(result.hasNext()); final Record record = result.next(); Assertions.assertNotNull(record); - // Assertions.assertEquals(" ", record.getString(ENTRY_CLASSLOADER)); - Assertions.assertEquals(" ", record.getString(ENTRY_MAVEN)); - Assertions.assertEquals(" ", record.getString(ENTRY_CLASS)); - Assertions.assertEquals(" ", record.getString(ENTRY_FROM_LOCATION)); - Assertions.assertEquals(" ", record.getString(ENTRY_ROOT_REPOSITORY)); - Assertions.assertEquals(" ", record.getString(ENTRY_RUNTIME_CLASSPATH)); + Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); + Assertions.assertEquals( + "org.apache.commons.numbers.primes.SmallPrimes", + record.getString(ENTRY_CLASS)); + Assertions.assertTrue(record.getBoolean(ENTRY_IS_LOADED)); + Assertions.assertNotNull(record.getString(ENTRY_CONNECTOR_CLASSLOADER)); + Assertions.assertTrue(record.getString(ENTRY_CONNECTOR_CLASSLOADER).startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); + Assertions.assertNotNull(record.getString(ENTRY_CLAZZ_CLASSLOADER)); + Assertions.assertTrue(record.getString(ENTRY_CLAZZ_CLASSLOADER).startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); + Assertions.assertNotNull(record.getString(ENTRY_FROM_LOCATION)); + Assertions.assertTrue(record.getString(ENTRY_FROM_LOCATION) + .endsWith( + "org/apache/commons/commons-numbers-primes/1.2/commons-numbers-primes-1.2.jar!/org/apache/commons/numbers/primes/SmallPrimes.class")); + Assertions.assertEquals("./lib/", record.getString(ENTRY_ROOT_REPOSITORY)); + Assertions.assertNotNull(record.getString(ENTRY_RUNTIME_CLASSPATH)); + Assertions.assertTrue(record.getString(ENTRY_RUNTIME_CLASSPATH).contains("commons-numbers-primes-1.2.jar")); Assertions.assertFalse(result.hasNext()); } -} +} \ No newline at end of file From a921b04ff3dbbab0718966e56ec5f2e0460cb2c0 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Mon, 27 Oct 2025 23:03:35 +0100 Subject: [PATCH 08/41] chore(QTDI-1914): working dynamic dependencies connectors. --- .../DynamicDependenciesConfiguration.java | 34 ++++++ .../config/Dependency.java | 48 +++++++++ .../config/DynamicDependencyConfig.java | 28 +++++ .../AbstractDynamicDependenciesService.java} | 37 +++---- .../withdataset}/config/Config.java | 13 ++- .../withdataset}/config/Dataset.java | 27 +---- .../withdataset}/config/Datastore.java | 2 +- ... DynamicDependenciesWithDatasetInput.java} | 11 +- .../withdataset/package-info.java | 2 +- ...DynamicDependenciesWithDatasetService.java | 48 +++++++++ .../src/main/resources/icons/dark/icon.svg | 36 ++++--- .../src/main/resources/icons/light/icon.svg | 36 ++++--- .../withdataset/Messages.properties | 19 ++++ .../withdataset/config}/Messages.properties | 8 +- .../withdataset/input/Messages.properties | 2 +- ...icDependenciesWithDatasetServiceTest.java} | 37 ++++--- .../pom.xml | 20 +++- .../withdatastore/config/Config.java | 57 ++++++++++ .../withdatastore/config/Dataset.java | 38 +++++++ .../withdatastore/config/Datastore.java | 41 +++++++ ...DynamicDependenciesWithDatastoreInput.java | 64 +++++++++++ .../withdatastore/package-info.java | 23 ++++ ...namicDependenciesWithDatastoreService.java | 49 +++++++++ .../src/main/resources/icons/dark/icon.svg | 36 ++++--- .../src/main/resources/icons/light/icon.svg | 36 ++++--- .../withdatastore/Messages.properties | 19 ++++ .../withdatastore}/config/Messages.properties | 14 +-- .../withdatastore/input/Messages.properties | 17 +++ ...cDependenciesWithDatastoreServiceTest.java | 100 +++++++++++++++++ .../pom.xml | 58 ++++++++++ .../config/Config.java | 62 +++++++++++ .../config/Dataset.java | 38 +++++++ .../config/Datastore.java | 30 ++++++ .../config/SubConfig.java | 41 +++++++ ...DynamicDependenciesconfigurationInput.java | 64 +++++++++++ .../package-info.java | 23 ++++ ...namicDependenciesConfigurationService.java | 49 +++++++++ .../src/main/resources/icons/dark}/icon.svg | 36 ++++--- .../src/main/resources/icons/light}/icon.svg | 36 ++++--- .../Messages.properties | 19 ++++ .../config/Messages.properties | 22 ++++ .../input/Messages.properties | 17 +++ ...cDependenciesConfigurationServiceTest.java | 102 ++++++++++++++++++ .../dynamic-dependencies/pom.xml | 3 +- 44 files changed, 1316 insertions(+), 186 deletions(-) create mode 100644 component-api/src/main/java/org/talend/sdk/component/api/configuration/type/DynamicDependenciesConfiguration.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/DynamicDependencyConfig.java rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesService.java => dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java} (85%) rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies => dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset}/config/Config.java (76%) rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies => dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset}/config/Dataset.java (69%) rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies => dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset}/config/Datastore.java (97%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/{DynamicDependenciesInput.java => DynamicDependenciesWithDatasetInput.java} (83%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetService.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies => dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config}/Messages.properties (73%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/{DynamicDependenciesServiceTest.java => DynamicDependenciesWithDatasetServiceTest.java} (75%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Dataset.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Datastore.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/DynamicDependenciesWithDatastoreInput.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/package-info.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies => dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore}/config/Messages.properties (64%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Dataset.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Datastore.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/package-info.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicDependenciesConfigurationService.java rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-common/src/main/resources/icons/light => dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/icons/dark}/icon.svg (53%) rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-common/src/main/resources/icons/dark => dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/icons/light}/icon.svg (53%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest.java diff --git a/component-api/src/main/java/org/talend/sdk/component/api/configuration/type/DynamicDependenciesConfiguration.java b/component-api/src/main/java/org/talend/sdk/component/api/configuration/type/DynamicDependenciesConfiguration.java new file mode 100644 index 0000000000000..f7f01ec74d5b3 --- /dev/null +++ b/component-api/src/main/java/org/talend/sdk/component/api/configuration/type/DynamicDependenciesConfiguration.java @@ -0,0 +1,34 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.api.configuration.type; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.talend.sdk.component.api.configuration.type.meta.ConfigurationType; +import org.talend.sdk.component.api.meta.Documentation; + +@Target(TYPE) +@Retention(RUNTIME) +@ConfigurationType("dynamicDependenciesConfiguration") +@Documentation("Mark a model (complex object) as being the configuration expected to compute dynamic dependencies.") +public @interface DynamicDependenciesConfiguration { + + String value() default "default"; +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java new file mode 100644 index 0000000000000..a4c67f8826dbd --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@GridLayout(value = { + @GridLayout.Row({ "groupId", "artifactId", "version", "clazz" }) +}) +public class Dependency implements Serializable { + + @Option + @Documentation("The groupId of the dependency.") + private String groupId; + + @Option + @Documentation("The artifactId of the dependency.") + private String artifactId; + + @Option + @Documentation("The version of the dependency.") + private String version; + + @Option + @Documentation("The class to try to load from this dependency.") + private String clazz; + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/DynamicDependencyConfig.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/DynamicDependencyConfig.java new file mode 100644 index 0000000000000..b40f4d3faa9c8 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/DynamicDependencyConfig.java @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.config; + +import java.util.List; + +public interface DynamicDependencyConfig { + + List getDependencies(); + + boolean isEnvironmentInformation(); + + boolean isDieOnError(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java similarity index 85% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesService.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java index 5b775e7000361..8ba1375183cda 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; +package org.talend.sdk.component.sample.feature.dynamicdependencies.service; import java.io.Serializable; import java.net.URL; @@ -21,25 +21,20 @@ import java.util.Iterator; import java.util.List; -import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.exception.ComponentException; import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.record.Record.Builder; import org.talend.sdk.component.api.record.Schema; import org.talend.sdk.component.api.record.Schema.Type; import org.talend.sdk.component.api.service.Service; -import org.talend.sdk.component.api.service.dependency.DynamicDependencies; import org.talend.sdk.component.api.service.record.RecordBuilderFactory; -import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; import lombok.extern.slf4j.Slf4j; @Slf4j -@Service -public class DynamicDependenciesService implements Serializable { +public abstract class AbstractDynamicDependenciesService implements Serializable { public static final String DEPENDENCY_ACTION = "DEPENDENCY_ACTION"; @@ -68,11 +63,11 @@ public class DynamicDependenciesService implements Serializable { @Service private RecordBuilderFactory factory; - public Iterator loadIterator(final Config config) { - Schema schema = buildSchema(config); + public Iterator loadIterator(final DynamicDependencyConfig dynamicDependencyConfig) { + Schema schema = buildSchema(dynamicDependencyConfig); List records = new ArrayList<>(); - for (Dependency dependency : config.getDse().getDependencies()) { + for (Dependency dependency : dynamicDependencyConfig.getDependencies()) { Builder builder = factory.newRecordBuilder(schema); String maven = String.format("%s:%s:%s", dependency.getGroupId(), dependency.getArtifactId(), @@ -93,7 +88,7 @@ public Iterator loadIterator(final Config config) { URL url = clazz.getClassLoader().getResource(classPath); fromLocation = String.valueOf(url); } catch (ClassNotFoundException e) { - manageException(config.isDieOnError(), + manageException(dynamicDependencyConfig.isDieOnError(), "Cannot load class %s from system classloader".formatted(dependency.getClazz()), e); } @@ -111,7 +106,7 @@ public Iterator loadIterator(final Config config) { .withBoolean(ENTRY_IS_TCK_CONTAINER, isTckContainer) .withBoolean(ENTRY_IS_LOADED_IN_TCK, isLoadedInTck); - if (config.isEnvironmentInformation()) { + if (dynamicDependencyConfig.isEnvironmentInformation()) { String rootRepository = System.getProperty("talend.component.manager.m2.repository"); String runtimeClasspath = System.getProperty("java.class.path"); @@ -127,7 +122,7 @@ public Iterator loadIterator(final Config config) { return records.iterator(); } - private Schema buildSchema(final Config config) { + protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConfig) { Schema.Builder builder = factory.newSchemaBuilder(Type.RECORD) .withEntry(factory.newEntryBuilder().withName(ENTRY_MAVEN).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_CLASS).withType(Type.STRING).build()) @@ -139,7 +134,7 @@ private Schema buildSchema(final Config config) { .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_TCK_CONTAINER).withType(Type.BOOLEAN).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_LOADED_IN_TCK).withType(Type.BOOLEAN).build()); - if (config.isEnvironmentInformation()) { + if (dynamicDependencyConfig.isEnvironmentInformation()) { builder = builder .withEntry(factory.newEntryBuilder().withName(ENTRY_ROOT_REPOSITORY).withType(Type.STRING).build()) .withEntry( @@ -157,19 +152,13 @@ private void manageException(final boolean dieOnError, final String message, fin } } - @DynamicDependencies(DEPENDENCY_ACTION) - public List getDynamicDependencies(@Option("configuration") final Dataset dataset) { - return dataset.getDependencies() + protected List getDynamicDependencies(final List dependencies) { + return dependencies .stream() .map(d -> String.format("%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion())) .toList(); } - @DiscoverSchemaExtended(DISCOVERSCHEMA_ACTION) - public Schema guessSchema4Input(final @Option("configuration") Config config) { - return buildSchema(config); - } - /** * Return true if the given path correspond to a class that has been loaded from a jar that contains * a TALEND-INF/dependencies.txt file. diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java similarity index 76% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java index 5bb218e825826..e9070eae41898 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java @@ -13,13 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.config; +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; import lombok.Data; @@ -31,7 +35,7 @@ @GridLayout.Row({ "dse" }), @GridLayout.Row({ "environmentInformation" }) }) -public class Config implements Serializable { +public class Config implements DynamicDependencyConfig, Serializable { @Option @Documentation("The dataset configuration.") @@ -45,4 +49,9 @@ public class Config implements Serializable { @Documentation("More environment information.") private boolean environmentInformation = false; + @Override + public List getDependencies() { + return new ArrayList<>(this.getDse().getDependencies()); + } + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java similarity index 69% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java index c0accd24d8d49..dda5e9d89446c 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dataset.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.config; +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config; import java.io.Serializable; import java.util.ArrayList; @@ -23,6 +23,7 @@ import org.talend.sdk.component.api.configuration.type.DataSet; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import lombok.Data; @@ -42,28 +43,4 @@ public class Dataset implements Serializable { @Documentation("The dependencies to load dynamically.") private List dependencies = new ArrayList<>(); - @Data - @GridLayout(value = { - @GridLayout.Row({ "groupId", "artifactId", "version", "clazz" }) - }) - public static class Dependency implements Serializable { - - @Option - @Documentation("The groupId of the dependency.") - private String groupId; - - @Option - @Documentation("The artifactId of the dependency.") - private String artifactId; - - @Option - @Documentation("The version of the dependency.") - private String version; - - @Option - @Documentation("The class to try to load from this dependency.") - private String clazz; - - } - } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Datastore.java similarity index 97% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Datastore.java index 21f23b347e87a..de540902c68ff 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Datastore.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Datastore.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.config; +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config; import java.io.Serializable; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesWithDatasetInput.java similarity index 83% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesInput.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesWithDatasetInput.java index 15847e1caf448..30e4e53d5d897 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/DynamicDependenciesWithDatasetInput.java @@ -26,22 +26,23 @@ import org.talend.sdk.component.api.input.Producer; import org.talend.sdk.component.api.meta.Documentation; import org.talend.sdk.component.api.record.Record; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService; @Version @Icon(value = Icon.IconType.CUSTOM, custom = "icon") @Emitter(name = "Input") @Documentation("Dynamic dependencies sample input connector.") -public class DynamicDependenciesInput implements Serializable { +public class DynamicDependenciesWithDatasetInput implements Serializable { private final Config config; - private final DynamicDependenciesService service; + private final DynamicDependenciesWithDatasetService service; private Iterator recordIterator; - public DynamicDependenciesInput(final Config config, final DynamicDependenciesService service) { + public DynamicDependenciesWithDatasetInput(final Config config, + final DynamicDependenciesWithDatasetService service) { this.config = config; this.service = service; } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java index 3610f69bb331a..5d16d15697f92 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java @@ -14,7 +14,7 @@ * limitations under the License. */ @Components( - family = "dynamicDependencies", + family = "dynamicDependenciesWithDataset", categories = "sample") @Icon(value = Icon.IconType.CUSTOM, custom = "icon") package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetService.java new file mode 100644 index 0000000000000..aadf3fcfeb374 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetService.java @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; + +import java.io.Serializable; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.record.Schema; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.api.service.dependency.DynamicDependencies; +import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; +import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Dataset; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class DynamicDependenciesWithDatasetService extends AbstractDynamicDependenciesService implements Serializable { + + public final static String DEPENDENCY_WITHDATASET_ACTION = "DEPENDENCY_WITHDATASET_ACTION"; + + @DynamicDependencies() + public List getDynamicDependencies(@Option("theDataset") final Dataset dataset) { + return super.getDynamicDependencies(dataset.getDependencies()); + } + + @DiscoverSchemaExtended(DEPENDENCY_WITHDATASET_ACTION) + public Schema guessSchema4Input(final @Option("configuration") Config config) { + return super.buildSchema(config); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/dark/icon.svg index 6e254d5c33ec9..3e6ba66a42db8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/dark/icon.svg +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/dark/icon.svg @@ -21,8 +21,8 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="43.575455" - inkscape:cx="13.998706" - inkscape:cy="-1.4687167" + inkscape:cx="30.820103" + inkscape:cy="-1.445768" inkscape:window-width="3840" inkscape:window-height="2276" inkscape:window-x="-12" @@ -37,24 +37,30 @@ style="fill: rgb(255, 255, 255);" id="rect1" /> DynamicDynamicDependencies + style="line-height:2.94px;letter-spacing:0px;stroke-width:1.1597">DependenciesDataset diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/light/icon.svg index 6e254d5c33ec9..3e6ba66a42db8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/light/icon.svg +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/icons/light/icon.svg @@ -21,8 +21,8 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="43.575455" - inkscape:cx="13.998706" - inkscape:cy="-1.4687167" + inkscape:cx="30.820103" + inkscape:cy="-1.445768" inkscape:window-width="3840" inkscape:window-height="2276" inkscape:window-x="-12" @@ -37,24 +37,30 @@ style="fill: rgb(255, 255, 255);" id="rect1" /> DynamicDynamicDependencies + style="line-height:2.94px;letter-spacing:0px;stroke-width:1.1597">DependenciesDataset diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties new file mode 100644 index 0000000000000..f1e4d16856f4d --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties @@ -0,0 +1,19 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependenciesWithDataset.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies +dynamicDependenciesWithDataset.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies +dynamicDependenciesWithDataset.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties similarity index 73% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties index 80342c6c8f436..bd147d336d2a1 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties @@ -14,6 +14,8 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependencies.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies -dynamicDependencies.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies -dynamicDependencies.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file +Dataset.dso._displayName = +Dataset.dependencies._displayName = +Config.dse._displayName = +Config.dieOnError._displayName = +Config.environmentInformation._displayName = \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties index 601aeca6c086c..bb6d78ae9d32f 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties @@ -14,4 +14,4 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependencies.Input._displayName = Dynamic Dependencies Input \ No newline at end of file +dynamicDependenciesWithDataset.Input._displayName = Dynamic Dependencies With Dataset Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java similarity index 75% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesServiceTest.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java index 10cb16c47b8b8..7149cf1f65ced 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java @@ -15,14 +15,14 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_CLASS; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_CLAZZ_CLASSLOADER; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_CONNECTOR_CLASSLOADER; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_FROM_LOCATION; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_IS_LOADED; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_MAVEN; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_ROOT_REPOSITORY; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_CLASS; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_CLAZZ_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_CONNECTOR_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_FROM_LOCATION; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_IS_LOADED; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_MAVEN; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_ROOT_REPOSITORY; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_RUNTIME_CLASSPATH; import java.util.ArrayList; import java.util.Iterator; @@ -34,18 +34,19 @@ import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.junit5.WithComponents; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dataset; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Datastore; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Datastore; import lombok.extern.slf4j.Slf4j; @Slf4j @WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset") -public class DynamicDependenciesServiceTest { +public class DynamicDependenciesWithDatasetServiceTest { @Service - DynamicDependenciesService dynamicDependenciesServiceService; + DynamicDependenciesWithDatasetService dynamicDependenciesServiceService; private Config config; @@ -54,8 +55,8 @@ void setUp() { config = new Config(); Dataset dse = new Dataset(); Datastore dso = new Datastore(); - List depends = new ArrayList<>(); - Dataset.Dependency depend = new Dataset.Dependency(); + List depends = new ArrayList<>(); + Dependency depend = new Dependency(); depend.setArtifactId("commons-numbers-primes"); depend.setVersion("1.2"); depend.setGroupId("org.apache.commons"); @@ -82,9 +83,11 @@ void testloadIterator() { record.getString(ENTRY_CLASS)); Assertions.assertTrue(record.getBoolean(ENTRY_IS_LOADED)); Assertions.assertNotNull(record.getString(ENTRY_CONNECTOR_CLASSLOADER)); - Assertions.assertTrue(record.getString(ENTRY_CONNECTOR_CLASSLOADER).startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); + Assertions.assertTrue(record.getString(ENTRY_CONNECTOR_CLASSLOADER) + .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); Assertions.assertNotNull(record.getString(ENTRY_CLAZZ_CLASSLOADER)); - Assertions.assertTrue(record.getString(ENTRY_CLAZZ_CLASSLOADER).startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); + Assertions.assertTrue(record.getString(ENTRY_CLAZZ_CLASSLOADER) + .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); Assertions.assertNotNull(record.getString(ENTRY_FROM_LOCATION)); Assertions.assertTrue(record.getString(ENTRY_FROM_LOCATION) .endsWith( diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml index 9d5d9524c22fa..cffba101241aa 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml @@ -17,7 +17,7 @@ 4.0.0 org.talend.sdk.component - dynamicdependencies + dynamic-dependencies 1.86.0-SNAPSHOT @@ -25,6 +25,21 @@ jar Component Runtime :: Sample Feature @DynamicDependency with Datastore + + + org.talend.sdk.component + dynamic-dependencies-common + ${project.version} + + + + org.apache.commons + commons-numbers-primes + 1.2 + test + + + @@ -33,12 +48,11 @@ - dynamic.dependencies.datastore + org.talend.sdk.component.dynamic.dependencies.withdatastore - \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java new file mode 100644 index 0000000000000..fc376ed311e35 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; + +import lombok.Data; + +/** + * For this sample, the same configuration is used for all connectors input/processor/output. + */ +@Data +@GridLayout({ + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "environmentInformation" }) +}) +public class Config implements DynamicDependencyConfig, Serializable { + + @Option + @Documentation("The dataset configuration.") + private Dataset dse = new Dataset(); + + @Option + @Documentation("If enable throw an exception for any error, if not just log the error.") + private boolean dieOnError = false; + + @Option + @Documentation("More environment information.") + private boolean environmentInformation = false; + + @Override + public List getDependencies() { + return new ArrayList<>(this.getDse().getDso().getDependencies()); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Dataset.java new file mode 100644 index 0000000000000..0faac7aef808c --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Dataset.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DataSet; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@DataSet("dyndepsdse") +@GridLayout(value = { + @GridLayout.Row({ "dso" }) +}) +public class Dataset implements Serializable { + + @Option + @Documentation("A datastore.") + private Datastore dso = new Datastore(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Datastore.java new file mode 100644 index 0000000000000..dc789196d89d3 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Datastore.java @@ -0,0 +1,41 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DataStore; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; + +import lombok.Data; + +@Data +@DataStore("dyndepsdso") +@GridLayout({ + @GridLayout.Row({ "dependencies" }) +}) +public class Datastore implements Serializable { + + @Option + @Documentation("The dependencies to load dynamically.") + private List dependencies = new ArrayList<>(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/DynamicDependenciesWithDatastoreInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/DynamicDependenciesWithDatastoreInput.java new file mode 100644 index 0000000000000..09159bfbc339d --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/DynamicDependenciesWithDatastoreInput.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.input; + +import java.io.Serializable; +import java.util.Iterator; + +import javax.annotation.PostConstruct; + +import org.talend.sdk.component.api.component.Icon; +import org.talend.sdk.component.api.component.Version; +import org.talend.sdk.component.api.input.Emitter; +import org.talend.sdk.component.api.input.Producer; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService; + +@Version +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +@Emitter(name = "Input") +@Documentation("Dynamic dependencies sample input connector.") +public class DynamicDependenciesWithDatastoreInput implements Serializable { + + private final Config config; + + private final DynamicDependenciesWithDatastoreService service; + + private Iterator recordIterator; + + public DynamicDependenciesWithDatastoreInput(final Config config, + final DynamicDependenciesWithDatastoreService service) { + this.config = config; + this.service = service; + } + + @PostConstruct + public void init() { + this.recordIterator = this.service.loadIterator(this.config); + } + + @Producer + public Record next() { + if (recordIterator == null || !recordIterator.hasNext()) { + return null; + } + + return recordIterator.next(); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/package-info.java new file mode 100644 index 0000000000000..acd6d1e4fe4d8 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/package-info.java @@ -0,0 +1,23 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Components( + family = "dynamicDependenciesWithDatastore", + categories = "sample") +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore; + +import org.talend.sdk.component.api.component.Components; +import org.talend.sdk.component.api.component.Icon; \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java new file mode 100644 index 0000000000000..df1c2e6ab564a --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service; + +import java.io.Serializable; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.record.Schema; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.api.service.dependency.DynamicDependencies; +import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; +import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Datastore; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class DynamicDependenciesWithDatastoreService extends AbstractDynamicDependenciesService + implements Serializable { + + public final static String DEPENDENCY_WITHDATASTORE_ACTION = "DEPENDENCY_WITHDATASTORE_ACTION"; + + @DynamicDependencies() + public List getDynamicDependencies(@Option("theDatastore") final Datastore datastore) { + return super.getDynamicDependencies(datastore.getDependencies()); + } + + @DiscoverSchemaExtended(DISCOVERSCHEMA_ACTION) + public Schema guessSchema4Input(final @Option("configuration") Config config) { + return super.buildSchema(config); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/dark/icon.svg index 6e254d5c33ec9..750d837d60cec 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/dark/icon.svg +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/dark/icon.svg @@ -21,8 +21,8 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="43.575455" - inkscape:cx="13.998706" - inkscape:cy="-1.4687167" + inkscape:cx="30.820103" + inkscape:cy="-1.4228193" inkscape:window-width="3840" inkscape:window-height="2276" inkscape:window-x="-12" @@ -37,24 +37,30 @@ style="fill: rgb(255, 255, 255);" id="rect1" /> DynamicDynamicDependencies + style="line-height:2.94px;letter-spacing:0px;stroke-width:1.1597">DependenciesDatastore diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/light/icon.svg index 6e254d5c33ec9..750d837d60cec 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/light/icon.svg +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/icons/light/icon.svg @@ -21,8 +21,8 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="43.575455" - inkscape:cx="13.998706" - inkscape:cy="-1.4687167" + inkscape:cx="30.820103" + inkscape:cy="-1.4228193" inkscape:window-width="3840" inkscape:window-height="2276" inkscape:window-x="-12" @@ -37,24 +37,30 @@ style="fill: rgb(255, 255, 255);" id="rect1" /> DynamicDynamicDependencies + style="line-height:2.94px;letter-spacing:0px;stroke-width:1.1597">DependenciesDatastore diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties new file mode 100644 index 0000000000000..f5f3fecda82c6 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties @@ -0,0 +1,19 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependenciesWithDatastore.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies +dynamicDependenciesWithDatastore.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies +dynamicDependenciesWithDatastore.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties similarity index 64% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties index aa1d1d58b4ea8..d6aafaad395f8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties @@ -14,20 +14,8 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +Datastore.dependencies._displayName = Dataset.dso._displayName = -Dataset.dependencies._displayName = -Dependency.groupId._displayName = -Dependency.artifactId._displayName = -Dependency.version._displayName = -Dependency.clazz._displayName = Config.dse._displayName = Config.dieOnError._displayName = -Config.rootRepository._displayName = -Config.runtimeClassPath._displayName = -Dependency.groupId._placeholder = -Dependency.artifactId._placeholder = -Dependency.version._placeholder = -Dependency.clazz._placeholder = -Datastore.input._displayName = -Datastore.input._placeholder = Config.environmentInformation._displayName = \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties new file mode 100644 index 0000000000000..2f50774da5a3b --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties @@ -0,0 +1,17 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependenciesWithDatastore.Input._displayName = Dynamic Dependencies With Dataset Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java new file mode 100644 index 0000000000000..ccd72e6353b06 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java @@ -0,0 +1,100 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service; + +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_CLASS; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_CLAZZ_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_CONNECTOR_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_FROM_LOCATION; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_IS_LOADED; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_MAVEN; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_ROOT_REPOSITORY; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_RUNTIME_CLASSPATH; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Datastore; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore") +public class DynamicDependenciesWithDatastoreServiceTest { + + @Service + DynamicDependenciesWithDatastoreService dynamicDependenciesServiceService; + + private Config config; + + @BeforeEach + void setUp() { + config = new Config(); + Dataset dse = new Dataset(); + Datastore dso = new Datastore(); + List depends = new ArrayList<>(); + Dependency depend = new Dependency(); + depend.setArtifactId("commons-numbers-primes"); + depend.setVersion("1.2"); + depend.setGroupId("org.apache.commons"); + depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); + depends.add(depend); + dso.setDependencies(depends); + dse.setDso(dso); + config.setDse(dse); + config.setEnvironmentInformation(true); + } + + @Test + void testloadIterator() { + System.setProperty("talend.component.manager.m2.repository", "./lib/"); + + final Iterator result = dynamicDependenciesServiceService.loadIterator(config); + + Assertions.assertTrue(result.hasNext()); + final Record record = result.next(); + Assertions.assertNotNull(record); + Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); + Assertions.assertEquals( + "org.apache.commons.numbers.primes.SmallPrimes", + record.getString(ENTRY_CLASS)); + Assertions.assertTrue(record.getBoolean(ENTRY_IS_LOADED)); + Assertions.assertNotNull(record.getString(ENTRY_CONNECTOR_CLASSLOADER)); + Assertions.assertTrue(record.getString(ENTRY_CONNECTOR_CLASSLOADER) + .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); + Assertions.assertNotNull(record.getString(ENTRY_CLAZZ_CLASSLOADER)); + Assertions.assertTrue(record.getString(ENTRY_CLAZZ_CLASSLOADER) + .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); + Assertions.assertNotNull(record.getString(ENTRY_FROM_LOCATION)); + Assertions.assertTrue(record.getString(ENTRY_FROM_LOCATION) + .endsWith( + "org/apache/commons/commons-numbers-primes/1.2/commons-numbers-primes-1.2.jar!/org/apache/commons/numbers/primes/SmallPrimes.class")); + Assertions.assertEquals("./lib/", record.getString(ENTRY_ROOT_REPOSITORY)); + Assertions.assertNotNull(record.getString(ENTRY_RUNTIME_CLASSPATH)); + Assertions.assertTrue(record.getString(ENTRY_RUNTIME_CLASSPATH).contains("commons-numbers-primes-1.2.jar")); + Assertions.assertFalse(result.hasNext()); + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml new file mode 100644 index 0000000000000..06bc0e5bbe3c3 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.talend.sdk.component + dynamic-dependencies + 1.86.0-SNAPSHOT + + + dynamic-dependencies-with-dynamicDependenciesConfiguration + jar + Component Runtime :: Sample Feature @DynamicDependency with DynamicDependenciesConfiguration + + + + org.talend.sdk.component + dynamic-dependencies-common + ${project.version} + + + + org.apache.commons + commons-numbers-primes + 1.2 + test + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.talend.sdk.component.dynamic.dependencies.withDynamicDependenciesConfiguration + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java new file mode 100644 index 0000000000000..d9ab2e7b5f3f6 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; + +import lombok.Data; + +/** + * For this sample, the same configuration is used for all connectors input/processor/output. + */ +@Data +@GridLayout({ + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "subConfig" }), + @GridLayout.Row({ "environmentInformation" }) +}) +public class Config implements DynamicDependencyConfig, Serializable { + + @Option + @Documentation("The dataset configuration.") + private Dataset dse = new Dataset(); + + @Option + @Documentation("Sub-configuration that contains the DynamidDependenciesConfiguration.") + private SubConfig subConfig = new SubConfig(); + + @Option + @Documentation("If enable throw an exception for any error, if not just log the error.") + private boolean dieOnError = false; + + @Option + @Documentation("More environment information.") + private boolean environmentInformation = false; + + @Override + public List getDependencies() { + return new ArrayList<>(this.getSubConfig().getDependencies()); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Dataset.java new file mode 100644 index 0000000000000..3fe30c3f77fbf --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Dataset.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DataSet; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@DataSet("dyndepsdse") +@GridLayout(value = { + @GridLayout.Row({ "dso" }) +}) +public class Dataset implements Serializable { + + @Option + @Documentation("A datastore.") + private Datastore dso = new Datastore(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Datastore.java new file mode 100644 index 0000000000000..3c3dbdc92160e --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Datastore.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.type.DataStore; +import org.talend.sdk.component.api.configuration.ui.layout.AutoLayout; + +import lombok.Data; + +@Data +@DataStore("dyndepsdso") +@AutoLayout +public class Datastore implements Serializable { + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java new file mode 100644 index 0000000000000..2693e8678b6eb --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java @@ -0,0 +1,41 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DynamicDependenciesConfiguration; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; + +import lombok.Data; + +@Data +@DynamicDependenciesConfiguration +@GridLayout({ + @GridLayout.Row({ "dependencies" }) +}) +public class SubConfig implements Serializable { + + @Option + @Documentation("The dependencies to load dynamically.") + private List dependencies = new ArrayList<>(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java new file mode 100644 index 0000000000000..7e2adbf79509b --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.input; + +import java.io.Serializable; +import java.util.Iterator; + +import javax.annotation.PostConstruct; + +import org.talend.sdk.component.api.component.Icon; +import org.talend.sdk.component.api.component.Version; +import org.talend.sdk.component.api.input.Emitter; +import org.talend.sdk.component.api.input.Producer; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService; + +@Version +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +@Emitter(name = "Input") +@Documentation("Dynamic dependencies sample input connector.") +public class DynamicDependenciesWithDynamicDependenciesconfigurationInput implements Serializable { + + private final Config config; + + private final DynamicDependenciesWithDynamicDependenciesConfigurationService service; + + private Iterator recordIterator; + + public DynamicDependenciesWithDynamicDependenciesconfigurationInput(final Config config, + final DynamicDependenciesWithDynamicDependenciesConfigurationService service) { + this.config = config; + this.service = service; + } + + @PostConstruct + public void init() { + this.recordIterator = this.service.loadIterator(this.config); + } + + @Producer + public Record next() { + if (recordIterator == null || !recordIterator.hasNext()) { + return null; + } + + return recordIterator.next(); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/package-info.java new file mode 100644 index 0000000000000..c484957886382 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/package-info.java @@ -0,0 +1,23 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Components( + family = "dynamicDependenciesWithDynamicDependenciesConfiguration", + categories = "sample") +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration; + +import org.talend.sdk.component.api.component.Components; +import org.talend.sdk.component.api.component.Icon; \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicDependenciesConfigurationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicDependenciesConfigurationService.java new file mode 100644 index 0000000000000..a20ea5e99987a --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicDependenciesConfigurationService.java @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service; + +import java.io.Serializable; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.record.Schema; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.api.service.dependency.DynamicDependencies; +import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; +import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.SubConfig; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class DynamicDependenciesWithDynamicDependenciesConfigurationService extends AbstractDynamicDependenciesService + implements Serializable { + + public final static String DEPENDENCY_WITHDATASET_ACTION = "DEPENDENCY_WITHDATASET_ACTION"; + + @DynamicDependencies() + public List getDynamicDependencies(@Option("theSubConfig") final SubConfig subConfig) { + return super.getDynamicDependencies(subConfig.getDependencies()); + } + + @DiscoverSchemaExtended(DISCOVERSCHEMA_ACTION) + public Schema guessSchema4Input(final @Option("configuration") Config config) { + return super.buildSchema(config); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/icons/dark/icon.svg similarity index 53% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/light/icon.svg rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/icons/dark/icon.svg index 6e254d5c33ec9..75edf24718ba0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/light/icon.svg +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/icons/dark/icon.svg @@ -21,8 +21,8 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="43.575455" - inkscape:cx="13.998706" - inkscape:cy="-1.4687167" + inkscape:cx="30.820103" + inkscape:cy="-1.4228193" inkscape:window-width="3840" inkscape:window-height="2276" inkscape:window-x="-12" @@ -37,24 +37,30 @@ style="fill: rgb(255, 255, 255);" id="rect1" /> DynamicDynamicDependencies + style="line-height:2.94px;letter-spacing:0px;stroke-width:1.1597">DependenciesDynDepConf diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/icons/light/icon.svg similarity index 53% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/dark/icon.svg rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/icons/light/icon.svg index 6e254d5c33ec9..75edf24718ba0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/resources/icons/dark/icon.svg +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/icons/light/icon.svg @@ -21,8 +21,8 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:zoom="43.575455" - inkscape:cx="13.998706" - inkscape:cy="-1.4687167" + inkscape:cx="30.820103" + inkscape:cy="-1.4228193" inkscape:window-width="3840" inkscape:window-height="2276" inkscape:window-x="-12" @@ -37,24 +37,30 @@ style="fill: rgb(255, 255, 255);" id="rect1" /> DynamicDynamicDependencies + style="line-height:2.94px;letter-spacing:0px;stroke-width:1.1597">DependenciesDynDepConf diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties new file mode 100644 index 0000000000000..8be235fe23afa --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties @@ -0,0 +1,19 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependenciesWithDynamicDependenciesConfiguration.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies +dynamicDependenciesWithDynamicDependenciesConfiguration.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies +dynamicDependenciesWithDynamicDependenciesConfiguration.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties new file mode 100644 index 0000000000000..725f8dab189c0 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties @@ -0,0 +1,22 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +Dataset.dso._displayName = +Config.dse._displayName = +Config.dieOnError._displayName = +Config.environmentInformation._displayName = +Config.subConfig._displayName = +SubConfig.dependencies._displayName = \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/Messages.properties new file mode 100644 index 0000000000000..52816b8cb1df6 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/Messages.properties @@ -0,0 +1,17 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependenciesWithDynamicDependenciesConfiguration.Input._displayName = Dynamic Dependencies With DynamicDependenciesConfiguration Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest.java new file mode 100644 index 0000000000000..019870330e62b --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest.java @@ -0,0 +1,102 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; + +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_CLASS; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_CLAZZ_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_CONNECTOR_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_FROM_LOCATION; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_IS_LOADED; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_MAVEN; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_ROOT_REPOSITORY; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_RUNTIME_CLASSPATH; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Datastore; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@WithComponents( + value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration") +public class DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest { + + @Service + DynamicDependenciesWithDynamicDependenciesConfigurationService dynamicDependenciesServiceService; + + private Config config; + + @BeforeEach + void setUp() { + config = new Config(); + Dataset dse = new Dataset(); + Datastore dso = new Datastore(); + List depends = new ArrayList<>(); + Dependency depend = new Dependency(); + depend.setArtifactId("commons-numbers-primes"); + depend.setVersion("1.2"); + depend.setGroupId("org.apache.commons"); + depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); + depends.add(depend); + dse.setDso(dso); + config.setDse(dse); + config.setEnvironmentInformation(true); + config.getSubConfig().setDependencies(depends); + } + + @Test + void testloadIterator() { + System.setProperty("talend.component.manager.m2.repository", "./lib/"); + + final Iterator result = dynamicDependenciesServiceService.loadIterator(config); + + Assertions.assertTrue(result.hasNext()); + final Record record = result.next(); + Assertions.assertNotNull(record); + Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); + Assertions.assertEquals( + "org.apache.commons.numbers.primes.SmallPrimes", + record.getString(ENTRY_CLASS)); + Assertions.assertTrue(record.getBoolean(ENTRY_IS_LOADED)); + Assertions.assertNotNull(record.getString(ENTRY_CONNECTOR_CLASSLOADER)); + Assertions.assertTrue(record.getString(ENTRY_CONNECTOR_CLASSLOADER) + .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); + Assertions.assertNotNull(record.getString(ENTRY_CLAZZ_CLASSLOADER)); + Assertions.assertTrue(record.getString(ENTRY_CLAZZ_CLASSLOADER) + .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); + Assertions.assertNotNull(record.getString(ENTRY_FROM_LOCATION)); + Assertions.assertTrue(record.getString(ENTRY_FROM_LOCATION) + .endsWith( + "org/apache/commons/commons-numbers-primes/1.2/commons-numbers-primes-1.2.jar!/org/apache/commons/numbers/primes/SmallPrimes.class")); + Assertions.assertEquals("./lib/", record.getString(ENTRY_ROOT_REPOSITORY)); + Assertions.assertNotNull(record.getString(ENTRY_RUNTIME_CLASSPATH)); + Assertions.assertTrue(record.getString(ENTRY_RUNTIME_CLASSPATH).contains("commons-numbers-primes-1.2.jar")); + Assertions.assertFalse(result.hasNext()); + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml index c25c4f634f7e8..1b2db4b3ca819 100644 --- a/sample-parent/sample-features/dynamic-dependencies/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -30,7 +30,8 @@ dynamic-dependencies-common dynamic-dependencies-with-dataset - + dynamic-dependencies-with-datastore + dynamic-dependencies-with-dynamicDependenciesConfiguration From 54714b77e57fc91ab5755c0608e14ea8962151b0 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Tue, 28 Oct 2025 16:03:40 +0800 Subject: [PATCH 09/41] fix labels --- .../dynamicdependencies/withdataset/Messages.properties | 4 ++-- .../dynamicdependencies/withdatastore/Messages.properties | 4 ++-- .../withdatastore/input/Messages.properties | 2 +- .../withDynamicDependenciesConfiguration/Messages.properties | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties index f1e4d16856f4d..ec724be2ad89d 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties @@ -14,6 +14,6 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDataset.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies -dynamicDependenciesWithDataset.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies +dynamicDependenciesWithDataset.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with dataset +dynamicDependenciesWithDataset.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with dataset dynamicDependenciesWithDataset.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties index f5f3fecda82c6..845043aa04e82 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties @@ -14,6 +14,6 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDatastore.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies -dynamicDependenciesWithDatastore.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies +dynamicDependenciesWithDatastore.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with datastore +dynamicDependenciesWithDatastore.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with datastore dynamicDependenciesWithDatastore.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties index 2f50774da5a3b..5a92305e1efb7 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties @@ -14,4 +14,4 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDatastore.Input._displayName = Dynamic Dependencies With Dataset Input \ No newline at end of file +dynamicDependenciesWithDatastore.Input._displayName = Dynamic Dependencies With Datastore Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties index 8be235fe23afa..8c2575448881a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties @@ -14,6 +14,6 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDynamicDependenciesConfiguration.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies -dynamicDependenciesWithDynamicDependenciesConfiguration.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies +dynamicDependenciesWithDynamicDependenciesConfiguration.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies With DynamicDependenciesConfiguration +dynamicDependenciesWithDynamicDependenciesConfiguration.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies With DynamicDependenciesConfiguration dynamicDependenciesWithDynamicDependenciesConfiguration.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file From d52d6eb6abf018d958174aafe03dd07bca896a51 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Tue, 28 Oct 2025 18:26:00 +0100 Subject: [PATCH 10/41] chore(QTDI-1914): fix artifact group id for dependency. --- .../dynamic-dependencies-common/pom.xml | 8 +++++--- .../dynamic-dependencies-with-dataset/pom.xml | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index adb359f7664c7..daf4a3b6dab30 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -13,7 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 org.talend.sdk.component @@ -21,6 +22,9 @@ 1.86.0-SNAPSHOT + + + org.talend.sdk.sample dynamic-dependencies-common jar Component Runtime :: Sample Feature @DynamicDependency Common @@ -44,8 +48,6 @@ ${project.version} - - talend-component-validate false diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index efe520d57f7b0..3518900d1f278 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -25,9 +25,14 @@ jar Component Runtime :: Sample Feature @DynamicDependency with Dataset + + org.talend.sdk.component:dynamic-dependencies-common + include-exclude + + - org.talend.sdk.component + org.talend.sdk.sample dynamic-dependencies-common ${project.version} From e55a7a4dee1c5616babd721539d571d3084a7df2 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Wed, 29 Oct 2025 15:25:09 +0800 Subject: [PATCH 11/41] refactor junits --- .../dynamic-dependencies-common/pom.xml | 41 +++++++ .../dynamicdependencies/TestUtils.java} | 63 +++-------- .../dynamic-dependencies-with-dataset/pom.xml | 9 ++ .../service/DatasetServiceTest.java | 67 ++++++++++++ .../pom.xml | 15 +++ .../service/DatastoreServiceTest.java | 67 ++++++++++++ ...cDependenciesWithDatastoreServiceTest.java | 100 ----------------- .../pom.xml | 15 +++ ...DynamicDependenciesconfigurationInput.java | 6 +- ...amicDependenciesConfigurationService.java} | 2 +- ...cDependenciesConfigurationServiceTest.java | 102 ------------------ 11 files changed, 232 insertions(+), 255 deletions(-) rename sample-parent/sample-features/dynamic-dependencies/{dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java => dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java} (59%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java delete mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/{DynamicDependenciesWithDynamicDependenciesConfigurationService.java => DynamicDependenciesConfigurationService.java} (94%) delete mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest.java diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index daf4a3b6dab30..08b4e41b60f44 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -29,6 +29,33 @@ jar Component Runtime :: Sample Feature @DynamicDependency Common + + + org.testcontainers + junit-jupiter + 1.21.3 + test + + + org.junit.jupiter + junit-jupiter + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.platform + junit-platform-commons + + + junit + junit + + + + + @@ -57,6 +84,20 @@ + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + + + test-jar + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java similarity index 59% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java index 7149cf1f65ced..4e75fe5270480 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java @@ -13,48 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; - -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_CLASS; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_CLAZZ_CLASSLOADER; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_CONNECTOR_CLASSLOADER; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_FROM_LOCATION; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_IS_LOADED; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_MAVEN; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_ROOT_REPOSITORY; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service.DynamicDependenciesWithDatasetService.ENTRY_RUNTIME_CLASSPATH; +package org.talend.sdk.component.sample.feature.dynamicdependencies; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; - import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.talend.sdk.component.api.record.Record; -import org.talend.sdk.component.api.service.Service; -import org.talend.sdk.component.junit5.WithComponents; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Dataset; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Datastore; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset") -public class DynamicDependenciesWithDatasetServiceTest { +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_CLASS; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_CLAZZ_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_CONNECTOR_CLASSLOADER; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_FROM_LOCATION; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_IS_LOADED; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_MAVEN; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_ROOT_REPOSITORY; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; - @Service - DynamicDependenciesWithDatasetService dynamicDependenciesServiceService; - - private Config config; - - @BeforeEach - void setUp() { - config = new Config(); - Dataset dse = new Dataset(); - Datastore dso = new Datastore(); +public class TestUtils { + public static List getDependList() { List depends = new ArrayList<>(); Dependency depend = new Dependency(); depend.setArtifactId("commons-numbers-primes"); @@ -62,20 +38,10 @@ void setUp() { depend.setGroupId("org.apache.commons"); depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); depends.add(depend); - dse.setDependencies(depends); - dse.setDso(dso); - config.setDse(dse); - config.setEnvironmentInformation(true); + return depends; } - @Test - void testloadIterator() { - System.setProperty("talend.component.manager.m2.repository", "./lib/"); - - final Iterator result = dynamicDependenciesServiceService.loadIterator(config); - - Assertions.assertTrue(result.hasNext()); - final Record record = result.next(); + public static void assertRecord(Record record) { Assertions.assertNotNull(record); Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); Assertions.assertEquals( @@ -95,6 +61,5 @@ void testloadIterator() { Assertions.assertEquals("./lib/", record.getString(ENTRY_ROOT_REPOSITORY)); Assertions.assertNotNull(record.getString(ENTRY_RUNTIME_CLASSPATH)); Assertions.assertTrue(record.getString(ENTRY_RUNTIME_CLASSPATH).contains("commons-numbers-primes-1.2.jar")); - Assertions.assertFalse(result.hasNext()); } -} \ No newline at end of file +} diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index 3518900d1f278..da809ae3460dd 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -36,6 +36,15 @@ dynamic-dependencies-common ${project.version} + + + org.talend.sdk.sample + dynamic-dependencies-common + ${project.version} + tests + test-jar + test + org.apache.commons diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java new file mode 100644 index 0000000000000..5b7d5329ec524 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.TestUtils; + +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Datastore; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset") +public class DatasetServiceTest { + + @Service + DynamicDependenciesWithDatasetService dynamicDependenciesServiceService; + + private Config config; + + @BeforeEach + void setUp() { + config = new Config(); + Dataset dse = new Dataset(); + Datastore dso = new Datastore(); + List depends = TestUtils.getDependList(); + dse.setDependencies(depends); + dse.setDso(dso); + config.setDse(dse); + config.setEnvironmentInformation(true); + } + + @Test + void testloadIterator() { + System.setProperty("talend.component.manager.m2.repository", "./lib/"); + + final Iterator result = dynamicDependenciesServiceService.loadIterator(config); + + Assertions.assertTrue(result.hasNext()); + TestUtils.assertRecord(result.next()); + Assertions.assertFalse(result.hasNext()); + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml index cffba101241aa..71fbf18f3f7ca 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml @@ -31,6 +31,15 @@ dynamic-dependencies-common ${project.version} + + + org.talend.sdk.sample + dynamic-dependencies-common + ${project.version} + tests + test-jar + test + org.apache.commons @@ -38,6 +47,12 @@ 1.2 test + + org.talend.sdk.sample + dynamic-dependencies-common + 1.86.0-SNAPSHOT + test + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java new file mode 100644 index 0000000000000..0ef5583a370a6 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java @@ -0,0 +1,67 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.TestUtils; + +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Datastore; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore") +public class DatastoreServiceTest { + + @Service + DynamicDependenciesWithDatastoreService dynamicDependenciesServiceService; + + private Config config; + + @BeforeEach + void setUp() { + config = new Config(); + Dataset dse = new Dataset(); + Datastore dso = new Datastore(); + List depends = TestUtils.getDependList(); + dso.setDependencies(depends); + dse.setDso(dso); + config.setDse(dse); + config.setEnvironmentInformation(true); + } + + @Test + void testloadIterator() { + System.setProperty("talend.component.manager.m2.repository", "./lib/"); + + final Iterator result = dynamicDependenciesServiceService.loadIterator(config); + + Assertions.assertTrue(result.hasNext()); + TestUtils.assertRecord(result.next()); + Assertions.assertFalse(result.hasNext()); + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java deleted file mode 100644 index ccd72e6353b06..0000000000000 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (C) 2006-2025 Talend Inc. - www.talend.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service; - -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_CLASS; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_CLAZZ_CLASSLOADER; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_CONNECTOR_CLASSLOADER; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_FROM_LOCATION; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_IS_LOADED; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_MAVEN; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_ROOT_REPOSITORY; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service.DynamicDependenciesWithDatastoreService.ENTRY_RUNTIME_CLASSPATH; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.talend.sdk.component.api.record.Record; -import org.talend.sdk.component.api.service.Service; -import org.talend.sdk.component.junit5.WithComponents; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Dataset; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Datastore; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore") -public class DynamicDependenciesWithDatastoreServiceTest { - - @Service - DynamicDependenciesWithDatastoreService dynamicDependenciesServiceService; - - private Config config; - - @BeforeEach - void setUp() { - config = new Config(); - Dataset dse = new Dataset(); - Datastore dso = new Datastore(); - List depends = new ArrayList<>(); - Dependency depend = new Dependency(); - depend.setArtifactId("commons-numbers-primes"); - depend.setVersion("1.2"); - depend.setGroupId("org.apache.commons"); - depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); - depends.add(depend); - dso.setDependencies(depends); - dse.setDso(dso); - config.setDse(dse); - config.setEnvironmentInformation(true); - } - - @Test - void testloadIterator() { - System.setProperty("talend.component.manager.m2.repository", "./lib/"); - - final Iterator result = dynamicDependenciesServiceService.loadIterator(config); - - Assertions.assertTrue(result.hasNext()); - final Record record = result.next(); - Assertions.assertNotNull(record); - Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); - Assertions.assertEquals( - "org.apache.commons.numbers.primes.SmallPrimes", - record.getString(ENTRY_CLASS)); - Assertions.assertTrue(record.getBoolean(ENTRY_IS_LOADED)); - Assertions.assertNotNull(record.getString(ENTRY_CONNECTOR_CLASSLOADER)); - Assertions.assertTrue(record.getString(ENTRY_CONNECTOR_CLASSLOADER) - .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); - Assertions.assertNotNull(record.getString(ENTRY_CLAZZ_CLASSLOADER)); - Assertions.assertTrue(record.getString(ENTRY_CLAZZ_CLASSLOADER) - .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); - Assertions.assertNotNull(record.getString(ENTRY_FROM_LOCATION)); - Assertions.assertTrue(record.getString(ENTRY_FROM_LOCATION) - .endsWith( - "org/apache/commons/commons-numbers-primes/1.2/commons-numbers-primes-1.2.jar!/org/apache/commons/numbers/primes/SmallPrimes.class")); - Assertions.assertEquals("./lib/", record.getString(ENTRY_ROOT_REPOSITORY)); - Assertions.assertNotNull(record.getString(ENTRY_RUNTIME_CLASSPATH)); - Assertions.assertTrue(record.getString(ENTRY_RUNTIME_CLASSPATH).contains("commons-numbers-primes-1.2.jar")); - Assertions.assertFalse(result.hasNext()); - } -} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml index 06bc0e5bbe3c3..24ae599094379 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml @@ -31,6 +31,15 @@ dynamic-dependencies-common ${project.version} + + + org.talend.sdk.sample + dynamic-dependencies-common + ${project.version} + tests + test-jar + test + org.apache.commons @@ -38,6 +47,12 @@ 1.2 test + + org.talend.sdk.sample + dynamic-dependencies-common + 1.86.0-SNAPSHOT + test + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java index 7e2adbf79509b..c4c0afade7f00 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java @@ -27,7 +27,7 @@ import org.talend.sdk.component.api.meta.Documentation; import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesConfigurationService; @Version @Icon(value = Icon.IconType.CUSTOM, custom = "icon") @@ -37,12 +37,12 @@ public class DynamicDependenciesWithDynamicDependenciesconfigurationInput implem private final Config config; - private final DynamicDependenciesWithDynamicDependenciesConfigurationService service; + private final DynamicDependenciesConfigurationService service; private Iterator recordIterator; public DynamicDependenciesWithDynamicDependenciesconfigurationInput(final Config config, - final DynamicDependenciesWithDynamicDependenciesConfigurationService service) { + final DynamicDependenciesConfigurationService service) { this.config = config; this.service = service; } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicDependenciesConfigurationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java similarity index 94% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicDependenciesConfigurationService.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java index a20ea5e99987a..c584b7eb124a5 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicDependenciesConfigurationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java @@ -31,7 +31,7 @@ @Slf4j @Service -public class DynamicDependenciesWithDynamicDependenciesConfigurationService extends AbstractDynamicDependenciesService +public class DynamicDependenciesConfigurationService extends AbstractDynamicDependenciesService implements Serializable { public final static String DEPENDENCY_WITHDATASET_ACTION = "DEPENDENCY_WITHDATASET_ACTION"; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest.java deleted file mode 100644 index 019870330e62b..0000000000000 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (C) 2006-2025 Talend Inc. - www.talend.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; - -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_CLASS; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_CLAZZ_CLASSLOADER; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_CONNECTOR_CLASSLOADER; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_FROM_LOCATION; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_IS_LOADED; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_MAVEN; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_ROOT_REPOSITORY; -import static org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService.ENTRY_RUNTIME_CLASSPATH; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.talend.sdk.component.api.record.Record; -import org.talend.sdk.component.api.service.Service; -import org.talend.sdk.component.junit5.WithComponents; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Dataset; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Datastore; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicDependenciesConfigurationService; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@WithComponents( - value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration") -public class DynamicDependenciesWithDynamicDependenciesConfigurationServiceTest { - - @Service - DynamicDependenciesWithDynamicDependenciesConfigurationService dynamicDependenciesServiceService; - - private Config config; - - @BeforeEach - void setUp() { - config = new Config(); - Dataset dse = new Dataset(); - Datastore dso = new Datastore(); - List depends = new ArrayList<>(); - Dependency depend = new Dependency(); - depend.setArtifactId("commons-numbers-primes"); - depend.setVersion("1.2"); - depend.setGroupId("org.apache.commons"); - depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); - depends.add(depend); - dse.setDso(dso); - config.setDse(dse); - config.setEnvironmentInformation(true); - config.getSubConfig().setDependencies(depends); - } - - @Test - void testloadIterator() { - System.setProperty("talend.component.manager.m2.repository", "./lib/"); - - final Iterator result = dynamicDependenciesServiceService.loadIterator(config); - - Assertions.assertTrue(result.hasNext()); - final Record record = result.next(); - Assertions.assertNotNull(record); - Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); - Assertions.assertEquals( - "org.apache.commons.numbers.primes.SmallPrimes", - record.getString(ENTRY_CLASS)); - Assertions.assertTrue(record.getBoolean(ENTRY_IS_LOADED)); - Assertions.assertNotNull(record.getString(ENTRY_CONNECTOR_CLASSLOADER)); - Assertions.assertTrue(record.getString(ENTRY_CONNECTOR_CLASSLOADER) - .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); - Assertions.assertNotNull(record.getString(ENTRY_CLAZZ_CLASSLOADER)); - Assertions.assertTrue(record.getString(ENTRY_CLAZZ_CLASSLOADER) - .startsWith("jdk.internal.loader.ClassLoaders$AppClassLoader")); - Assertions.assertNotNull(record.getString(ENTRY_FROM_LOCATION)); - Assertions.assertTrue(record.getString(ENTRY_FROM_LOCATION) - .endsWith( - "org/apache/commons/commons-numbers-primes/1.2/commons-numbers-primes-1.2.jar!/org/apache/commons/numbers/primes/SmallPrimes.class")); - Assertions.assertEquals("./lib/", record.getString(ENTRY_ROOT_REPOSITORY)); - Assertions.assertNotNull(record.getString(ENTRY_RUNTIME_CLASSPATH)); - Assertions.assertTrue(record.getString(ENTRY_RUNTIME_CLASSPATH).contains("commons-numbers-primes-1.2.jar")); - Assertions.assertFalse(result.hasNext()); - } -} \ No newline at end of file From 0c8e974da7205274eb5f07e8bc2a06a43a41300b Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Wed, 29 Oct 2025 16:22:07 +0800 Subject: [PATCH 12/41] add working directory in output --- .../service/AbstractDynamicDependenciesService.java | 10 +++++++--- .../sample/feature/dynamicdependencies/TestUtils.java | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java index 8ba1375183cda..28d492ae60ac4 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java @@ -60,6 +60,8 @@ public abstract class AbstractDynamicDependenciesService implements Serializable public static final String ENTRY_RUNTIME_CLASSPATH = "runtime_classpath"; + public static final String ENTRY_WORKING_DIRECTORY = "Working_directory"; + @Service private RecordBuilderFactory factory; @@ -109,10 +111,12 @@ public Iterator loadIterator(final DynamicDependencyConfig dynamicDepend if (dynamicDependencyConfig.isEnvironmentInformation()) { String rootRepository = System.getProperty("talend.component.manager.m2.repository"); String runtimeClasspath = System.getProperty("java.class.path"); + String workDirectory = System.getProperty("user.dir"); recordBuilder = recordBuilder .withString(ENTRY_ROOT_REPOSITORY, rootRepository) - .withString(ENTRY_RUNTIME_CLASSPATH, runtimeClasspath); + .withString(ENTRY_RUNTIME_CLASSPATH, runtimeClasspath) + .withString(ENTRY_WORKING_DIRECTORY, workDirectory); } Record record = recordBuilder.build(); @@ -137,8 +141,8 @@ protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConf if (dynamicDependencyConfig.isEnvironmentInformation()) { builder = builder .withEntry(factory.newEntryBuilder().withName(ENTRY_ROOT_REPOSITORY).withType(Type.STRING).build()) - .withEntry( - factory.newEntryBuilder().withName(ENTRY_RUNTIME_CLASSPATH).withType(Type.STRING).build()); + .withEntry(factory.newEntryBuilder().withName(ENTRY_RUNTIME_CLASSPATH).withType(Type.STRING).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_WORKING_DIRECTORY).withType(Type.STRING).build()); } return builder.build(); diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java index 4e75fe5270480..51981dde355d3 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java @@ -28,6 +28,7 @@ import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_MAVEN; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_ROOT_REPOSITORY; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; +import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_WORKING_DIRECTORY; public class TestUtils { public static List getDependList() { @@ -60,6 +61,7 @@ public static void assertRecord(Record record) { "org/apache/commons/commons-numbers-primes/1.2/commons-numbers-primes-1.2.jar!/org/apache/commons/numbers/primes/SmallPrimes.class")); Assertions.assertEquals("./lib/", record.getString(ENTRY_ROOT_REPOSITORY)); Assertions.assertNotNull(record.getString(ENTRY_RUNTIME_CLASSPATH)); + Assertions.assertNotNull(record.getString(ENTRY_WORKING_DIRECTORY)); Assertions.assertTrue(record.getString(ENTRY_RUNTIME_CLASSPATH).contains("commons-numbers-primes-1.2.jar")); } } From 3b18693c83730e31104cf14a53a496c262d6f814 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Wed, 29 Oct 2025 18:12:03 +0100 Subject: [PATCH 13/41] chore(QTDI-1914): Improve and unit test and fix labels. --- .../dynamic-dependencies-common/pom.xml | 7 +++ .../AbstractDynamicDependenciesService.java | 8 +-- ...stractDynamicDependenciesServiceTest.java} | 50 ++++++++++++---- .../dynamic-dependencies-with-dataset/pom.xml | 1 - .../withdataset/Messages.properties | 3 +- .../withdataset/config/Messages.properties | 10 ++-- .../withdataset/input/Messages.properties | 2 +- .../service/DatasetServiceTest.java | 37 +++++------- .../pom.xml | 15 ++--- ...namicDependenciesWithDatastoreService.java | 2 +- .../withdatastore/Messages.properties | 3 +- .../withdatastore/config/Messages.properties | 10 ++-- .../withdatastore/input/Messages.properties | 2 +- .../service/DatastoreServiceTest.java | 35 ++++------- .../pom.xml | 14 ++--- ...DynamicDependenciesconfigurationInput.java | 4 +- ...namicDependenciesConfigurationService.java | 2 +- .../config/Messages.properties | 10 ++-- ...cDependenciesConfigurationServiceTest.java | 58 +++++++++++++++++++ .../dynamic-dependencies/pom.xml | 6 ++ 20 files changed, 175 insertions(+), 104 deletions(-) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/{TestUtils.java => AbstractDynamicDependenciesServiceTest.java} (76%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationServiceTest.java diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index 08b4e41b60f44..4ce71b766be23 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -68,6 +68,13 @@ + + + + test-jar + + + org.talend.sdk.component diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java index 28d492ae60ac4..0d8e73213a669 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java @@ -36,8 +36,6 @@ @Slf4j public abstract class AbstractDynamicDependenciesService implements Serializable { - public static final String DEPENDENCY_ACTION = "DEPENDENCY_ACTION"; - public static final String DISCOVERSCHEMA_ACTION = "DISCOVERSCHEMA_ACTION"; public static final String ENTRY_MAVEN = "maven"; @@ -141,8 +139,10 @@ protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConf if (dynamicDependencyConfig.isEnvironmentInformation()) { builder = builder .withEntry(factory.newEntryBuilder().withName(ENTRY_ROOT_REPOSITORY).withType(Type.STRING).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_RUNTIME_CLASSPATH).withType(Type.STRING).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_WORKING_DIRECTORY).withType(Type.STRING).build()); + .withEntry( + factory.newEntryBuilder().withName(ENTRY_RUNTIME_CLASSPATH).withType(Type.STRING).build()) + .withEntry( + factory.newEntryBuilder().withName(ENTRY_WORKING_DIRECTORY).withType(Type.STRING).build()); } return builder.build(); diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java similarity index 76% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java index 51981dde355d3..272184c99e6e7 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/TestUtils.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java @@ -15,11 +15,6 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies; -import java.util.ArrayList; -import java.util.List; -import org.junit.jupiter.api.Assertions; -import org.talend.sdk.component.api.record.Record; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_CLASS; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_CLAZZ_CLASSLOADER; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_CONNECTOR_CLASSLOADER; @@ -30,8 +25,43 @@ import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_RUNTIME_CLASSPATH; import static org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService.ENTRY_WORKING_DIRECTORY; -public class TestUtils { - public static List getDependList() { +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; +import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; + +public abstract class AbstractDynamicDependenciesServiceTest { + + private C config; + + protected abstract C buildConfig(); + + protected abstract S getService(); + + @BeforeEach + void setUp() { + this.config = this.buildConfig(); + } + + @Test + void testloadIterator() { + System.setProperty("talend.component.manager.m2.repository", "./lib/"); + + final Iterator result = getService().loadIterator(config); + + Assertions.assertTrue(result.hasNext()); + this.assertRecord(result.next()); + Assertions.assertFalse(result.hasNext()); + } + + protected List getDependList() { List depends = new ArrayList<>(); Dependency depend = new Dependency(); depend.setArtifactId("commons-numbers-primes"); @@ -42,7 +72,7 @@ public static List getDependList() { return depends; } - public static void assertRecord(Record record) { + private void assertRecord(Record record) { Assertions.assertNotNull(record); Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); Assertions.assertEquals( @@ -61,7 +91,7 @@ public static void assertRecord(Record record) { "org/apache/commons/commons-numbers-primes/1.2/commons-numbers-primes-1.2.jar!/org/apache/commons/numbers/primes/SmallPrimes.class")); Assertions.assertEquals("./lib/", record.getString(ENTRY_ROOT_REPOSITORY)); Assertions.assertNotNull(record.getString(ENTRY_RUNTIME_CLASSPATH)); - Assertions.assertNotNull(record.getString(ENTRY_WORKING_DIRECTORY)); + Assertions.assertEquals(System.getProperty("user.dir"), record.getString(ENTRY_WORKING_DIRECTORY)); Assertions.assertTrue(record.getString(ENTRY_RUNTIME_CLASSPATH).contains("commons-numbers-primes-1.2.jar")); } -} +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index da809ae3460dd..8e1614778e7c3 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -41,7 +41,6 @@ org.talend.sdk.sample dynamic-dependencies-common ${project.version} - tests test-jar test diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties index ec724be2ad89d..75f06aebbc117 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties @@ -15,5 +15,4 @@ # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example dynamicDependenciesWithDataset.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with dataset -dynamicDependenciesWithDataset.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with dataset -dynamicDependenciesWithDataset.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file +dynamicDependenciesWithDataset.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with dataset \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties index bd147d336d2a1..37b3370e63193 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties @@ -14,8 +14,8 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -Dataset.dso._displayName = -Dataset.dependencies._displayName = -Config.dse._displayName = -Config.dieOnError._displayName = -Config.environmentInformation._displayName = \ No newline at end of file +Dataset.dso._displayName = +Dataset.dependencies._displayName = Dependencies +Config.dse._displayName = +Config.dieOnError._displayName = Die on error +Config.environmentInformation._displayName = Environment information \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties index bb6d78ae9d32f..e283372e8c37c 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties @@ -14,4 +14,4 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDataset.Input._displayName = Dynamic Dependencies With Dataset Input \ No newline at end of file +dynamicDependenciesWithDataset.Input._displayName = Dynamic Dependencies With Dataset Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java index 5b7d5329ec524..f4683eec8c6b2 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java @@ -15,17 +15,11 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.service; -import org.talend.sdk.component.sample.feature.dynamicdependencies.TestUtils; - -import java.util.Iterator; import java.util.List; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.sample.feature.dynamicdependencies.AbstractDynamicDependenciesServiceTest; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Config; import org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset.config.Dataset; @@ -35,33 +29,28 @@ @Slf4j @WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset") -public class DatasetServiceTest { +public class DatasetServiceTest + extends AbstractDynamicDependenciesServiceTest { @Service - DynamicDependenciesWithDatasetService dynamicDependenciesServiceService; - - private Config config; + private DynamicDependenciesWithDatasetService dynamicDependenciesServiceService; - @BeforeEach - void setUp() { - config = new Config(); + @Override + protected Config buildConfig() { + Config config = new Config(); Dataset dse = new Dataset(); Datastore dso = new Datastore(); - List depends = TestUtils.getDependList(); + List depends = this.getDependList(); dse.setDependencies(depends); dse.setDso(dso); config.setDse(dse); config.setEnvironmentInformation(true); - } - @Test - void testloadIterator() { - System.setProperty("talend.component.manager.m2.repository", "./lib/"); - - final Iterator result = dynamicDependenciesServiceService.loadIterator(config); + return config; + } - Assertions.assertTrue(result.hasNext()); - TestUtils.assertRecord(result.next()); - Assertions.assertFalse(result.hasNext()); + @Override + protected DynamicDependenciesWithDatasetService getService() { + return dynamicDependenciesServiceService; } } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml index 71fbf18f3f7ca..d54c52653b059 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml @@ -13,7 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 org.talend.sdk.component @@ -27,7 +28,7 @@ - org.talend.sdk.component + org.talend.sdk.sample dynamic-dependencies-common ${project.version} @@ -36,7 +37,6 @@ org.talend.sdk.sample dynamic-dependencies-common ${project.version} - tests test-jar test @@ -47,12 +47,6 @@ 1.2 test - - org.talend.sdk.sample - dynamic-dependencies-common - 1.86.0-SNAPSHOT - test - @@ -63,7 +57,8 @@ - org.talend.sdk.component.dynamic.dependencies.withdatastore + org.talend.sdk.component.dynamic.dependencies.withdatastore + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java index df1c2e6ab564a..ff0247f3a7cee 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java @@ -41,7 +41,7 @@ public List getDynamicDependencies(@Option("theDatastore") final Datasto return super.getDynamicDependencies(datastore.getDependencies()); } - @DiscoverSchemaExtended(DISCOVERSCHEMA_ACTION) + @DiscoverSchemaExtended(DEPENDENCY_WITHDATASTORE_ACTION) public Schema guessSchema4Input(final @Option("configuration") Config config) { return super.buildSchema(config); } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties index 845043aa04e82..c1441fd5b6447 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties @@ -15,5 +15,4 @@ # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example dynamicDependenciesWithDatastore.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with datastore -dynamicDependenciesWithDatastore.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with datastore -dynamicDependenciesWithDatastore.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file +dynamicDependenciesWithDatastore.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with datastore \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties index d6aafaad395f8..3e79ffdba2002 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties @@ -14,8 +14,8 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -Datastore.dependencies._displayName = -Dataset.dso._displayName = -Config.dse._displayName = -Config.dieOnError._displayName = -Config.environmentInformation._displayName = \ No newline at end of file +Datastore.dependencies._displayName = Dependences +Dataset.dso._displayName = +Config.dse._displayName = +Config.dieOnError._displayName = Die on error +Config.environmentInformation._displayName = Environment information \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties index 5a92305e1efb7..0a253fa924171 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties @@ -14,4 +14,4 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDatastore.Input._displayName = Dynamic Dependencies With Datastore Input \ No newline at end of file +dynamicDependenciesWithDatastore.Input._displayName = Dynamic Dependencies With Datastore Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java index 0ef5583a370a6..af9ae9265de25 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java @@ -15,17 +15,11 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.service; -import org.talend.sdk.component.sample.feature.dynamicdependencies.TestUtils; - -import java.util.Iterator; import java.util.List; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.sample.feature.dynamicdependencies.AbstractDynamicDependenciesServiceTest; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Config; import org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore.config.Dataset; @@ -35,33 +29,28 @@ @Slf4j @WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore") -public class DatastoreServiceTest { +public class DatastoreServiceTest + extends AbstractDynamicDependenciesServiceTest { @Service DynamicDependenciesWithDatastoreService dynamicDependenciesServiceService; - private Config config; - - @BeforeEach - void setUp() { - config = new Config(); + @Override + protected Config buildConfig() { + Config config = new Config(); Dataset dse = new Dataset(); Datastore dso = new Datastore(); - List depends = TestUtils.getDependList(); + List depends = this.getDependList(); dso.setDependencies(depends); dse.setDso(dso); config.setDse(dse); config.setEnvironmentInformation(true); - } - @Test - void testloadIterator() { - System.setProperty("talend.component.manager.m2.repository", "./lib/"); - - final Iterator result = dynamicDependenciesServiceService.loadIterator(config); + return config; + } - Assertions.assertTrue(result.hasNext()); - TestUtils.assertRecord(result.next()); - Assertions.assertFalse(result.hasNext()); + @Override + protected DynamicDependenciesWithDatastoreService getService() { + return dynamicDependenciesServiceService; } } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml index 24ae599094379..a97a22bbaa086 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml @@ -25,9 +25,14 @@ jar Component Runtime :: Sample Feature @DynamicDependency with DynamicDependenciesConfiguration + + org.talend.sdk.component:dynamic-dependencies-common + include-exclude + + - org.talend.sdk.component + org.talend.sdk.sample dynamic-dependencies-common ${project.version} @@ -36,7 +41,6 @@ org.talend.sdk.sample dynamic-dependencies-common ${project.version} - tests test-jar test @@ -47,12 +51,6 @@ 1.2 test - - org.talend.sdk.sample - dynamic-dependencies-common - 1.86.0-SNAPSHOT - test - diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java index c4c0afade7f00..921ed21d30f70 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java @@ -26,6 +26,7 @@ import org.talend.sdk.component.api.input.Producer; import org.talend.sdk.component.api.meta.Documentation; import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesConfigurationService; @@ -33,7 +34,8 @@ @Icon(value = Icon.IconType.CUSTOM, custom = "icon") @Emitter(name = "Input") @Documentation("Dynamic dependencies sample input connector.") -public class DynamicDependenciesWithDynamicDependenciesconfigurationInput implements Serializable { +public class DynamicDependenciesWithDynamicDependenciesconfigurationInput extends AbstractDynamicDependenciesService + implements Serializable { private final Config config; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java index c584b7eb124a5..9fa0876465c46 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java @@ -41,7 +41,7 @@ public List getDynamicDependencies(@Option("theSubConfig") final SubConf return super.getDynamicDependencies(subConfig.getDependencies()); } - @DiscoverSchemaExtended(DISCOVERSCHEMA_ACTION) + @DiscoverSchemaExtended(DEPENDENCY_WITHDATASET_ACTION) public Schema guessSchema4Input(final @Option("configuration") Config config) { return super.buildSchema(config); } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties index 725f8dab189c0..7e328113b48b1 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties @@ -14,9 +14,9 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -Dataset.dso._displayName = -Config.dse._displayName = -Config.dieOnError._displayName = -Config.environmentInformation._displayName = +Dataset.dso._displayName = +Config.dse._displayName = +Config.dieOnError._displayName = Die on error +Config.environmentInformation._displayName = Environment information Config.subConfig._displayName = -SubConfig.dependencies._displayName = \ No newline at end of file +SubConfig.dependencies._displayName = Dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationServiceTest.java new file mode 100644 index 0000000000000..69a385aee45e0 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationServiceTest.java @@ -0,0 +1,58 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service; + +import java.util.List; + +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.sample.feature.dynamicdependencies.AbstractDynamicDependenciesServiceTest; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Datastore; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@WithComponents( + value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration") +public class DynamicDependenciesConfigurationServiceTest + extends + AbstractDynamicDependenciesServiceTest { + + @Service + DynamicDependenciesConfigurationService dynamicDependenciesServiceService; + + @Override + protected Config buildConfig() { + Config config = new Config(); + Dataset dse = new Dataset(); + Datastore dso = new Datastore(); + List depends = this.getDependList(); + config.getSubConfig().setDependencies(depends); + dse.setDso(dso); + config.setDse(dse); + config.setEnvironmentInformation(true); + + return config; + } + + @Override + protected DynamicDependenciesConfigurationService getService() { + return dynamicDependenciesServiceService; + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml index 1b2db4b3ca819..756dc532da339 100644 --- a/sample-parent/sample-features/dynamic-dependencies/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -41,6 +41,12 @@ ${project.version} test + \ No newline at end of file From 360f13dc702505e8a51d828fb7dc8a571202f32e Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 30 Oct 2025 18:17:55 +0100 Subject: [PATCH 14/41] chore(QTDI-1914): Add a connector with same behavior as datapreprun. --- .../pom.xml | 60 +++++++++++++++++ .../DynamicDependencySupported.java | 18 +++++ .../config/Config.java | 64 ++++++++++++++++++ .../config/Dataset.java | 38 +++++++++++ .../config/Datastore.java | 30 +++++++++ .../config/SubConfig.java | 40 +++++++++++ ...DynamicDependenciesconfigurationInput.java | 66 +++++++++++++++++++ .../package-info.java | 23 +++++++ ...endenciesDataprepRunAnnotationService.java | 50 ++++++++++++++ .../service/DataprepRunServiceTest.java | 55 ++++++++++++++++ .../dynamic-dependencies/pom.xml | 1 + 11 files changed, 445 insertions(+) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Dataset.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Datastore.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/package-info.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml new file mode 100644 index 0000000000000..ec4f6bf616d8d --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + + org.talend.sdk.component + sample-features + 1.86.0-SNAPSHOT + + + dynamic-dependencies-with-dataprepRunAnnotation + jar + Component Runtime :: Sample Feature @DynamicDependency with DataprepRun annotation + + + org.talend.sdk.component:dynamic-dependencies-common + include-exclude + + + + + org.talend.sdk.sample + dynamic-dependencies-common + ${project.version} + + + + org.talend.sdk.sample + dynamic-dependencies-common + ${project.version} + test-jar + test + + + + org.apache.commons + commons-numbers-primes + 1.2 + test + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dynamic.dependencies.withDataprepRunAnnotation + + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java new file mode 100644 index 0000000000000..8b20d0077a261 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java @@ -0,0 +1,18 @@ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.annotation; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.talend.sdk.component.api.configuration.type.meta.ConfigurationType; +import org.talend.sdk.component.api.meta.Documentation; + +@Target(TYPE) +@Retention(RUNTIME) +@ConfigurationType("configuration") +@Documentation("Copy/past of the annotation from tDataprepRun.") +public @interface DynamicDependencySupported { + String value() default "default"; +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java new file mode 100644 index 0000000000000..9d138331f36ba --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.annotation.DynamicDependencySupported; + +import lombok.Data; + +/** + * For this sample, the same configuration is used for all connectors input/processor/output. + */ +@Data +@DynamicDependencySupported +@GridLayout({ + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "subConfig" }), + @GridLayout.Row({ "environmentInformation" }) +}) +public class Config implements DynamicDependencyConfig, Serializable { + + @Option + @Documentation("The dataset configuration.") + private Dataset dse = new Dataset(); + + @Option + @Documentation("Sub-configuration that contains the DynamidDependenciesConfiguration.") + private SubConfig subConfig = new SubConfig(); + + @Option + @Documentation("If enable throw an exception for any error, if not just log the error.") + private boolean dieOnError = false; + + @Option + @Documentation("More environment information.") + private boolean environmentInformation = false; + + @Override + public List getDependencies() { + return new ArrayList<>(this.getSubConfig().getDependencies()); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Dataset.java new file mode 100644 index 0000000000000..e5b6da5daba63 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Dataset.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DataSet; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@DataSet("dyndepsdse") +@GridLayout(value = { + @GridLayout.Row({ "dso" }) +}) +public class Dataset implements Serializable { + + @Option + @Documentation("A datastore.") + private Datastore dso = new Datastore(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Datastore.java new file mode 100644 index 0000000000000..1749603106828 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Datastore.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.type.DataStore; +import org.talend.sdk.component.api.configuration.ui.layout.AutoLayout; + +import lombok.Data; + +@Data +@DataStore("dyndepsdso") +@AutoLayout +public class Datastore implements Serializable { + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java new file mode 100644 index 0000000000000..2617e7f559f32 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DynamicDependenciesConfiguration; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; + +import lombok.Data; + +@Data +@GridLayout({ + @GridLayout.Row({ "dependencies" }) +}) +public class SubConfig implements Serializable { + + @Option + @Documentation("The dependencies to load dynamically.") + private List dependencies = new ArrayList<>(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java new file mode 100644 index 0000000000000..fe0c9d93077c1 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java @@ -0,0 +1,66 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.input; + +import java.io.Serializable; +import java.util.Iterator; + +import javax.annotation.PostConstruct; + +import org.talend.sdk.component.api.component.Icon; +import org.talend.sdk.component.api.component.Version; +import org.talend.sdk.component.api.input.Emitter; +import org.talend.sdk.component.api.input.Producer; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.service.DynamicDependenciesDataprepRunAnnotationService; + +@Version +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +@Emitter(name = "Input") +@Documentation("Dynamic dependencies sample input connector.") +public class DynamicDependenciesWithDynamicDependenciesconfigurationInput extends AbstractDynamicDependenciesService + implements Serializable { + + private final Config config; + + private final DynamicDependenciesDataprepRunAnnotationService service; + + private Iterator recordIterator; + + public DynamicDependenciesWithDynamicDependenciesconfigurationInput(final Config config, + final DynamicDependenciesDataprepRunAnnotationService service) { + this.config = config; + this.service = service; + } + + @PostConstruct + public void init() { + this.recordIterator = this.service.loadIterator(this.config); + } + + @Producer + public Record next() { + if (recordIterator == null || !recordIterator.hasNext()) { + return null; + } + + return recordIterator.next(); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/package-info.java new file mode 100644 index 0000000000000..2ab45388df734 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/package-info.java @@ -0,0 +1,23 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Components( + family = "dynamicDependenciesWithDataprepAnnotation", + categories = "sample") +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation; + +import org.talend.sdk.component.api.component.Components; +import org.talend.sdk.component.api.component.Icon; \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java new file mode 100644 index 0000000000000..428a4278349c9 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.service; + +import java.io.Serializable; +import java.util.List; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.record.Schema; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.api.service.dependency.DynamicDependencies; +import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; +import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.SubConfig; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class DynamicDependenciesDataprepRunAnnotationService extends AbstractDynamicDependenciesService + implements Serializable { + + public final static String DEPENDENCY_WITHDATAPREPRUN_ACTION = "DEPENDENCY_WITHDATAPREPRUN_ACTION"; + + @DynamicDependencies() + public List getDynamicDependencies(@Option("theConfig") final Config config) { + return super.getDynamicDependencies(config.getDependencies()); + } + + @DiscoverSchemaExtended(DEPENDENCY_WITHDATAPREPRUN_ACTION) + public Schema guessSchema4Input(final @Option("configuration") Config config) { + return super.buildSchema(config); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java new file mode 100644 index 0000000000000..334d62e808a4a --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java @@ -0,0 +1,55 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.service; + +import java.util.List; + +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.sample.feature.dynamicdependencies.AbstractDynamicDependenciesServiceTest; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Dataset; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Datastore; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation") +public class DataprepRunServiceTest + extends AbstractDynamicDependenciesServiceTest { + + @Service + DynamicDependenciesDataprepRunAnnotationService dynamicDependenciesServiceService; + + @Override + protected Config buildConfig() { + Config config = new Config(); + Dataset dse = new Dataset(); + Datastore dso = new Datastore(); + List depends = this.getDependList(); + config.getSubConfig().setDependencies(depends); + dse.setDso(dso); + config.setDse(dse); + config.setEnvironmentInformation(true); + + return config; + } + + @Override + protected DynamicDependenciesDataprepRunAnnotationService getService() { + return dynamicDependenciesServiceService; + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml index 756dc532da339..e354afee25ac0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -32,6 +32,7 @@ dynamic-dependencies-with-dataset dynamic-dependencies-with-datastore dynamic-dependencies-with-dynamicDependenciesConfiguration + dynamic-dependencies-with-dataprepRunAnnotation From 136b654ce63f538e99e39ec7f0a391716de8a5a3 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Fri, 31 Oct 2025 09:37:44 +0800 Subject: [PATCH 15/41] fix layout for dieOnError --- .../feature/dynamicdependencies/withdataset/config/Config.java | 1 + .../feature/dynamicdependencies/withdatastore/config/Config.java | 1 + .../withDynamicDependenciesConfiguration/config/Config.java | 1 + 3 files changed, 3 insertions(+) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java index e9070eae41898..4d24151753a22 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java @@ -33,6 +33,7 @@ @Data @GridLayout({ @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "dieOnError" }), @GridLayout.Row({ "environmentInformation" }) }) public class Config implements DynamicDependencyConfig, Serializable { diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java index fc376ed311e35..1e7af215441fb 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java @@ -33,6 +33,7 @@ @Data @GridLayout({ @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "dieOnError" }), @GridLayout.Row({ "environmentInformation" }) }) public class Config implements DynamicDependencyConfig, Serializable { diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java index d9ab2e7b5f3f6..5e5949dfa7075 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java @@ -34,6 +34,7 @@ @GridLayout({ @GridLayout.Row({ "dse" }), @GridLayout.Row({ "subConfig" }), + @GridLayout.Row({ "dieOnError" }), @GridLayout.Row({ "environmentInformation" }) }) public class Config implements DynamicDependencyConfig, Serializable { From c3e7ad07bdd8a3994858a8ccc5890d0b4ba6b39e Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Fri, 31 Oct 2025 16:32:18 +0800 Subject: [PATCH 16/41] Fix dataprepRunAnnotation connector --- .../pom.xml | 21 ++++-- .../DynamicDependencySupported.java | 15 +++++ .../config/Config.java | 1 + .../config/SubConfig.java | 1 - ...endenciesDataprepRunAnnotationService.java | 6 +- .../src/main/resources/icons/dark/icon.svg | 66 +++++++++++++++++++ .../src/main/resources/icons/light/icon.svg | 66 +++++++++++++++++++ .../Messages.properties | 18 +++++ .../config/Messages.properties | 23 +++++++ .../input/Messages.properties | 17 +++++ .../service/DataprepRunServiceTest.java | 1 + 11 files changed, 227 insertions(+), 8 deletions(-) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/dark/icon.svg create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/light/icon.svg create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/Messages.properties diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml index ec4f6bf616d8d..cce69a50dd39b 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml @@ -1,11 +1,24 @@ - + + 4.0.0 + org.talend.sdk.component - sample-features + dynamic-dependencies 1.86.0-SNAPSHOT diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java index 8b20d0077a261..1731e25856250 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java @@ -1,3 +1,18 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.annotation; import static java.lang.annotation.ElementType.TYPE; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java index 9d138331f36ba..16bdd11b38e5b 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java @@ -36,6 +36,7 @@ @GridLayout({ @GridLayout.Row({ "dse" }), @GridLayout.Row({ "subConfig" }), + @GridLayout.Row({ "dieOnError" }), @GridLayout.Row({ "environmentInformation" }) }) public class Config implements DynamicDependencyConfig, Serializable { diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java index 2617e7f559f32..46f239e54a2d7 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java @@ -20,7 +20,6 @@ import java.util.List; import org.talend.sdk.component.api.configuration.Option; -import org.talend.sdk.component.api.configuration.type.DynamicDependenciesConfiguration; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java index 428a4278349c9..97b62a6980edb 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java @@ -25,8 +25,6 @@ import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.SubConfig; import lombok.extern.slf4j.Slf4j; @@ -37,7 +35,9 @@ public class DynamicDependenciesDataprepRunAnnotationService extends AbstractDyn public final static String DEPENDENCY_WITHDATAPREPRUN_ACTION = "DEPENDENCY_WITHDATAPREPRUN_ACTION"; - @DynamicDependencies() + public static final String DEPENDENCY_ACTION = "dataprep-dependencies"; + + @DynamicDependencies(DEPENDENCY_ACTION) public List getDynamicDependencies(@Option("theConfig") final Config config) { return super.getDynamicDependencies(config.getDependencies()); } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/dark/icon.svg new file mode 100644 index 0000000000000..3e6ba66a42db8 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/dark/icon.svg @@ -0,0 +1,66 @@ + + + + + + DynamicDependenciesDataset + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/light/icon.svg new file mode 100644 index 0000000000000..3e6ba66a42db8 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/light/icon.svg @@ -0,0 +1,66 @@ + + + + + + DynamicDependenciesDataset + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/Messages.properties new file mode 100644 index 0000000000000..0757f022f7615 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/Messages.properties @@ -0,0 +1,18 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependenciesWithDataprepAnnotation.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with dataset +dynamicDependenciesWithDataprepAnnotation.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with dataset \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties new file mode 100644 index 0000000000000..17cd41bce48d8 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties @@ -0,0 +1,23 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +Dataset.dso._displayName = +Dataset.dependencies._displayName = Dependencies +Config.dse._displayName = +Config.dieOnError._displayName = Die on error +Config.environmentInformation._displayName = Environment information +Config.subConfig._displayName = SubConfig +SubConfig.dependencies._displayName = Dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/Messages.properties new file mode 100644 index 0000000000000..8ece7b6117a49 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/Messages.properties @@ -0,0 +1,17 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +dynamicDependenciesWithDataprepAnnotation.Input._displayName = Dynamic Dependencies With Dynamic Dependencies Configuration Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java index 334d62e808a4a..654cdd2895dca 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java @@ -18,6 +18,7 @@ import java.util.List; import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.junit5.WithComponents; import org.talend.sdk.component.sample.feature.dynamicdependencies.AbstractDynamicDependenciesServiceTest; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Config; From 2417f804f45992b3b13045e1ebf723b0cad60617 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Tue, 4 Nov 2025 18:34:27 +0100 Subject: [PATCH 17/41] feat(QTDI-1914): Cleanings. --- .../dynamic-dependencies-with-dataprepRunAnnotation/pom.xml | 5 ----- .../annotation/DynamicDependencySupported.java | 1 + .../withDataprepRunAnnotation/config/Config.java | 5 ++++- .../withDataprepRunAnnotation/config/Dataset.java | 3 +++ .../withDataprepRunAnnotation/package-info.java | 2 +- .../src/main/resources/icons/dark/icon.svg | 4 ++-- .../src/main/resources/icons/light/icon.svg | 4 ++-- .../withDataprepRunAnnotation/Messages.properties | 4 ++-- .../withDataprepRunAnnotation/config/Messages.properties | 2 +- .../withDataprepRunAnnotation/input/Messages.properties | 2 +- .../dynamic-dependencies-with-dataset/pom.xml | 5 ----- .../dynamicdependencies/withdataset/config/Config.java | 5 ++++- .../dynamicdependencies/withdataset/config/Dataset.java | 3 +++ .../dynamicdependencies/withdataset/package-info.java | 2 +- .../dynamicdependencies/withdataset/Messages.properties | 4 ++-- .../withdataset/input/Messages.properties | 2 +- .../dynamicdependencies/withdatastore/config/Config.java | 5 ++++- .../dynamicdependencies/withdatastore/config/Dataset.java | 3 +++ .../dynamicdependencies/withdatastore/package-info.java | 2 +- .../dynamicdependencies/withdatastore/Messages.properties | 4 ++-- .../withdatastore/input/Messages.properties | 2 +- .../withDynamicDependenciesConfiguration/config/Config.java | 5 ++++- .../withDynamicDependenciesConfiguration/config/Dataset.java | 3 +++ .../withDynamicDependenciesConfiguration/package-info.java | 2 +- .../service/DynamicDependenciesConfigurationService.java | 4 ++-- .../withDynamicDependenciesConfiguration/Messages.properties | 5 ++--- .../input/Messages.properties | 2 +- 27 files changed, 52 insertions(+), 38 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml index cce69a50dd39b..0f346b2da2be0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml @@ -26,11 +26,6 @@ jar Component Runtime :: Sample Feature @DynamicDependency with DataprepRun annotation - - org.talend.sdk.component:dynamic-dependencies-common - include-exclude - - org.talend.sdk.sample diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java index 1731e25856250..7c81044cfbce7 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/annotation/DynamicDependencySupported.java @@ -29,5 +29,6 @@ @ConfigurationType("configuration") @Documentation("Copy/past of the annotation from tDataprepRun.") public @interface DynamicDependencySupported { + String value() default "default"; } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java index 16bdd11b38e5b..9b91a834e53ce 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java @@ -36,9 +36,12 @@ @GridLayout({ @GridLayout.Row({ "dse" }), @GridLayout.Row({ "subConfig" }), - @GridLayout.Row({ "dieOnError" }), @GridLayout.Row({ "environmentInformation" }) }) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "dieOnError" }) +}) public class Config implements DynamicDependencyConfig, Serializable { @Option diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Dataset.java index e5b6da5daba63..ea45a9daba395 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Dataset.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Dataset.java @@ -29,6 +29,9 @@ @GridLayout(value = { @GridLayout.Row({ "dso" }) }) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dso" }) +}) public class Dataset implements Serializable { @Option diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/package-info.java index 2ab45388df734..f671561c7be2c 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/package-info.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/package-info.java @@ -14,7 +14,7 @@ * limitations under the License. */ @Components( - family = "dynamicDependenciesWithDataprepAnnotation", + family = "DynamicDependenciesWithDataprepAnnotation", categories = "sample") @Icon(value = Icon.IconType.CUSTOM, custom = "icon") package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/dark/icon.svg index 3e6ba66a42db8..85e6a3e1e8eda 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/dark/icon.svg +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/dark/icon.svg @@ -22,7 +22,7 @@ inkscape:deskcolor="#d1d1d1" inkscape:zoom="43.575455" inkscape:cx="30.820103" - inkscape:cy="-1.445768" + inkscape:cy="-1.4228193" inkscape:window-width="3840" inkscape:window-height="2276" inkscape:window-x="-12" @@ -62,5 +62,5 @@ x="13.80696" y="8.6892385" style="line-height:2.94px;letter-spacing:0px;stroke-width:1.1597" - id="tspan2">Dataset + id="tspan2">DataprepRun diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/light/icon.svg index 3e6ba66a42db8..85e6a3e1e8eda 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/light/icon.svg +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/icons/light/icon.svg @@ -22,7 +22,7 @@ inkscape:deskcolor="#d1d1d1" inkscape:zoom="43.575455" inkscape:cx="30.820103" - inkscape:cy="-1.445768" + inkscape:cy="-1.4228193" inkscape:window-width="3840" inkscape:window-height="2276" inkscape:window-x="-12" @@ -62,5 +62,5 @@ x="13.80696" y="8.6892385" style="line-height:2.94px;letter-spacing:0px;stroke-width:1.1597" - id="tspan2">Dataset + id="tspan2">DataprepRun diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/Messages.properties index 0757f022f7615..6a100dc952c46 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/Messages.properties @@ -14,5 +14,5 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDataprepAnnotation.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with dataset -dynamicDependenciesWithDataprepAnnotation.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with dataset \ No newline at end of file +DynamicDependenciesWithDataprepAnnotation.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with datapreprun +DynamicDependenciesWithDataprepAnnotation.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with datapreprun \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties index 17cd41bce48d8..7705ca13b09f7 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties @@ -19,5 +19,5 @@ Dataset.dependencies._displayName = Dependencies Config.dse._displayName = Config.dieOnError._displayName = Die on error Config.environmentInformation._displayName = Environment information -Config.subConfig._displayName = SubConfig +Config.subConfig._displayName = SubConfig.dependencies._displayName = Dependencies \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/Messages.properties index 8ece7b6117a49..a0c8970bddfa2 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/Messages.properties @@ -14,4 +14,4 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDataprepAnnotation.Input._displayName = Dynamic Dependencies With Dynamic Dependencies Configuration Input \ No newline at end of file +DynamicDependenciesWithDataprepAnnotation.Input._displayName = Dynamic Dependencies With DataprepRun annotation Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index 8e1614778e7c3..0bd12a55f3bfa 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -25,11 +25,6 @@ jar Component Runtime :: Sample Feature @DynamicDependency with Dataset - - org.talend.sdk.component:dynamic-dependencies-common - include-exclude - - org.talend.sdk.sample diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java index 4d24151753a22..3ef03c7172e60 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java @@ -33,9 +33,12 @@ @Data @GridLayout({ @GridLayout.Row({ "dse" }), - @GridLayout.Row({ "dieOnError" }), @GridLayout.Row({ "environmentInformation" }) }) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "dieOnError" }), +}) public class Config implements DynamicDependencyConfig, Serializable { @Option diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java index dda5e9d89446c..59541a501f0f9 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java @@ -33,6 +33,9 @@ @GridLayout.Row({ "dso" }), @GridLayout.Row({ "dependencies" }) }) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dso" }) +}) public class Dataset implements Serializable { @Option diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java index 5d16d15697f92..525faeb12ae02 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/package-info.java @@ -14,7 +14,7 @@ * limitations under the License. */ @Components( - family = "dynamicDependenciesWithDataset", + family = "DynamicDependenciesWithDataset", categories = "sample") @Icon(value = Icon.IconType.CUSTOM, custom = "icon") package org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties index 75f06aebbc117..e2466c2844474 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/Messages.properties @@ -14,5 +14,5 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDataset.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with dataset -dynamicDependenciesWithDataset.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with dataset \ No newline at end of file +DynamicDependenciesWithDataset.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with dataset +DynamicDependenciesWithDataset.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with dataset \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties index e283372e8c37c..43d63aaae3a02 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/input/Messages.properties @@ -14,4 +14,4 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDataset.Input._displayName = Dynamic Dependencies With Dataset Input \ No newline at end of file +DynamicDependenciesWithDataset.Input._displayName = Dynamic Dependencies With Dataset Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java index 1e7af215441fb..13f6203f15f38 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java @@ -33,9 +33,12 @@ @Data @GridLayout({ @GridLayout.Row({ "dse" }), - @GridLayout.Row({ "dieOnError" }), @GridLayout.Row({ "environmentInformation" }) }) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "dieOnError" }), +}) public class Config implements DynamicDependencyConfig, Serializable { @Option diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Dataset.java index 0faac7aef808c..abc52e5ec91c4 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Dataset.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Dataset.java @@ -29,6 +29,9 @@ @GridLayout(value = { @GridLayout.Row({ "dso" }) }) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dso" }) +}) public class Dataset implements Serializable { @Option diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/package-info.java index acd6d1e4fe4d8..84c17f8fc511b 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/package-info.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/package-info.java @@ -14,7 +14,7 @@ * limitations under the License. */ @Components( - family = "dynamicDependenciesWithDatastore", + family = "DynamicDependenciesWithDatastore", categories = "sample") @Icon(value = Icon.IconType.CUSTOM, custom = "icon") package org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties index c1441fd5b6447..54e6e670c24ff 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/Messages.properties @@ -14,5 +14,5 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDatastore.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with datastore -dynamicDependenciesWithDatastore.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with datastore \ No newline at end of file +DynamicDependenciesWithDatastore.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies with datastore +DynamicDependenciesWithDatastore.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies with datastore \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties index 0a253fa924171..686de01008376 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/Messages.properties @@ -14,4 +14,4 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDatastore.Input._displayName = Dynamic Dependencies With Datastore Input \ No newline at end of file +DynamicDependenciesWithDatastore.Input._displayName = Dynamic Dependencies With Datastore Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java index 5e5949dfa7075..5081fe4ced75a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java @@ -34,9 +34,12 @@ @GridLayout({ @GridLayout.Row({ "dse" }), @GridLayout.Row({ "subConfig" }), - @GridLayout.Row({ "dieOnError" }), @GridLayout.Row({ "environmentInformation" }) }) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "dieOnError" }), +}) public class Config implements DynamicDependencyConfig, Serializable { @Option diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Dataset.java index 3fe30c3f77fbf..8bd5960324df2 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Dataset.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Dataset.java @@ -29,6 +29,9 @@ @GridLayout(value = { @GridLayout.Row({ "dso" }) }) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dso" }) +}) public class Dataset implements Serializable { @Option diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/package-info.java index c484957886382..fcc2ed3c55c47 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/package-info.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/package-info.java @@ -14,7 +14,7 @@ * limitations under the License. */ @Components( - family = "dynamicDependenciesWithDynamicDependenciesConfiguration", + family = "DynamicDependenciesWithDynamicDependenciesConfiguration", categories = "sample") @Icon(value = Icon.IconType.CUSTOM, custom = "icon") package org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java index 9fa0876465c46..9e7188b9a073f 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java @@ -34,14 +34,14 @@ public class DynamicDependenciesConfigurationService extends AbstractDynamicDependenciesService implements Serializable { - public final static String DEPENDENCY_WITHDATASET_ACTION = "DEPENDENCY_WITHDATASET_ACTION"; + public final static String DEPENDENCY_WITHDYNDEPSCONFIG_ACTION = "DEPENDENCY_WITHDYNDEPSCONFIG_ACTION"; @DynamicDependencies() public List getDynamicDependencies(@Option("theSubConfig") final SubConfig subConfig) { return super.getDynamicDependencies(subConfig.getDependencies()); } - @DiscoverSchemaExtended(DEPENDENCY_WITHDATASET_ACTION) + @DiscoverSchemaExtended(DEPENDENCY_WITHDYNDEPSCONFIG_ACTION) public Schema guessSchema4Input(final @Option("configuration") Config config) { return super.buildSchema(config); } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties index 8c2575448881a..c86de8883106d 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/Messages.properties @@ -14,6 +14,5 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDynamicDependenciesConfiguration.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies With DynamicDependenciesConfiguration -dynamicDependenciesWithDynamicDependenciesConfiguration.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies With DynamicDependenciesConfiguration -dynamicDependenciesWithDynamicDependenciesConfiguration.actions.schema.DISCOVERSCHEMA_ACTION._displayName = Discover Schema for dynamic dependencies \ No newline at end of file +DynamicDependenciesWithDynamicDependenciesConfiguration.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies With DynamicDependenciesConfiguration +DynamicDependenciesWithDynamicDependenciesConfiguration.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies With DynamicDependenciesConfiguration \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/Messages.properties index 52816b8cb1df6..b252d46a5697c 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/Messages.properties @@ -14,4 +14,4 @@ # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -dynamicDependenciesWithDynamicDependenciesConfiguration.Input._displayName = Dynamic Dependencies With DynamicDependenciesConfiguration Input \ No newline at end of file +DynamicDependenciesWithDynamicDependenciesConfiguration.Input._displayName = Dynamic Dependencies With DynamicDependenciesConfiguration Input \ No newline at end of file From fdde448607ce377ee641f1e96fd4920b438a2c92 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Wed, 5 Nov 2025 18:09:23 +0800 Subject: [PATCH 18/41] Add Readme --- .../dynamic-dependencies/README.md | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sample-parent/sample-features/dynamic-dependencies/README.md diff --git a/sample-parent/sample-features/dynamic-dependencies/README.md b/sample-parent/sample-features/dynamic-dependencies/README.md new file mode 100644 index 0000000000000..aff3dac7f1be4 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/README.md @@ -0,0 +1,38 @@ +# Component Runtime :: Sample Feature :: DynamicDependency + +## Table of Contents +- [Overview](#overview) +- [Usage](#usage) + - [How to build the connector plugin](#how-to-build-the-sample-connector-plugin) + - [How to use](#how-to-use) + + +## Overview +This is a test TCK connector plugin to test and validate the DynamicDependency input feature. + +This project contains 4 test connectors: +### DynamicDependency with Dataset +The service of this connector use a dataset as parameter. + +### DynamicDependency with Datastore +The service of this connector use a datastore as parameter. + +### DynamicDependency with Dataprep run annotation +The service of this connector use a new annotation @DynamicDependencySupported. + +### DynamicDependency with @DynamicDependenciesConfiguration +The service of this connector use a config which using @DynamicDependenciesConfiguration. + +## Usage +### How to build the sample connector plugin +Checkout the code from the repository and build the project using `mvn clean install` +Alternatively build the feature module using `mvn install -am -pl :dynamicdependencies` + +### How to use +- Deploy the connector into Studio: +java -jar dynamic-dependencies-with-dataset-1.86.0-SNAPSHOT.car studio-deploy --location c:\Talend-Studio-20251010_0827-V8.0.2SNAPSHOT + +- Use the connector in the job. +- Click "Guess schema" of the connector. +- Add others you want to use in the job, then run the job. + From 0572b53563fc1f630365bac407ab10bdb6a14270 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Mon, 10 Nov 2025 10:53:56 +0100 Subject: [PATCH 19/41] feat(QTDI-1914): try to execute a TCK connector to check if it is well loaded... to continue... --- .../config/Dependency.java | 13 +++++++ .../AbstractDynamicDependenciesService.java | 36 +++++++++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java index a4c67f8826dbd..d3ddba7727ea4 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java @@ -45,4 +45,17 @@ public class Dependency implements Serializable { @Documentation("The class to try to load from this dependency.") private String clazz; + @Option + private String connectorFamily; + + @Option + private String connectorName; + + @Option + private int connectorVersion; + + @Option + private String connectorConfiguration; + + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java index 0d8e73213a669..65f9877246bd6 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java @@ -1,12 +1,12 @@ /** * Copyright (C) 2006-2025 Talend Inc. - www.talend.com - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + *

* http://www.apache.org/licenses/LICENSE-2.0 - * + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,8 +18,10 @@ import java.io.Serializable; import java.net.URL; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.talend.sdk.component.api.exception.ComponentException; import org.talend.sdk.component.api.record.Record; @@ -28,6 +30,7 @@ import org.talend.sdk.component.api.record.Schema.Type; import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.api.service.record.RecordBuilderFactory; +import org.talend.sdk.component.api.service.source.ProducerFinder; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; @@ -63,6 +66,9 @@ public abstract class AbstractDynamicDependenciesService implements Serializable @Service private RecordBuilderFactory factory; + @Service + private ProducerFinder finder; + public Iterator loadIterator(final DynamicDependencyConfig dynamicDependencyConfig) { Schema schema = buildSchema(dynamicDependencyConfig); @@ -92,9 +98,13 @@ public Iterator loadIterator(final DynamicDependencyConfig dynamicDepend "Cannot load class %s from system classloader".formatted(dependency.getClazz()), e); } - boolean isTckContainer = isTCKContainer(fromLocation); - // package-info@Components - boolean isLoadedInTck = false; // to improve + boolean isTckContainer = false; + boolean isLoadedInTck = false; + if (dependency.getConnectorFamily() != null && !dependency.getConnectorFamily().isEmpty()) { + isTckContainer = isTCKContainer(fromLocation); // not now + // package-info@Components + isLoadedInTck = testLoadingData(dependency); // to improve + } Builder recordBuilder = builder .withString(ENTRY_MAVEN, maven) @@ -124,6 +134,16 @@ public Iterator loadIterator(final DynamicDependencyConfig dynamicDepend return records.iterator(); } + private boolean testLoadingData(final Dependency dependency) { + Iterator recordIterator = this.loadData(dependency.getConnectorFamily(), dependency.getConnectorName(), dependency.getConnectorVersion(), json2Map(dependency.getConnectorConfiguration())); + return recordIterator.hasNext(); + } + + private Map json2Map(final String json) { + // Transform the given json to map + return Collections.emptyMap(); + } + protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConfig) { Schema.Builder builder = factory.newSchemaBuilder(Type.RECORD) .withEntry(factory.newEntryBuilder().withName(ENTRY_MAVEN).withType(Type.STRING).build()) @@ -148,6 +168,10 @@ protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConf return builder.build(); } + protected Iterator loadData(String family, String name, int version, Map parameters) { + return finder.find(family, name, version, parameters); + } + private void manageException(final boolean dieOnError, final String message, final Exception e) { String msg = "Dynamic dependencies connector raised an exception: %s : %s".formatted(message, e.getMessage()); log.error(msg, e); From 06da2862856e5faa1552cfcd1e8fbc6dd0f85977 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Wed, 12 Nov 2025 16:24:04 +0800 Subject: [PATCH 20/41] Add function to load depended component's depends --- .../config/Dependency.java | 4 ++ .../AbstractDynamicDependenciesService.java | 42 ++++++++++---- ...bstractDynamicDependenciesServiceTest.java | 5 +- .../pom.xml | 6 ++ ...endenciesDataprepRunAnnotationService.java | 57 +++++++++++++++++++ .../service/DataprepRunServiceTest.java | 53 +++++++++++++++++ 6 files changed, 155 insertions(+), 12 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java index d3ddba7727ea4..633ac24e0ad8c 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java @@ -46,15 +46,19 @@ public class Dependency implements Serializable { private String clazz; @Option + @Documentation("The family for depended connector.") private String connectorFamily; @Option + @Documentation("The name for depended connector.") private String connectorName; @Option + @Documentation("The version for depended connector.") private int connectorVersion; @Option + @Documentation("The configuration for depended connector.") private String connectorConfiguration; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java index 65f9877246bd6..09442be77520f 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java @@ -1,12 +1,12 @@ /** * Copyright (C) 2006-2025 Talend Inc. - www.talend.com - *

+ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

+ * * http://www.apache.org/licenses/LICENSE-2.0 - *

+ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,13 +15,20 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.service; +import java.io.IOException; +import java.io.InputStream; import java.io.Serializable; import java.net.URL; +import java.nio.file.FileSystems; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Properties; +import java.util.jar.JarFile; import org.talend.sdk.component.api.exception.ComponentException; import org.talend.sdk.component.api.record.Record; @@ -67,7 +74,7 @@ public abstract class AbstractDynamicDependenciesService implements Serializable private RecordBuilderFactory factory; @Service - private ProducerFinder finder; + protected ProducerFinder finder; public Iterator loadIterator(final DynamicDependencyConfig dynamicDependencyConfig) { Schema schema = buildSchema(dynamicDependencyConfig); @@ -103,7 +110,7 @@ public Iterator loadIterator(final DynamicDependencyConfig dynamicDepend if (dependency.getConnectorFamily() != null && !dependency.getConnectorFamily().isEmpty()) { isTckContainer = isTCKContainer(fromLocation); // not now // package-info@Components - isLoadedInTck = testLoadingData(dependency); // to improve + isLoadedInTck = testLoadingData(dynamicDependencyConfig, dependency); // to improve } Builder recordBuilder = builder @@ -134,11 +141,29 @@ public Iterator loadIterator(final DynamicDependencyConfig dynamicDepend return records.iterator(); } - private boolean testLoadingData(final Dependency dependency) { - Iterator recordIterator = this.loadData(dependency.getConnectorFamily(), dependency.getConnectorName(), dependency.getConnectorVersion(), json2Map(dependency.getConnectorConfiguration())); + protected boolean testLoadingData(final DynamicDependencyConfig dynamicDependencyConfig, final Dependency dependency) { + Iterator recordIterator = finder.find(dependency.getConnectorFamily(), dependency.getConnectorName(), + dependency.getConnectorVersion(), Collections.emptyMap()); return recordIterator.hasNext(); } + //If the dependency is a TCK connector, get its dependencies list + protected Map loadComponentDepends(final DynamicDependencyConfig dynamicDependencyConfig, final String jarPath) { + Map configMap = new HashMap<>(); + final Path archive = FileSystems.getDefault().getPath(jarPath); + try (final JarFile file = new JarFile(archive.toFile()); + final InputStream stream = file.getInputStream(file.getEntry("TALEND-INF/dependencies.txt"))) { + final Properties properties = new Properties(); + properties.load(stream); + properties.stringPropertyNames().forEach(name -> { + configMap.put(name, properties.getProperty(name)); + }); + return configMap;//empty if no dependencies + } catch (final IOException e) { + throw new IllegalStateException(e); + } + } + private Map json2Map(final String json) { // Transform the given json to map return Collections.emptyMap(); @@ -168,9 +193,6 @@ protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConf return builder.build(); } - protected Iterator loadData(String family, String name, int version, Map parameters) { - return finder.find(family, name, version, parameters); - } private void manageException(final boolean dieOnError, final String message, final Exception e) { String msg = "Dynamic dependencies connector raised an exception: %s : %s".formatted(message, e.getMessage()); diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java index 272184c99e6e7..1056a5c81ccfd 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; + import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; @@ -39,7 +40,7 @@ public abstract class AbstractDynamicDependenciesServiceTest { - private C config; + protected C config; protected abstract C buildConfig(); @@ -72,7 +73,7 @@ protected List getDependList() { return depends; } - private void assertRecord(Record record) { + protected void assertRecord(Record record) { Assertions.assertNotNull(record); Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); Assertions.assertEquals( diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml index 0f346b2da2be0..75aeb389c1946 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml @@ -47,6 +47,12 @@ 1.2 test + + org.talend.sdk.component + container-core + 1.86.0-SNAPSHOT + compile + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java index 97b62a6980edb..4c7bca6b14018 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java @@ -15,16 +15,31 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.service; +import java.io.IOException; +import java.io.InputStream; import java.io.Serializable; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.jar.JarFile; import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.record.Schema; import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.api.service.dependency.DynamicDependencies; import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.SubConfig; import lombok.extern.slf4j.Slf4j; @@ -47,4 +62,46 @@ public Schema guessSchema4Input(final @Option("configuration") Config config) { return super.buildSchema(config); } + protected boolean testLoadingData(final DynamicDependencyConfig dynamicDependencyConfig, final Dependency dependency) { + //if depend on tck connector, load this connector's depends in its dependencies.txt into subconfig. + //loadComponentDepends(dynamicDependencyConfig, dependency.getConnectorFamily() + ":" + dependency.getConnectorName()); + + //In junit, can only find one : test. + Iterator recordIterator = finder.find(dependency.getConnectorFamily(), dependency.getConnectorName(), + dependency.getConnectorVersion(), Collections.emptyMap()); + return recordIterator.hasNext(); + } + + protected Map loadComponentDepends(final DynamicDependencyConfig dynamicDependencyConfig, final String jarPath) { + Map configMap = new HashMap<>(); + SubConfig subConfig = ((Config)dynamicDependencyConfig).getSubConfig(); + final Path archive = FileSystems.getDefault().getPath(jarPath); + + if (!Files.exists(archive)) { + throw new IllegalArgumentException("--Dependency does not exist: '" + archive + "'"); + } + try (final JarFile file = new JarFile(archive.toFile()); + final InputStream stream = file.getInputStream(file.getEntry("TALEND-INF/dependencies.txt"))) { + final Properties properties = new Properties(); + properties.load(stream); + properties.stringPropertyNames().forEach(name -> { + configMap.put(name, properties.getProperty(name)); + addToDependList(subConfig, name, properties.getProperty(name)); + }); + return configMap; + } catch (final IOException e) { + throw new IllegalStateException(e); + } + } + + private static void addToDependList(final SubConfig subConfig, final String name, final String property) { + Dependency depend = new Dependency(); + depend.setArtifactId(name); + depend.setVersion("1.2"); + depend.setGroupId(property); + depend.setClazz("FromDependency"); + + subConfig.getDependencies().add(depend); + } + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java index 654cdd2895dca..0274477b61927 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java @@ -15,8 +15,14 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.service; +import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.junit5.WithComponents; import org.talend.sdk.component.sample.feature.dynamicdependencies.AbstractDynamicDependenciesServiceTest; @@ -35,6 +41,27 @@ public class DataprepRunServiceTest @Service DynamicDependenciesDataprepRunAnnotationService dynamicDependenciesServiceService; + + @Test + void testloadIterator() { + System.setProperty("talend.component.manager.m2.repository", "./lib/"); + + final Iterator result = getService().loadIterator(config); + + Assertions.assertTrue(result.hasNext()); + this.assertRecord(result.next()); + Assertions.assertFalse(result.hasNext()); + } + + @Test + void testLoadDependency() { + System.setProperty("talend.component.manager.m2.repository", "./lib/"); + + Map depends = getService().loadComponentDepends(config, "C:\\Users\\ODG\\.m2\\repository\\org\\talend\\components\\record-provider\\1.71.0-SNAPSHOT\\record-provider-1.71.0-SNAPSHOT.jar"); + Assertions.assertEquals(2, depends.size()); + + } + @Override protected Config buildConfig() { Config config = new Config(); @@ -49,6 +76,32 @@ protected Config buildConfig() { return config; } + //use tck cnnector as dependency + protected List getDependList() { + List depends = new ArrayList<>(); + Dependency depend = new Dependency(); + depend.setArtifactId("commons-numbers-primes"); + depend.setVersion("1.2"); + depend.setGroupId("org.apache.commons"); + depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); + depends.add(depend); + + //for connector depend + Dependency depend2 = new Dependency(); + depend.setArtifactId("record-provider"); + depend.setVersion("1.71.0-SNAPSHOT"); + depend.setGroupId("org.talend.components"); + depend.setClazz("org.talend.components.recordprovider.source.GenericMapper"); + //set a TCK connector as one dependency for depend2. + depend.setConnectorFamily("JDBC"); + depend.setConnectorName("newjdbc"); + depend.setConnectorVersion(1); + depend.setConnectorConfiguration(""); + + depends.add(depend2); + return depends; + } + @Override protected DynamicDependenciesDataprepRunAnnotationService getService() { return dynamicDependenciesServiceService; From fe550fc68079018f19fd129dd88301eec53ef7ab Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Tue, 18 Nov 2025 10:13:18 +0800 Subject: [PATCH 21/41] # Conflicts: # sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java # sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java --- .../dynamicdependencies/config/Connector.java | 65 +++++ .../config/Dependency.java | 17 -- .../config/DynamicDependencyConfig.java | 2 + .../AbstractDynamicDependenciesService.java | 235 +++++++++++++----- .../config/Config.java | 6 + .../config/SubConfig.java | 8 +- ...endenciesDataprepRunAnnotationService.java | 2 +- .../config/Messages.properties | 3 +- .../withdataset/config/Config.java | 5 + .../withdataset/config/Dataset.java | 8 +- ...DynamicDependenciesWithDatasetService.java | 2 +- .../withdataset/config/Messages.properties | 3 +- .../withdatastore/config/Config.java | 5 + .../withdatastore/config/Datastore.java | 8 +- ...namicDependenciesWithDatastoreService.java | 2 +- .../withdatastore/config/Messages.properties | 3 +- .../config/Config.java | 5 + .../config/SubConfig.java | 8 +- ...namicDependenciesConfigurationService.java | 2 +- .../config/Messages.properties | 3 +- 20 files changed, 302 insertions(+), 90 deletions(-) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Connector.java diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Connector.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Connector.java new file mode 100644 index 0000000000000..3aed79831e48e --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Connector.java @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@GridLayout(value = { + @GridLayout.Row({ "groupId", "artifactId", "version", "connectorFamily", "connectorName", "connectorVersion", + "loadTransitiveDependencies", "connectorConfiguration" }) +}) +public class Connector implements Serializable { + + @Option + @Documentation("The connector's group id.") + private String groupId; + + @Option + @Documentation("The connector's artifact id.") + private String artifactId; + + @Option + @Documentation("The connector's artifact version.") + private String version; + + @Option + @Documentation("The connector's family.") + private String connectorFamily; + + @Option + @Documentation("The connector's namer.") + private String connectorName; + + @Option + @Documentation("The connector's version.") + private int connectorVersion; + + @Option + @Documentation("Load transitive dependencies from TALEND-INF/dependencies.txt.") + private boolean loadTransitiveDependencies; + + @Option + @Documentation("The connector's configuration.") + private String connectorConfiguration; + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java index 633ac24e0ad8c..a4c67f8826dbd 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java @@ -45,21 +45,4 @@ public class Dependency implements Serializable { @Documentation("The class to try to load from this dependency.") private String clazz; - @Option - @Documentation("The family for depended connector.") - private String connectorFamily; - - @Option - @Documentation("The name for depended connector.") - private String connectorName; - - @Option - @Documentation("The version for depended connector.") - private int connectorVersion; - - @Option - @Documentation("The configuration for depended connector.") - private String connectorConfiguration; - - } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/DynamicDependencyConfig.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/DynamicDependencyConfig.java index b40f4d3faa9c8..ec866e68c5a19 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/DynamicDependencyConfig.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/DynamicDependencyConfig.java @@ -21,6 +21,8 @@ public interface DynamicDependencyConfig { List getDependencies(); + List getConnectors(); + boolean isEnvironmentInformation(); boolean isDieOnError(); diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java index 09442be77520f..8d1aa84c2781f 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java @@ -15,20 +15,24 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.service; +import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Serializable; import java.net.URL; -import java.nio.file.FileSystems; -import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Properties; +import java.util.Optional; +import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.talend.sdk.component.api.exception.ComponentException; import org.talend.sdk.component.api.record.Record; @@ -36,8 +40,10 @@ import org.talend.sdk.component.api.record.Schema; import org.talend.sdk.component.api.record.Schema.Type; import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.api.service.dependency.Resolver; import org.talend.sdk.component.api.service.record.RecordBuilderFactory; import org.talend.sdk.component.api.service.source.ProducerFinder; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; @@ -46,8 +52,6 @@ @Slf4j public abstract class AbstractDynamicDependenciesService implements Serializable { - public static final String DISCOVERSCHEMA_ACTION = "DISCOVERSCHEMA_ACTION"; - public static final String ENTRY_MAVEN = "maven"; public static final String ENTRY_CLASS = "clazz"; @@ -62,7 +66,7 @@ public abstract class AbstractDynamicDependenciesService implements Serializable public static final String ENTRY_IS_TCK_CONTAINER = "is_tck_container"; - public static final String ENTRY_IS_LOADED_IN_TCK = "is_loaded_in_tck_manager"; + public static final String ENTRY_FIRST_RECORD = "first_record"; public static final String ENTRY_ROOT_REPOSITORY = "root_repository"; @@ -74,14 +78,24 @@ public abstract class AbstractDynamicDependenciesService implements Serializable private RecordBuilderFactory factory; @Service - protected ProducerFinder finder; + private ProducerFinder finder; + + @Service + private Resolver resolver; public Iterator loadIterator(final DynamicDependencyConfig dynamicDependencyConfig) { Schema schema = buildSchema(dynamicDependencyConfig); + List standardDependencies = loadStandarDependencies(dynamicDependencyConfig, schema); + List additionalConnectors = loadConnectors(dynamicDependencyConfig, schema); + + return Stream.concat(standardDependencies.stream(), additionalConnectors.stream()).iterator(); + } + + private List loadStandarDependencies(final DynamicDependencyConfig dynamicDependencyConfig, + final Schema schema) { List records = new ArrayList<>(); for (Dependency dependency : dynamicDependencyConfig.getDependencies()) { - Builder builder = factory.newRecordBuilder(schema); String maven = String.format("%s:%s:%s", dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); @@ -105,63 +119,95 @@ public Iterator loadIterator(final DynamicDependencyConfig dynamicDepend "Cannot load class %s from system classloader".formatted(dependency.getClazz()), e); } - boolean isTckContainer = false; - boolean isLoadedInTck = false; - if (dependency.getConnectorFamily() != null && !dependency.getConnectorFamily().isEmpty()) { - isTckContainer = isTCKContainer(fromLocation); // not now - // package-info@Components - isLoadedInTck = testLoadingData(dynamicDependencyConfig, dependency); // to improve - } + Record record = buildRecord(schema, + dynamicDependencyConfig, + maven, + dependency.getClazz(), + isLoaded, + connectorClassLoaderId, + clazzClassLoaderId, + fromLocation, + false, + Optional.empty()); + records.add(record); + } - Builder recordBuilder = builder - .withString(ENTRY_MAVEN, maven) - .withString(ENTRY_CLASS, dependency.getClazz()) - .withBoolean(ENTRY_IS_LOADED, isLoaded) - .withString(ENTRY_CONNECTOR_CLASSLOADER, connectorClassLoaderId) - .withString(ENTRY_CLAZZ_CLASSLOADER, clazzClassLoaderId) - .withString(ENTRY_FROM_LOCATION, fromLocation) - .withBoolean(ENTRY_IS_TCK_CONTAINER, isTckContainer) - .withBoolean(ENTRY_IS_LOADED_IN_TCK, isLoadedInTck); - - if (dynamicDependencyConfig.isEnvironmentInformation()) { - String rootRepository = System.getProperty("talend.component.manager.m2.repository"); - String runtimeClasspath = System.getProperty("java.class.path"); - String workDirectory = System.getProperty("user.dir"); - - recordBuilder = recordBuilder - .withString(ENTRY_ROOT_REPOSITORY, rootRepository) - .withString(ENTRY_RUNTIME_CLASSPATH, runtimeClasspath) - .withString(ENTRY_WORKING_DIRECTORY, workDirectory); - } + return records; + } + + private List loadConnectors(final DynamicDependencyConfig dynamicDependencyConfig, final Schema schema) { + List records = new ArrayList<>(); + for (Connector connector : dynamicDependencyConfig.getConnectors()) { - Record record = recordBuilder.build(); + String maven = String.format("%s:%s:%s", connector.getGroupId(), connector.getArtifactId(), + connector.getVersion()); + + String connectorClassLoaderId = this.getClass().getClassLoader().toString(); + String clazzClassLoaderId = "N/A"; + String fromLocation = "N/A"; + Optional optionalRecord = testLoadingData(connector); + boolean isLoaded = optionalRecord.isPresent(); + + Record record = buildRecord(schema, + dynamicDependencyConfig, + maven, + "N/A", + isLoaded, + connectorClassLoaderId, + clazzClassLoaderId, + fromLocation, + true, + optionalRecord); records.add(record); } - return records.iterator(); - } + return records; - protected boolean testLoadingData(final DynamicDependencyConfig dynamicDependencyConfig, final Dependency dependency) { - Iterator recordIterator = finder.find(dependency.getConnectorFamily(), dependency.getConnectorName(), - dependency.getConnectorVersion(), Collections.emptyMap()); - return recordIterator.hasNext(); } - //If the dependency is a TCK connector, get its dependencies list - protected Map loadComponentDepends(final DynamicDependencyConfig dynamicDependencyConfig, final String jarPath) { - Map configMap = new HashMap<>(); - final Path archive = FileSystems.getDefault().getPath(jarPath); - try (final JarFile file = new JarFile(archive.toFile()); - final InputStream stream = file.getInputStream(file.getEntry("TALEND-INF/dependencies.txt"))) { - final Properties properties = new Properties(); - properties.load(stream); - properties.stringPropertyNames().forEach(name -> { - configMap.put(name, properties.getProperty(name)); - }); - return configMap;//empty if no dependencies - } catch (final IOException e) { - throw new IllegalStateException(e); + private Record buildRecord(final Schema schema, + final DynamicDependencyConfig dynamicDependencyConfig, + final String maven, + final String clazz, + final boolean isLoaded, + final String connectorClassLoaderId, + final String clazzClassLoaderId, + final String fromLocation, + final boolean isTckContainer, + final Optional firstRecord) { + Builder builder = factory.newRecordBuilder(schema); + Builder recordBuilder = builder + .withString(ENTRY_MAVEN, maven) + .withString(ENTRY_CLASS, clazz) + .withBoolean(ENTRY_IS_LOADED, isLoaded) + .withString(ENTRY_CONNECTOR_CLASSLOADER, connectorClassLoaderId) + .withString(ENTRY_CLAZZ_CLASSLOADER, clazzClassLoaderId) + .withString(ENTRY_FROM_LOCATION, fromLocation) + .withBoolean(ENTRY_IS_TCK_CONTAINER, isTckContainer); + + if (firstRecord.isPresent()) { + builder.withRecord(ENTRY_FIRST_RECORD, firstRecord.get()); + } + + if (dynamicDependencyConfig.isEnvironmentInformation()) { + String rootRepository = System.getProperty("talend.component.manager.m2.repository"); + String runtimeClasspath = System.getProperty("java.class.path"); + String workDirectory = System.getProperty("user.dir"); + + recordBuilder = recordBuilder + .withString(ENTRY_ROOT_REPOSITORY, rootRepository) + .withString(ENTRY_RUNTIME_CLASSPATH, runtimeClasspath) + .withString(ENTRY_WORKING_DIRECTORY, workDirectory); } + + return recordBuilder.build(); + } + + private Optional testLoadingData(final Connector connector) { + Iterator recordIterator = this.loadData(connector.getConnectorFamily(), connector.getConnectorName(), + connector.getConnectorVersion(), json2Map(connector.getConnectorConfiguration())); + return Optional.ofNullable( + recordIterator.hasNext() ? recordIterator.next() : null); } private Map json2Map(final String json) { @@ -178,8 +224,7 @@ protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConf factory.newEntryBuilder().withName(ENTRY_CONNECTOR_CLASSLOADER).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_CLAZZ_CLASSLOADER).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_FROM_LOCATION).withType(Type.STRING).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_TCK_CONTAINER).withType(Type.BOOLEAN).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_LOADED_IN_TCK).withType(Type.BOOLEAN).build()); + .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_TCK_CONTAINER).withType(Type.BOOLEAN).build()); if (dynamicDependencyConfig.isEnvironmentInformation()) { builder = builder @@ -193,6 +238,10 @@ protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConf return builder.build(); } + protected Iterator loadData(final String family, final String name, final int version, + final Map parameters) { + return finder.find(family, name, version, parameters); + } private void manageException(final boolean dieOnError, final String message, final Exception e) { String msg = "Dynamic dependencies connector raised an exception: %s : %s".formatted(message, e.getMessage()); @@ -202,11 +251,75 @@ private void manageException(final boolean dieOnError, final String message, fin } } - protected List getDynamicDependencies(final List dependencies) { - return dependencies + protected List getDynamicDependencies(final List dependencies, + final List connectors) { + List standardDependencies = dependencies .stream() .map(d -> String.format("%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion())) .toList(); + + List additionalConnectors = connectors + .stream() + .map(c -> String.format("%s:%s:%s", c.getGroupId(), c.getArtifactId(), c.getVersion())) + .toList(); + + List connectorsDependencies = connectors + .stream() + .flatMap(this::getConnectorDependencies) + .toList(); + List all = Stream.of(standardDependencies, additionalConnectors, connectorsDependencies) + .flatMap(Collection::stream) + .toList(); + + if (log.isInfoEnabled()) { + String collect = all.stream().collect(Collectors.joining("\n- ", "- ", "")); + log.info("All identified dependencies:\n" + collect); + } + return all; + } + + private Stream getConnectorDependencies(final Connector connector) { + if (!connector.isLoadTransitiveDependencies()) { + return Stream.empty(); + } + + List result; + + String gav = String.format("%s:%s:%s", connector.getGroupId(), + connector.getArtifactId(), + connector.getVersion()); + Collection jarFiles = resolver.resolveFromDescriptor( + Collections.singletonList(gav)); + + if (jarFiles == null || jarFiles.size() <= 0) { + throw new ComponentException("Can't find additional connector '%s'.".formatted(gav)); + } + if (jarFiles.size() > 1) { + String join = jarFiles.stream().map(File::getAbsolutePath).collect(Collectors.joining(",")); + throw new ComponentException("Several files have been found to resolve '%s': %s".formatted(gav, join)); + } + + File jarFile = jarFiles.iterator().next(); + + try (JarFile jar = new JarFile(jarFile)) { + JarEntry entry = jar.getJarEntry("TALEND-INF/dependencies.txt"); + if (entry == null) { + throw new ComponentException("TALEND-INF/dependencies.txt not found in JAR"); + } + + try (InputStream is = jar.getInputStream(entry); + BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { + + result = reader.lines() + .filter(line -> !line.isBlank()) // skip empty lines + .map(line -> line.substring(0, line.lastIndexOf(":"))) // remove last ':xxx' + .collect(Collectors.toList()); + } + + } catch (IOException e) { + throw new ComponentException("Can't load dependencies for %s: %s".formatted(gav, e.getMessage()), e); + } + return result.stream(); } /** diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java index 9b91a834e53ce..535e4b06acd90 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Config.java @@ -22,6 +22,7 @@ import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.annotation.DynamicDependencySupported; @@ -65,4 +66,9 @@ public List getDependencies() { return new ArrayList<>(this.getSubConfig().getDependencies()); } + @Override + public List getConnectors() { + return new ArrayList<>(this.getSubConfig().getConnectors()); + } + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java index 46f239e54a2d7..97b8a8db6fb0a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/SubConfig.java @@ -22,13 +22,15 @@ import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import lombok.Data; @Data @GridLayout({ - @GridLayout.Row({ "dependencies" }) + @GridLayout.Row({ "dependencies" }), + @GridLayout.Row({ "connectors" }) }) public class SubConfig implements Serializable { @@ -36,4 +38,8 @@ public class SubConfig implements Serializable { @Documentation("The dependencies to load dynamically.") private List dependencies = new ArrayList<>(); + @Option + @Documentation("The connectors to load dynamically.") + private List connectors = new ArrayList<>(); + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java index 4c7bca6b14018..a71a02df2646e 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java @@ -54,7 +54,7 @@ public class DynamicDependenciesDataprepRunAnnotationService extends AbstractDyn @DynamicDependencies(DEPENDENCY_ACTION) public List getDynamicDependencies(@Option("theConfig") final Config config) { - return super.getDynamicDependencies(config.getDependencies()); + return super.getDynamicDependencies(config.getDependencies(), config.getConnectors()); } @DiscoverSchemaExtended(DEPENDENCY_WITHDATAPREPRUN_ACTION) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties index 7705ca13b09f7..1b0eda6eb9634 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/config/Messages.properties @@ -20,4 +20,5 @@ Config.dse._displayName = Config.dieOnError._displayName = Die on error Config.environmentInformation._displayName = Environment information Config.subConfig._displayName = -SubConfig.dependencies._displayName = Dependencies \ No newline at end of file +SubConfig.dependencies._displayName = Dependencies +SubConfig.connectors._displayName = \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java index 3ef03c7172e60..95352ed168631 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java @@ -22,6 +22,7 @@ import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; @@ -58,4 +59,8 @@ public List getDependencies() { return new ArrayList<>(this.getDse().getDependencies()); } + public List getConnectors() { + return new ArrayList<>(this.getDse().getConnectors()); + } + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java index 59541a501f0f9..de1cd0b4ca719 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Dataset.java @@ -23,6 +23,7 @@ import org.talend.sdk.component.api.configuration.type.DataSet; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import lombok.Data; @@ -31,7 +32,8 @@ @DataSet("dyndepsdse") @GridLayout(value = { @GridLayout.Row({ "dso" }), - @GridLayout.Row({ "dependencies" }) + @GridLayout.Row({ "dependencies" }), + @GridLayout.Row({ "connectors" }) }) @GridLayout(names = GridLayout.FormType.ADVANCED, value = { @GridLayout.Row({ "dso" }) @@ -46,4 +48,8 @@ public class Dataset implements Serializable { @Documentation("The dependencies to load dynamically.") private List dependencies = new ArrayList<>(); + @Option + @Documentation("The connectors to load dynamically.") + private List connectors = new ArrayList<>(); + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetService.java index aadf3fcfeb374..a532095bcc62b 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetService.java @@ -37,7 +37,7 @@ public class DynamicDependenciesWithDatasetService extends AbstractDynamicDepend @DynamicDependencies() public List getDynamicDependencies(@Option("theDataset") final Dataset dataset) { - return super.getDynamicDependencies(dataset.getDependencies()); + return super.getDynamicDependencies(dataset.getDependencies(), dataset.getConnectors()); } @DiscoverSchemaExtended(DEPENDENCY_WITHDATASET_ACTION) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties index 37b3370e63193..42b990411eaf6 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Messages.properties @@ -18,4 +18,5 @@ Dataset.dso._displayName = Dataset.dependencies._displayName = Dependencies Config.dse._displayName = Config.dieOnError._displayName = Die on error -Config.environmentInformation._displayName = Environment information \ No newline at end of file +Config.environmentInformation._displayName = Environment information +Dataset.connectors._displayName = \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java index 13f6203f15f38..50b8591e816f3 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Config.java @@ -22,6 +22,7 @@ import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; @@ -58,4 +59,8 @@ public List getDependencies() { return new ArrayList<>(this.getDse().getDso().getDependencies()); } + public List getConnectors() { + return new ArrayList<>(this.getDse().getDso().getConnectors()); + } + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Datastore.java index dc789196d89d3..8218f4e27f7cc 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Datastore.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Datastore.java @@ -23,6 +23,7 @@ import org.talend.sdk.component.api.configuration.type.DataStore; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import lombok.Data; @@ -30,7 +31,8 @@ @Data @DataStore("dyndepsdso") @GridLayout({ - @GridLayout.Row({ "dependencies" }) + @GridLayout.Row({ "dependencies" }), + @GridLayout.Row({ "connectors" }) }) public class Datastore implements Serializable { @@ -38,4 +40,8 @@ public class Datastore implements Serializable { @Documentation("The dependencies to load dynamically.") private List dependencies = new ArrayList<>(); + @Option + @Documentation("The connectors to load dynamically.") + private List connectors = new ArrayList<>(); + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java index ff0247f3a7cee..ea08f69beb09c 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreService.java @@ -38,7 +38,7 @@ public class DynamicDependenciesWithDatastoreService extends AbstractDynamicDepe @DynamicDependencies() public List getDynamicDependencies(@Option("theDatastore") final Datastore datastore) { - return super.getDynamicDependencies(datastore.getDependencies()); + return super.getDynamicDependencies(datastore.getDependencies(), datastore.getConnectors()); } @DiscoverSchemaExtended(DEPENDENCY_WITHDATASTORE_ACTION) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties index 3e79ffdba2002..2a933f364e575 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/config/Messages.properties @@ -18,4 +18,5 @@ Datastore.dependencies._displayName = Dependences Dataset.dso._displayName = Config.dse._displayName = Config.dieOnError._displayName = Die on error -Config.environmentInformation._displayName = Environment information \ No newline at end of file +Config.environmentInformation._displayName = Environment information +Datastore.connectors._displayName = \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java index 5081fe4ced75a..cd2c88cbd673b 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Config.java @@ -22,6 +22,7 @@ import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; @@ -63,4 +64,8 @@ public List getDependencies() { return new ArrayList<>(this.getSubConfig().getDependencies()); } + public List getConnectors() { + return new ArrayList<>(this.getSubConfig().getConnectors()); + } + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java index 2693e8678b6eb..12efa3c258d42 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java @@ -23,6 +23,7 @@ import org.talend.sdk.component.api.configuration.type.DynamicDependenciesConfiguration; import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Connector; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import lombok.Data; @@ -30,7 +31,8 @@ @Data @DynamicDependenciesConfiguration @GridLayout({ - @GridLayout.Row({ "dependencies" }) + @GridLayout.Row({ "dependencies" }), + @GridLayout.Row({ "connectors" }) }) public class SubConfig implements Serializable { @@ -38,4 +40,8 @@ public class SubConfig implements Serializable { @Documentation("The dependencies to load dynamically.") private List dependencies = new ArrayList<>(); + @Option + @Documentation("The connectors to load dynamically.") + private List connectors = new ArrayList<>(); + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java index 9e7188b9a073f..a071430dd2819 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java @@ -38,7 +38,7 @@ public class DynamicDependenciesConfigurationService extends AbstractDynamicDepe @DynamicDependencies() public List getDynamicDependencies(@Option("theSubConfig") final SubConfig subConfig) { - return super.getDynamicDependencies(subConfig.getDependencies()); + return super.getDynamicDependencies(subConfig.getDependencies(), subConfig.getConnectors()); } @DiscoverSchemaExtended(DEPENDENCY_WITHDYNDEPSCONFIG_ACTION) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties index 7e328113b48b1..2585384578ebd 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/Messages.properties @@ -19,4 +19,5 @@ Config.dse._displayName = Config.dieOnError._displayName = Die on error Config.environmentInformation._displayName = Environment information Config.subConfig._displayName = -SubConfig.dependencies._displayName = Dependencies \ No newline at end of file +SubConfig.dependencies._displayName = Dependencies +SubConfig.connectors._displayName = \ No newline at end of file From caef44ada1874a367a94e9eddee315aa2f03d5d2 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Tue, 18 Nov 2025 10:33:54 +0800 Subject: [PATCH 22/41] rename --- ...enciesWithDataprepRunAnnotationInput.java} | 6 +-- ...endenciesDataprepRunAnnotationService.java | 42 ------------------- 2 files changed, 3 insertions(+), 45 deletions(-) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/{DynamicDependenciesWithDynamicDependenciesconfigurationInput.java => DynamicDependenciesWithDataprepRunAnnotationInput.java} (87%) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDataprepRunAnnotationInput.java similarity index 87% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDataprepRunAnnotationInput.java index fe0c9d93077c1..ba9b57aab7f1d 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDataprepRunAnnotationInput.java @@ -34,7 +34,7 @@ @Icon(value = Icon.IconType.CUSTOM, custom = "icon") @Emitter(name = "Input") @Documentation("Dynamic dependencies sample input connector.") -public class DynamicDependenciesWithDynamicDependenciesconfigurationInput extends AbstractDynamicDependenciesService +public class DynamicDependenciesWithDataprepRunAnnotationInput extends AbstractDynamicDependenciesService implements Serializable { private final Config config; @@ -43,8 +43,8 @@ public class DynamicDependenciesWithDynamicDependenciesconfigurationInput extend private Iterator recordIterator; - public DynamicDependenciesWithDynamicDependenciesconfigurationInput(final Config config, - final DynamicDependenciesDataprepRunAnnotationService service) { + public DynamicDependenciesWithDataprepRunAnnotationInput(final Config config, + final DynamicDependenciesDataprepRunAnnotationService service) { this.config = config; this.service = service; } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java index a71a02df2646e..77a6665284bba 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java @@ -62,46 +62,4 @@ public Schema guessSchema4Input(final @Option("configuration") Config config) { return super.buildSchema(config); } - protected boolean testLoadingData(final DynamicDependencyConfig dynamicDependencyConfig, final Dependency dependency) { - //if depend on tck connector, load this connector's depends in its dependencies.txt into subconfig. - //loadComponentDepends(dynamicDependencyConfig, dependency.getConnectorFamily() + ":" + dependency.getConnectorName()); - - //In junit, can only find one : test. - Iterator recordIterator = finder.find(dependency.getConnectorFamily(), dependency.getConnectorName(), - dependency.getConnectorVersion(), Collections.emptyMap()); - return recordIterator.hasNext(); - } - - protected Map loadComponentDepends(final DynamicDependencyConfig dynamicDependencyConfig, final String jarPath) { - Map configMap = new HashMap<>(); - SubConfig subConfig = ((Config)dynamicDependencyConfig).getSubConfig(); - final Path archive = FileSystems.getDefault().getPath(jarPath); - - if (!Files.exists(archive)) { - throw new IllegalArgumentException("--Dependency does not exist: '" + archive + "'"); - } - try (final JarFile file = new JarFile(archive.toFile()); - final InputStream stream = file.getInputStream(file.getEntry("TALEND-INF/dependencies.txt"))) { - final Properties properties = new Properties(); - properties.load(stream); - properties.stringPropertyNames().forEach(name -> { - configMap.put(name, properties.getProperty(name)); - addToDependList(subConfig, name, properties.getProperty(name)); - }); - return configMap; - } catch (final IOException e) { - throw new IllegalStateException(e); - } - } - - private static void addToDependList(final SubConfig subConfig, final String name, final String property) { - Dependency depend = new Dependency(); - depend.setArtifactId(name); - depend.setVersion("1.2"); - depend.setGroupId(property); - depend.setClazz("FromDependency"); - - subConfig.getDependencies().add(depend); - } - } \ No newline at end of file From 15c4e2dcb6790fb1e4e78e79e4f2ca84cd3f3483 Mon Sep 17 00:00:00 2001 From: yyin-talend Date: Tue, 18 Nov 2025 10:59:52 +0800 Subject: [PATCH 23/41] fix junit --- ...endenciesDataprepRunAnnotationService.java | 15 ---------- .../service/DataprepRunServiceTest.java | 30 +++++-------------- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java index 77a6665284bba..39f7e7ea4b08f 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationService.java @@ -15,31 +15,16 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.service; -import java.io.IOException; -import java.io.InputStream; import java.io.Serializable; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.jar.JarFile; import org.talend.sdk.component.api.configuration.Option; -import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.record.Schema; import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.api.service.dependency.DynamicDependencies; import org.talend.sdk.component.api.service.schema.DiscoverSchemaExtended; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; -import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.config.SubConfig; import lombok.extern.slf4j.Slf4j; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java index 0274477b61927..3c3a8918f2a57 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java @@ -19,7 +19,6 @@ import java.util.Iterator; import java.util.List; -import java.util.Map; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.talend.sdk.component.api.record.Record; @@ -53,15 +52,6 @@ void testloadIterator() { Assertions.assertFalse(result.hasNext()); } - @Test - void testLoadDependency() { - System.setProperty("talend.component.manager.m2.repository", "./lib/"); - - Map depends = getService().loadComponentDepends(config, "C:\\Users\\ODG\\.m2\\repository\\org\\talend\\components\\record-provider\\1.71.0-SNAPSHOT\\record-provider-1.71.0-SNAPSHOT.jar"); - Assertions.assertEquals(2, depends.size()); - - } - @Override protected Config buildConfig() { Config config = new Config(); @@ -86,19 +76,13 @@ protected List getDependList() { depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); depends.add(depend); - //for connector depend - Dependency depend2 = new Dependency(); - depend.setArtifactId("record-provider"); - depend.setVersion("1.71.0-SNAPSHOT"); - depend.setGroupId("org.talend.components"); - depend.setClazz("org.talend.components.recordprovider.source.GenericMapper"); - //set a TCK connector as one dependency for depend2. - depend.setConnectorFamily("JDBC"); - depend.setConnectorName("newjdbc"); - depend.setConnectorVersion(1); - depend.setConnectorConfiguration(""); - - depends.add(depend2); +// //for connector depend +// Dependency depend2 = new Dependency(); +// depend.setArtifactId("record-provider"); +// depend.setVersion("1.71.0-SNAPSHOT"); +// depend.setGroupId("org.talend.components"); +// depend.setClazz("org.talend.components.recordprovider.source.GenericMapper"); +// depends.add(depend2); return depends; } From 132e0d944168bea168167bddc81f98e39e101694 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Tue, 18 Nov 2025 18:34:58 +0100 Subject: [PATCH 24/41] fix(QTDI-1914): some refactoring. --- ...bstractDynamicDependenciesServiceTest.java | 8 +++-- .../pom.xml | 6 ---- ...denciesWithDataprepRunAnnotationInput.java | 2 +- ...ciesDataprepRunAnnotationServiceTest.java} | 34 +++++-------------- ...icDependenciesWithDatasetServiceTest.java} | 2 +- ...DependenciesWithDatastoreServiceTest.java} | 2 +- ...ynamicDependenciesConfigurationInput.java} | 10 +++--- ...namicependenciesConfigurationService.java} | 2 +- ...cependenciesConfigurationServiceTest.java} | 8 ++--- 9 files changed, 27 insertions(+), 47 deletions(-) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/{DataprepRunServiceTest.java => DynamicDependenciesDataprepRunAnnotationServiceTest.java} (74%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/{DatasetServiceTest.java => DynamicDependenciesWithDatasetServiceTest.java} (97%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/{DatastoreServiceTest.java => DynamicDependenciesWithDatastoreServiceTest.java} (97%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/{DynamicDependenciesWithDynamicDependenciesconfigurationInput.java => DynamicDependenciesWithDynamicDependenciesConfigurationInput.java} (86%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/{DynamicDependenciesConfigurationService.java => DynamicDependenciesWithDynamicependenciesConfigurationService.java} (94%) rename sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/{DynamicDependenciesConfigurationServiceTest.java => DynamicDependenciesWithDynamicependenciesConfigurationServiceTest.java} (86%) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java index 1056a5c81ccfd..270b228c525e1 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/AbstractDynamicDependenciesServiceTest.java @@ -32,15 +32,17 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency; import org.talend.sdk.component.sample.feature.dynamicdependencies.config.DynamicDependencyConfig; import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; +import lombok.Getter; + public abstract class AbstractDynamicDependenciesServiceTest { - protected C config; + @Getter + private C config; protected abstract C buildConfig(); @@ -73,7 +75,7 @@ protected List getDependList() { return depends; } - protected void assertRecord(Record record) { + private void assertRecord(Record record) { Assertions.assertNotNull(record); Assertions.assertEquals("org.apache.commons:commons-numbers-primes:1.2", record.getString(ENTRY_MAVEN)); Assertions.assertEquals( diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml index 75aeb389c1946..0f346b2da2be0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml @@ -47,12 +47,6 @@ 1.2 test - - org.talend.sdk.component - container-core - 1.86.0-SNAPSHOT - compile - diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDataprepRunAnnotationInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDataprepRunAnnotationInput.java index ba9b57aab7f1d..26ab1b60d7a09 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDataprepRunAnnotationInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/input/DynamicDependenciesWithDataprepRunAnnotationInput.java @@ -44,7 +44,7 @@ public class DynamicDependenciesWithDataprepRunAnnotationInput extends AbstractD private Iterator recordIterator; public DynamicDependenciesWithDataprepRunAnnotationInput(final Config config, - final DynamicDependenciesDataprepRunAnnotationService service) { + final DynamicDependenciesDataprepRunAnnotationService service) { this.config = config; this.service = service; } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationServiceTest.java similarity index 74% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationServiceTest.java index 3c3a8918f2a57..c1097e2960ddc 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DataprepRunServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDataprepRunAnnotation/service/DynamicDependenciesDataprepRunAnnotationServiceTest.java @@ -16,12 +16,8 @@ package org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation.service; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.service.Service; import org.talend.sdk.component.junit5.WithComponents; import org.talend.sdk.component.sample.feature.dynamicdependencies.AbstractDynamicDependenciesServiceTest; @@ -34,24 +30,12 @@ @Slf4j @WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withDataprepRunAnnotation") -public class DataprepRunServiceTest +public class DynamicDependenciesDataprepRunAnnotationServiceTest extends AbstractDynamicDependenciesServiceTest { @Service DynamicDependenciesDataprepRunAnnotationService dynamicDependenciesServiceService; - - @Test - void testloadIterator() { - System.setProperty("talend.component.manager.m2.repository", "./lib/"); - - final Iterator result = getService().loadIterator(config); - - Assertions.assertTrue(result.hasNext()); - this.assertRecord(result.next()); - Assertions.assertFalse(result.hasNext()); - } - @Override protected Config buildConfig() { Config config = new Config(); @@ -66,7 +50,7 @@ protected Config buildConfig() { return config; } - //use tck cnnector as dependency + // use tck cnnector as dependency protected List getDependList() { List depends = new ArrayList<>(); Dependency depend = new Dependency(); @@ -76,13 +60,13 @@ protected List getDependList() { depend.setClazz("org.apache.commons.numbers.primes.SmallPrimes"); depends.add(depend); -// //for connector depend -// Dependency depend2 = new Dependency(); -// depend.setArtifactId("record-provider"); -// depend.setVersion("1.71.0-SNAPSHOT"); -// depend.setGroupId("org.talend.components"); -// depend.setClazz("org.talend.components.recordprovider.source.GenericMapper"); -// depends.add(depend2); + // //for connector depend + // Dependency depend2 = new Dependency(); + // depend.setArtifactId("record-provider"); + // depend.setVersion("1.71.0-SNAPSHOT"); + // depend.setGroupId("org.talend.components"); + // depend.setClazz("org.talend.components.recordprovider.source.GenericMapper"); + // depends.add(depend2); return depends; } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java similarity index 97% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java index f4683eec8c6b2..1602ef1a7fa83 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DatasetServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/service/DynamicDependenciesWithDatasetServiceTest.java @@ -29,7 +29,7 @@ @Slf4j @WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdataset") -public class DatasetServiceTest +public class DynamicDependenciesWithDatasetServiceTest extends AbstractDynamicDependenciesServiceTest { @Service diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java similarity index 97% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java index af9ae9265de25..465e126902f54 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DatastoreServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/service/DynamicDependenciesWithDatastoreServiceTest.java @@ -29,7 +29,7 @@ @Slf4j @WithComponents(value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withdatastore") -public class DatastoreServiceTest +public class DynamicDependenciesWithDatastoreServiceTest extends AbstractDynamicDependenciesServiceTest { @Service diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesConfigurationInput.java similarity index 86% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesConfigurationInput.java index 921ed21d30f70..335322e79b7fb 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesconfigurationInput.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/input/DynamicDependenciesWithDynamicDependenciesConfigurationInput.java @@ -28,23 +28,23 @@ import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.sample.feature.dynamicdependencies.service.AbstractDynamicDependenciesService; import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.config.Config; -import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesConfigurationService; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration.service.DynamicDependenciesWithDynamicependenciesConfigurationService; @Version @Icon(value = Icon.IconType.CUSTOM, custom = "icon") @Emitter(name = "Input") @Documentation("Dynamic dependencies sample input connector.") -public class DynamicDependenciesWithDynamicDependenciesconfigurationInput extends AbstractDynamicDependenciesService +public class DynamicDependenciesWithDynamicDependenciesConfigurationInput extends AbstractDynamicDependenciesService implements Serializable { private final Config config; - private final DynamicDependenciesConfigurationService service; + private final DynamicDependenciesWithDynamicependenciesConfigurationService service; private Iterator recordIterator; - public DynamicDependenciesWithDynamicDependenciesconfigurationInput(final Config config, - final DynamicDependenciesConfigurationService service) { + public DynamicDependenciesWithDynamicDependenciesConfigurationInput(final Config config, + final DynamicDependenciesWithDynamicependenciesConfigurationService service) { this.config = config; this.service = service; } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicependenciesConfigurationService.java similarity index 94% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicependenciesConfigurationService.java index a071430dd2819..3d0057a5fafec 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicependenciesConfigurationService.java @@ -31,7 +31,7 @@ @Slf4j @Service -public class DynamicDependenciesConfigurationService extends AbstractDynamicDependenciesService +public class DynamicDependenciesWithDynamicependenciesConfigurationService extends AbstractDynamicDependenciesService implements Serializable { public final static String DEPENDENCY_WITHDYNDEPSCONFIG_ACTION = "DEPENDENCY_WITHDYNDEPSCONFIG_ACTION"; diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationServiceTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicependenciesConfigurationServiceTest.java similarity index 86% rename from sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationServiceTest.java rename to sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicependenciesConfigurationServiceTest.java index 69a385aee45e0..7b2bc3083c4a4 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesConfigurationServiceTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/service/DynamicDependenciesWithDynamicependenciesConfigurationServiceTest.java @@ -30,12 +30,12 @@ @Slf4j @WithComponents( value = "org.talend.sdk.component.sample.feature.dynamicdependencies.withDynamicDependenciesConfiguration") -public class DynamicDependenciesConfigurationServiceTest +public class DynamicDependenciesWithDynamicependenciesConfigurationServiceTest extends - AbstractDynamicDependenciesServiceTest { + AbstractDynamicDependenciesServiceTest { @Service - DynamicDependenciesConfigurationService dynamicDependenciesServiceService; + DynamicDependenciesWithDynamicependenciesConfigurationService dynamicDependenciesServiceService; @Override protected Config buildConfig() { @@ -52,7 +52,7 @@ protected Config buildConfig() { } @Override - protected DynamicDependenciesConfigurationService getService() { + protected DynamicDependenciesWithDynamicependenciesConfigurationService getService() { return dynamicDependenciesServiceService; } } \ No newline at end of file From 578c3389cbfc7d663585c97fb63b8e21f73ca114 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Tue, 25 Nov 2025 23:57:15 +0100 Subject: [PATCH 25/41] feat(QTDI-1914): Add a connector taht uses a SPI. --- .../classloader-test-library/pom.xml | 48 ++++++++++ .../StringMapProvider.java | 24 +++++ .../StringMapTransformer.java | 80 +++++++++++++++++ .../resource.properties | 16 ++++ .../classloader-test-spi/pom.xml | 56 ++++++++++++ .../StringMapProviderImpl.java | 35 ++++++++ .../CLASSLOADER-TEST-SPI/resource.properties | 16 ++++ ...s.classloadertestlibrary.StringMapProvider | 16 ++++ .../dynamic-dependencies-common/pom.xml | 58 ++++++------ .../pom.xml | 7 +- .../dynamic-dependencies-with-dataset/pom.xml | 7 +- .../pom.xml | 7 +- .../pom.xml | 7 +- .../dynamic-dependencies-with-spi/pom.xml | 66 ++++++++++++++ .../withspi/config/Config.java | 47 ++++++++++ .../withspi/config/Dataset.java | 46 ++++++++++ .../withspi/config/Datastore.java | 36 ++++++++ .../DynamicDependenciesWithSPIInput.java | 64 ++++++++++++++ .../withspi/package-info.java | 23 +++++ .../DynamicDependenciesWithSPIService.java | 88 +++++++++++++++++++ .../src/main/resources/icons/dark/icon.svg | 66 ++++++++++++++ .../src/main/resources/icons/light/icon.svg | 66 ++++++++++++++ .../withspi/Messages.properties | 19 ++++ .../withspi/config/Messages.properties | 22 +++++ .../withspi/input/Messages.properties | 17 ++++ .../src/main/resources/version.properties | 17 ++++ .../dynamic-dependencies/pom.xml | 10 +-- 27 files changed, 920 insertions(+), 44 deletions(-) create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapProvider.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/CLASSLOADER-TEST-LIBRARY/resource.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImpl.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Config.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Dataset.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Datastore.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInput.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/package-info.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/icons/dark/icon.svg create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/icons/light/icon.svg create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/Messages.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/version.properties diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml new file mode 100644 index 0000000000000..8358575457b4e --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + org.talend.sdk.samplefeature.dynamicdependencies + dynamic-dependencies + 1.86.0-SNAPSHOT + + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-library + + jar + Component Runtime :: Sample Feature @DynamicDependency :: a classloader test library + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dynamic.dependencies.classloadertestlibrary + + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapProvider.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapProvider.java new file mode 100644 index 0000000000000..7004bed056076 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapProvider.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary; + +import java.util.Map; + +public interface StringMapProvider { + + Map getMap(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java new file mode 100644 index 0000000000000..8e29acabcbd62 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java @@ -0,0 +1,80 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.function.BiFunction; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.talend.sdk.component.api.exception.ComponentException; + +public class StringMapTransformer { + + private final StringMapProvider stringMapProvider; + + public StringMapTransformer(final boolean failIfSeveralServicesFound) { + ServiceLoader serviceLoader = ServiceLoader.load(StringMapProvider.class); + + List stringMapProviderList = new ArrayList<>(); + serviceLoader.iterator().forEachRemaining(stringMapProviderList::add); + + if (stringMapProviderList.size() <= 0) { + throw new ComponentException("No %s service found.".formatted(StringMapProvider.class)); + } + + if (stringMapProviderList.size() > 1 && failIfSeveralServicesFound) { + String join = stringMapProviderList.stream() + .map(m -> m.getClass().getName()) + .collect(Collectors.joining("\n")); + throw new ComponentException("More than one %s service has been found: %s" + .formatted(StringMapProvider.class, join)); + } + + this.stringMapProvider = stringMapProviderList.get(0); + } + + public List transform(final BiFunction function) { + Map map = stringMapProvider.getMap(); + return map.entrySet() + .stream() + .map(e -> function.apply(e.getKey(), e.getValue())) + .toList(); + } + + public String getResourceContent() { + Stream resources = this.getClass().getClassLoader().resources("CLASSLOADER-TEST-SPI/resource.properties"); + return resources + .map(url -> { + try (InputStream is = url.openStream()) { + return new String(is.readAllBytes(), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }) + .filter(l -> !l.startsWith("#")) + .collect(Collectors.joining("\n")); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/CLASSLOADER-TEST-LIBRARY/resource.properties b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/CLASSLOADER-TEST-LIBRARY/resource.properties new file mode 100644 index 0000000000000..dfa17bc74aadd --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/CLASSLOADER-TEST-LIBRARY/resource.properties @@ -0,0 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.message=This is a resource file from classloader-test-library. \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml new file mode 100644 index 0000000000000..5bd2d3c7fe11b --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml @@ -0,0 +1,56 @@ + + + + 4.0.0 + + org.talend.sdk.samplefeature.dynamicdependencies + dynamic-dependencies + 1.86.0-SNAPSHOT + + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-spi + + jar + Component Runtime :: Sample Feature @DynamicDependency :: a spi service + + + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-library + ${project.version} + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + dynamic.dependencies.dynamicdependencyspi + + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImpl.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImpl.java new file mode 100644 index 0000000000000..fff9b1b8f7c05 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImpl.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi; + +import java.util.HashMap; +import java.util.Map; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider; + +public class StringMapProviderImpl implements StringMapProvider { + + @Override + public Map getMap() { + Map map = new HashMap<>(); + map.put("key1", "value1"); + map.put("key2", "value2"); + map.put("key3", "value3"); + map.put("key4", "value4"); + map.put("key5", "value5"); + return map; + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties new file mode 100644 index 0000000000000..1d5ecab5e0199 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties @@ -0,0 +1,16 @@ +<<<<<<<<<<<<<<<<<<# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example>>>>>>>>>>>>>>>>>> +org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi.message=This is a resource file from classloader-test-spi. \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider new file mode 100644 index 0000000000000..bc36faaceadbb --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider @@ -0,0 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi.StringMapProviderImpl \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index 4ce71b766be23..4808b23af757f 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -17,43 +17,49 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.talend.sdk.component + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies 1.86.0-SNAPSHOT - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common jar Component Runtime :: Sample Feature @DynamicDependency Common - - org.testcontainers - junit-jupiter - 1.21.3 - test - - - org.junit.jupiter - junit-jupiter - - - org.junit.jupiter - junit-jupiter-api - - - org.junit.platform - junit-platform-commons - - - junit - junit - - - + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-library + 1.86.0-SNAPSHOT + compile + + + org.testcontainers + junit-jupiter + 1.21.3 + test + + + org.junit.jupiter + junit-jupiter + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.platform + junit-platform-commons + + + junit + junit + + + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml index 0f346b2da2be0..80c0b8bc45460 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml @@ -17,24 +17,25 @@ 4.0.0 - org.talend.sdk.component + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies 1.86.0-SNAPSHOT + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-dataprepRunAnnotation jar Component Runtime :: Sample Feature @DynamicDependency with DataprepRun annotation - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common ${project.version} - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common ${project.version} test-jar diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index 0bd12a55f3bfa..6b8bbdadb1d7d 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -16,24 +16,25 @@ 4.0.0 - org.talend.sdk.component + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies 1.86.0-SNAPSHOT + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-dataset jar Component Runtime :: Sample Feature @DynamicDependency with Dataset - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common ${project.version} - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common ${project.version} test-jar diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml index d54c52653b059..a64addc4322ae 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml @@ -17,24 +17,25 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.talend.sdk.component + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies 1.86.0-SNAPSHOT + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-datastore jar Component Runtime :: Sample Feature @DynamicDependency with Datastore - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common ${project.version} - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common ${project.version} test-jar diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml index a97a22bbaa086..842ad3faa79b2 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml @@ -16,11 +16,12 @@ 4.0.0 - org.talend.sdk.component + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies 1.86.0-SNAPSHOT + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-dynamicDependenciesConfiguration jar Component Runtime :: Sample Feature @DynamicDependency with DynamicDependenciesConfiguration @@ -32,13 +33,13 @@ - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common ${project.version} - org.talend.sdk.sample + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common ${project.version} test-jar diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml new file mode 100644 index 0000000000000..485213f4ef979 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml @@ -0,0 +1,66 @@ + + + + 4.0.0 + + org.talend.sdk.samplefeature.dynamicdependencies + dynamic-dependencies + 1.86.0-SNAPSHOT + + + org.talend.sdk.samplefeature.dynamicdependencies + dynamic-dependencies-with-spi + jar + Component Runtime :: Sample Feature @DynamicDependency with spi + + + + org.talend.sdk.samplefeature.dynamicdependencies + dynamic-dependencies-common + ${project.version} + + + + org.talend.sdk.samplefeature.dynamicdependencies + dynamic-dependencies-common + ${project.version} + test-jar + test + + + + + + + src/main/resources + true + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.talend.sdk.component.dynamic.dependencies.withspi + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Config.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Config.java new file mode 100644 index 0000000000000..31b3b04ae1f03 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Config.java @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +/** + * For this sample, the same configuration is used for all connectors input/processor/output. + */ +@Data +@GridLayout({ + @GridLayout.Row({ "dse" }), +}) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dse" }), + @GridLayout.Row({ "dieOnError" }), +}) +public class Config implements Serializable { + + @Option + @Documentation("The dataset configuration.") + private Dataset dse = new Dataset(); + + @Option + @Documentation("If enable throw an exception for any error, if not just log the error.") + private boolean dieOnError = false; + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Dataset.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Dataset.java new file mode 100644 index 0000000000000..bbb28640b0c6b --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Dataset.java @@ -0,0 +1,46 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DataSet; +import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@DataSet("dyndepsdse") +@GridLayout(value = { + @GridLayout.Row({ "dso" }), + @GridLayout.Row({ "bbb" }), +}) +@GridLayout(names = GridLayout.FormType.ADVANCED, value = { + @GridLayout.Row({ "dso" }) +}) +public class Dataset implements Serializable { + + @Option + @Documentation("A datastore.") + private Datastore dso = new Datastore(); + + @Option + @Documentation("Xxxx xxx.") + private String bbb; + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Datastore.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Datastore.java new file mode 100644 index 0000000000000..91d74dac3fdb6 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Datastore.java @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.config; + +import java.io.Serializable; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.configuration.type.DataStore; +import org.talend.sdk.component.api.configuration.ui.layout.AutoLayout; +import org.talend.sdk.component.api.meta.Documentation; + +import lombok.Data; + +@Data +@DataStore("dyndepsdso") +@AutoLayout +public class Datastore implements Serializable { + + @Option + @Documentation("Xxxx xxx.") + private String aaa; + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInput.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInput.java new file mode 100644 index 0000000000000..3e26377bbed1c --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInput.java @@ -0,0 +1,64 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.input; + +import java.io.Serializable; +import java.util.Iterator; + +import javax.annotation.PostConstruct; + +import org.talend.sdk.component.api.component.Icon; +import org.talend.sdk.component.api.component.Version; +import org.talend.sdk.component.api.input.Emitter; +import org.talend.sdk.component.api.input.Producer; +import org.talend.sdk.component.api.meta.Documentation; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.config.Config; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.service.DynamicDependenciesWithSPIService; + +@Version +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +@Emitter(name = "Input") +@Documentation("Dynamic dependencies sample input connector.") +public class DynamicDependenciesWithSPIInput implements Serializable { + + private final Config config; + + private final DynamicDependenciesWithSPIService service; + + private Iterator recordIterator; + + public DynamicDependenciesWithSPIInput(final Config config, + final DynamicDependenciesWithSPIService service) { + this.config = config; + this.service = service; + } + + @PostConstruct + public void init() { + this.recordIterator = this.service.getRecordIterator(); + } + + @Producer + public Record next() { + if (recordIterator == null || !recordIterator.hasNext()) { + return null; + } + + return recordIterator.next(); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/package-info.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/package-info.java new file mode 100644 index 0000000000000..8f684f5ab8500 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/package-info.java @@ -0,0 +1,23 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Components( + family = "DynamicDependenciesWithSPI", + categories = "sample") +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi; + +import org.talend.sdk.component.api.component.Components; +import org.talend.sdk.component.api.component.Icon; \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java new file mode 100644 index 0000000000000..739a043507634 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.service; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + +import org.talend.sdk.component.api.configuration.Option; +import org.talend.sdk.component.api.exception.ComponentException; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.api.record.Schema; +import org.talend.sdk.component.api.service.Service; +import org.talend.sdk.component.api.service.dependency.DynamicDependencies; +import org.talend.sdk.component.api.service.record.RecordBuilderFactory; +import org.talend.sdk.component.api.service.schema.DiscoverSchema; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapTransformer; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.config.Dataset; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Service +public class DynamicDependenciesWithSPIService implements Serializable { + + private static String version; + + @Service + private RecordBuilderFactory recordBuilderFactory; + + @DynamicDependencies + public List getDynamicDependencies(@Option("theDataset") final Dataset dataset) { + String dep = "org.talend.sdk.samplefeature.dynamicdependencies:classloader-test-spi:" + + loadVersion(); + System.out.println("Dynamic dependency to load: " + dep); + return Collections.singletonList(dep); + } + + @DiscoverSchema("dyndepsdse") + public Schema guessSchema4Input(final @Option("configuration") Dataset dse) { + Iterator recordIterator = getRecordIterator(); + if (!recordIterator.hasNext()) { + throw new ComponentException("No data loaded from StringMapTransformer."); + } + + Record record = recordIterator.next(); + return record.getSchema(); + } + + public Iterator getRecordIterator() { + StringMapTransformer stringMapTransformer = new StringMapTransformer<>(true); + List records = stringMapTransformer + .transform((s1, s2) -> recordBuilderFactory.newRecordBuilder().withString(s1, s2).build()); + return records.iterator(); + } + + private static String loadVersion() { + if (version == null) { + try (InputStream is = DynamicDependenciesWithSPIService.class.getClassLoader() + .getResourceAsStream("version.properties")) { + Properties props = new Properties(); + props.load(is); + version = props.getProperty("version"); + } catch (IOException e) { + throw new ComponentException("Unable to load project version", e); + } + } + return version; + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/icons/dark/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/icons/dark/icon.svg new file mode 100644 index 0000000000000..3e6ba66a42db8 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/icons/dark/icon.svg @@ -0,0 +1,66 @@ + + + + + + DynamicDependenciesDataset + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/icons/light/icon.svg b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/icons/light/icon.svg new file mode 100644 index 0000000000000..3e6ba66a42db8 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/icons/light/icon.svg @@ -0,0 +1,66 @@ + + + + + + DynamicDependenciesDataset + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/Messages.properties new file mode 100644 index 0000000000000..07fabc121dc11 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/Messages.properties @@ -0,0 +1,19 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +DynamicDependenciesWithSPI.datastore.dyndepsdso._displayName = Datastore for dynamic dependencies With SPI +DynamicDependenciesWithSPI.dataset.dyndepsdse._displayName = Dataset for dynamic dependencies With SPI +DynamicDependenciesWithSPI.actions.schema.dyndepsdse._displayName = Dynamic dependencies With SPI discover schema \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Messages.properties new file mode 100644 index 0000000000000..a83b1f07a4954 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/config/Messages.properties @@ -0,0 +1,22 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +Dataset.dso._displayName = +Config.dse._displayName = +Config.dieOnError._displayName =Die on error +Datastore.aaa._displayName = +Dataset.bbb._displayName = +Datastore.aaa._placeholder = +Dataset.bbb._placeholder = \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/Messages.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/Messages.properties new file mode 100644 index 0000000000000..5d3c3478cce11 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/Messages.properties @@ -0,0 +1,17 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +DynamicDependenciesWithSPI.Input._displayName = Dynamic Dependencies With SPI Input \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/version.properties b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/version.properties new file mode 100644 index 0000000000000..c7c8d1f0f47db --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/version.properties @@ -0,0 +1,17 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example + +version=${project.version} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml index e354afee25ac0..209a16957fe6a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -23,6 +23,7 @@ 1.86.0-SNAPSHOT + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies pom @@ -33,6 +34,9 @@ dynamic-dependencies-with-datastore dynamic-dependencies-with-dynamicDependenciesConfiguration dynamic-dependencies-with-dataprepRunAnnotation + dynamic-dependencies-with-spi + classloader-test-library + classloader-test-spi @@ -42,12 +46,6 @@ ${project.version} test - \ No newline at end of file From 2dc763d210cdeaddf9c520649e680b59dc03dab2 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Wed, 26 Nov 2025 00:12:32 +0100 Subject: [PATCH 26/41] feat(QTDI-1914): remove unnecessary dependency. --- .../dynamic-dependencies-common/pom.xml | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index 4808b23af757f..7d89ca650c4c4 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -29,39 +29,6 @@ jar Component Runtime :: Sample Feature @DynamicDependency Common - - - org.talend.sdk.samplefeature.dynamicdependencies - classloader-test-library - 1.86.0-SNAPSHOT - compile - - - org.testcontainers - junit-jupiter - 1.21.3 - test - - - org.junit.jupiter - junit-jupiter - - - org.junit.jupiter - junit-jupiter-api - - - org.junit.platform - junit-platform-commons - - - junit - junit - - - - - From fabc2588659eee1c73cc56794116ad6c93791e02 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Wed, 26 Nov 2025 00:35:40 +0100 Subject: [PATCH 27/41] feat(QTDI-1914): Add a test on the spi. --- .../StringMapProviderImplTest.java | 40 +++++++++++++++++++ .../dynamic-dependencies-common/pom.xml | 13 ++++++ 2 files changed, 53 insertions(+) create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java new file mode 100644 index 0000000000000..4ae9547429e81 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapTransformer; + +class StringMapProviderImplTest { + + @Test + void testSPI() { + StringMapTransformer stringMapTransformer = new StringMapTransformer<>(true); + List transform = stringMapTransformer.transform((s1, s2) -> s1 + ":" + s2); + List sorted = new ArrayList<>(transform); + sorted.sort(String::compareTo); + String collect = String.join("/", sorted); + Assertions.assertEquals("key1:value1/key2:value2/key3:value3/key4:value4/key5:value5", + collect); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index 7d89ca650c4c4..f14a434b72623 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -29,6 +29,19 @@ jar Component Runtime :: Sample Feature @DynamicDependency Common + + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-library + ${project.version} + + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-spi + ${project.version} + + + From 15759e131dfde34cd04bf1a99920a23980532baa Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Wed, 26 Nov 2025 22:36:57 +0100 Subject: [PATCH 28/41] feat(QTDI-1914): Change the SPI interface and add a unit test. --- .../StringMapTransformer.java | 21 ++++--- ...ngMapProvider.java => StringProvider.java} | 6 +- ...viderImpl.java => StringProviderImpl.java} | 18 ++---- ...ies.classloadertestlibrary.StringProvider} | 2 +- .../StringMapProviderImplTest.java | 5 +- .../DynamicDependenciesWithSPIService.java | 2 +- .../DynamicDependenciesWithSPIInputTest.java | 57 +++++++++++++++++++ 7 files changed, 81 insertions(+), 30 deletions(-) rename sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/{StringMapProvider.java => StringProvider.java} (88%) rename sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/{StringMapProviderImpl.java => StringProviderImpl.java} (64%) rename sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/{org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider => org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider} (96%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java index 8e29acabcbd62..232f393df3eb2 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java @@ -22,9 +22,8 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.ServiceLoader; -import java.util.function.BiFunction; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -32,16 +31,16 @@ public class StringMapTransformer { - private final StringMapProvider stringMapProvider; + private final StringProvider stringMapProvider; public StringMapTransformer(final boolean failIfSeveralServicesFound) { - ServiceLoader serviceLoader = ServiceLoader.load(StringMapProvider.class); + ServiceLoader serviceLoader = ServiceLoader.load(StringProvider.class); - List stringMapProviderList = new ArrayList<>(); + List stringMapProviderList = new ArrayList<>(); serviceLoader.iterator().forEachRemaining(stringMapProviderList::add); if (stringMapProviderList.size() <= 0) { - throw new ComponentException("No %s service found.".formatted(StringMapProvider.class)); + throw new ComponentException("No SPI service found for %s.".formatted(StringProvider.class)); } if (stringMapProviderList.size() > 1 && failIfSeveralServicesFound) { @@ -49,17 +48,17 @@ public StringMapTransformer(final boolean failIfSeveralServicesFound) { .map(m -> m.getClass().getName()) .collect(Collectors.joining("\n")); throw new ComponentException("More than one %s service has been found: %s" - .formatted(StringMapProvider.class, join)); + .formatted(StringProvider.class, join)); } this.stringMapProvider = stringMapProviderList.get(0); } - public List transform(final BiFunction function) { - Map map = stringMapProvider.getMap(); - return map.entrySet() + public List transform(final Function function) { + List strings = stringMapProvider.getStrings(); + return strings .stream() - .map(e -> function.apply(e.getKey(), e.getValue())) + .map(function::apply) .toList(); } diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapProvider.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringProvider.java similarity index 88% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapProvider.java rename to sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringProvider.java index 7004bed056076..d45ded5e8bae8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapProvider.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringProvider.java @@ -15,10 +15,10 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary; -import java.util.Map; +import java.util.List; -public interface StringMapProvider { +public interface StringProvider { - Map getMap(); + List getStrings(); } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImpl.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringProviderImpl.java similarity index 64% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImpl.java rename to sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringProviderImpl.java index fff9b1b8f7c05..aa59002b0bf0e 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImpl.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringProviderImpl.java @@ -15,21 +15,15 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi; -import java.util.HashMap; -import java.util.Map; +import java.util.Arrays; +import java.util.List; -import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider; -public class StringMapProviderImpl implements StringMapProvider { +public class StringProviderImpl implements StringProvider { @Override - public Map getMap() { - Map map = new HashMap<>(); - map.put("key1", "value1"); - map.put("key2", "value2"); - map.put("key3", "value3"); - map.put("key4", "value4"); - map.put("key5", "value5"); - return map; + public List getStrings() { + return Arrays.asList("value1", "value2", "value3"); } } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider similarity index 96% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider rename to sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider index bc36faaceadbb..6a81451058bcf 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapProvider +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider @@ -13,4 +13,4 @@ # limitations under the License. # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi.StringMapProviderImpl \ No newline at end of file +org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi.StringProviderImpl \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java index 4ae9547429e81..f5a3a54c48f56 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Function; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -29,11 +30,11 @@ class StringMapProviderImplTest { @Test void testSPI() { StringMapTransformer stringMapTransformer = new StringMapTransformer<>(true); - List transform = stringMapTransformer.transform((s1, s2) -> s1 + ":" + s2); + List transform = stringMapTransformer.transform(Function.identity()); List sorted = new ArrayList<>(transform); sorted.sort(String::compareTo); String collect = String.join("/", sorted); - Assertions.assertEquals("key1:value1/key2:value2/key3:value3/key4:value4/key5:value5", + Assertions.assertEquals("value1/value2/value3", collect); } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java index 739a043507634..ec68fe6582b08 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java @@ -67,7 +67,7 @@ public Schema guessSchema4Input(final @Option("configuration") Dataset dse) { public Iterator getRecordIterator() { StringMapTransformer stringMapTransformer = new StringMapTransformer<>(true); List records = stringMapTransformer - .transform((s1, s2) -> recordBuilderFactory.newRecordBuilder().withString(s1, s2).build()); + .transform(s -> recordBuilderFactory.newRecordBuilder().withString("value", s).build()); return records.iterator(); } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java new file mode 100644 index 0000000000000..6bc91900cac36 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.input; + +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.api.record.Record; +import org.talend.sdk.component.junit.BaseComponentsHandler; +import org.talend.sdk.component.junit.SimpleFactory; +import org.talend.sdk.component.junit5.Injected; +import org.talend.sdk.component.junit5.WithComponents; +import org.talend.sdk.component.runtime.manager.chain.Job; +import org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.config.Config; + +@WithComponents("org.talend.sdk.component.sample.feature.dynamicdependencies.withspi") +class DynamicDependenciesWithSPIInputTest { + + @Injected + protected BaseComponentsHandler handler; + + @Test + public void testGeneratedRecord() { + Config config = new Config(); + String queryString = SimpleFactory.configurationByExample().forInstance(config).configured().toQueryString(); + + Job.components() + .component("input", "DynamicDependenciesWithSPI://Input?" + queryString) + .component("collector", "test://collector") + .connections() + .from("input") + .to("collector") + .build() + .run(); + + List collectedData = handler.getCollectedData(Record.class); + Assertions.assertEquals(3, collectedData.size()); + Assertions.assertEquals("value1", collectedData.get(0).getString("value")); + Assertions.assertEquals("value2", collectedData.get(1).getString("value")); + Assertions.assertEquals("value3", collectedData.get(2).getString("value")); + } + +} \ No newline at end of file From bc2ded478324f75e3d425c4bb106a49bf8cc7660 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Wed, 26 Nov 2025 22:51:15 +0100 Subject: [PATCH 29/41] feat(QTDI-1914): Update pom version in dynamic-dependencies modules. --- sample-parent/sample-features/dynamic-dependencies/README.md | 5 ++--- .../dynamic-dependencies/classloader-test-library/pom.xml | 2 +- .../dynamic-dependencies/classloader-test-spi/pom.xml | 2 +- .../dynamic-dependencies/dynamic-dependencies-common/pom.xml | 2 +- .../dynamic-dependencies-with-dataprepRunAnnotation/pom.xml | 2 +- .../dynamic-dependencies-with-dataset/pom.xml | 2 +- .../dynamic-dependencies-with-datastore/pom.xml | 2 +- .../pom.xml | 2 +- .../dynamic-dependencies-with-spi/pom.xml | 2 +- sample-parent/sample-features/dynamic-dependencies/pom.xml | 2 +- 10 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/README.md b/sample-parent/sample-features/dynamic-dependencies/README.md index aff3dac7f1be4..e13a0d5c5e064 100644 --- a/sample-parent/sample-features/dynamic-dependencies/README.md +++ b/sample-parent/sample-features/dynamic-dependencies/README.md @@ -30,9 +30,8 @@ Alternatively build the feature module using `mvn install -am -pl :dynamicdepend ### How to use - Deploy the connector into Studio: -java -jar dynamic-dependencies-with-dataset-1.86.0-SNAPSHOT.car studio-deploy --location c:\Talend-Studio-20251010_0827-V8.0.2SNAPSHOT +java -jar dynamic-dependencies-with-dataset-x.y.z-SNAPSHOT.car studio-deploy --location c:\Talend-Studio-20251010_0827-V8.0.2SNAPSHOT - Use the connector in the job. - Click "Guess schema" of the connector. -- Add others you want to use in the job, then run the job. - +- Add others you want to use in the job, then run the job. \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml index 8358575457b4e..856dd4a180b5b 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml @@ -20,7 +20,7 @@ org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT org.talend.sdk.samplefeature.dynamicdependencies diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml index 5bd2d3c7fe11b..ff77d1ce82fc9 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml @@ -20,7 +20,7 @@ org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT org.talend.sdk.samplefeature.dynamicdependencies diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index f14a434b72623..cb4d0baac6a3b 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -19,7 +19,7 @@ org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml index 80c0b8bc45460..99f1de33a2b9a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml @@ -19,7 +19,7 @@ org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT org.talend.sdk.samplefeature.dynamicdependencies diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index 6b8bbdadb1d7d..e4025b41ee4f6 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -18,7 +18,7 @@ org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT org.talend.sdk.samplefeature.dynamicdependencies diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml index a64addc4322ae..bfa6379243909 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml @@ -19,7 +19,7 @@ org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT org.talend.sdk.samplefeature.dynamicdependencies diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml index 842ad3faa79b2..c458e84c4506c 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml @@ -18,7 +18,7 @@ org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT org.talend.sdk.samplefeature.dynamicdependencies diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml index 485213f4ef979..351d3b510256e 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml @@ -18,7 +18,7 @@ org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT org.talend.sdk.samplefeature.dynamicdependencies diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml index 209a16957fe6a..d1092ead9f6c1 100644 --- a/sample-parent/sample-features/dynamic-dependencies/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -20,7 +20,7 @@ org.talend.sdk.component sample-features - 1.86.0-SNAPSHOT + 1.88.0-SNAPSHOT org.talend.sdk.samplefeature.dynamicdependencies From d282b186d3bab2bb6830f3751c83925116d04fff Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 27 Nov 2025 14:20:28 +0100 Subject: [PATCH 30/41] feat(QTDI-1914): Clean pom.xml in dynamic-dependencies sample module. --- .../dynamic-dependencies-common/pom.xml | 13 ------------- .../dynamic-dependencies-with-spi/pom.xml | 9 ++++++--- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index cb4d0baac6a3b..023b5246e1816 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -29,19 +29,6 @@ jar Component Runtime :: Sample Feature @DynamicDependency Common - - - org.talend.sdk.samplefeature.dynamicdependencies - classloader-test-library - ${project.version} - - - org.talend.sdk.samplefeature.dynamicdependencies - classloader-test-spi - ${project.version} - - - diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml index 351d3b510256e..3db9e964b1a72 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml @@ -32,12 +32,15 @@ dynamic-dependencies-common ${project.version} - org.talend.sdk.samplefeature.dynamicdependencies - dynamic-dependencies-common + classloader-test-library + ${project.version} + + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-spi ${project.version} - test-jar test From 07e2722cbf1f38b16a3802df634bd78aa8d1b103 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 27 Nov 2025 16:23:26 +0100 Subject: [PATCH 31/41] feat(QTDI-1914): try to add a classloader customizer. --- .../dynamic-dependencies-with-spi/pom.xml | 12 ++++++-- .../withspi/service/CustomizeClassLoader.java | 29 +++++++++++++++++++ ...runtime.manager.ComponentManager$Customize | 0 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/CustomizeClassLoader.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customize diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml index 3db9e964b1a72..18386e8e6f801 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml @@ -13,7 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. --> - + 4.0.0 org.talend.sdk.samplefeature.dynamicdependencies @@ -27,6 +28,12 @@ Component Runtime :: Sample Feature @DynamicDependency with spi + + org.talend.sdk.component + component-runtime-manager + ${project.version} + provided + org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common @@ -59,7 +66,8 @@ - org.talend.sdk.component.dynamic.dependencies.withspi + org.talend.sdk.component.dynamic.dependencies.withspi + diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/CustomizeClassLoader.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/CustomizeClassLoader.java new file mode 100644 index 0000000000000..fcc8571fb8270 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/CustomizeClassLoader.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.service; + +import java.util.stream.Stream; + +import org.talend.sdk.component.runtime.manager.ComponentManager; + +public class CustomizeClassLoader implements ComponentManager.Customizer { + + @Override + public Stream containerClassesAndPackages() { + return Stream.of( + "org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider"); + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customize b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customize new file mode 100644 index 0000000000000..e69de29bb2d1d From 208067ae8b860c7330da135d09947e70bf87678f Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 27 Nov 2025 17:00:06 +0100 Subject: [PATCH 32/41] feat(QTDI-1914): Fix customizer SPI resource file. --- ...lend.sdk.component.runtime.manager.ComponentManager$Customize | 0 ...end.sdk.component.runtime.manager.ComponentManager$Customizer | 1 + 2 files changed, 1 insertion(+) delete mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customize create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customize b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customize deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer new file mode 100644 index 0000000000000..5f7ce3b1beea4 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer @@ -0,0 +1 @@ +org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.service.CustomizeClassLoader \ No newline at end of file From 646d9ab6697edb023c20646b6a968c16429fbdc1 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 27 Nov 2025 17:26:06 +0100 Subject: [PATCH 33/41] feat(QTDI-1914): Add some resources to be loaded. --- .../MULTIPLE_RESOURCE/common.properties | 1 + .../CLASSLOADER-TEST-SPI/resource.properties | 2 +- .../MULTIPLE_RESOURCE/common.properties | 1 + .../DynamicDependenciesWithSPIService.java | 51 ++++++++++++++++++- ...untime.manager.ComponentManager$Customizer | 1 - 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/MULTIPLE_RESOURCE/common.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties delete mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/MULTIPLE_RESOURCE/common.properties b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/MULTIPLE_RESOURCE/common.properties new file mode 100644 index 0000000000000..416a8adeb83ad --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/MULTIPLE_RESOURCE/common.properties @@ -0,0 +1 @@ +content=from dependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties index 1d5ecab5e0199..a0602276759b4 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties @@ -1,4 +1,4 @@ -<<<<<<<<<<<<<<<<<<# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties new file mode 100644 index 0000000000000..7a069e5a6bc52 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties @@ -0,0 +1 @@ +content=from dynamic dependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java index ec68fe6582b08..8200ae5fc8280 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java @@ -18,7 +18,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.Serializable; +import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Collections; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Properties; @@ -65,9 +68,55 @@ public Schema guessSchema4Input(final @Option("configuration") Dataset dse) { } public Iterator getRecordIterator() { + String contentFromResourceDependency; + try (InputStream resourceStreamFromDependency = DynamicDependenciesWithSPIService.class.getClassLoader() + .getResourceAsStream("CLASSLOADER-TEST-LIBRARY/resource.properties")) { + contentFromResourceDependency = + new String(resourceStreamFromDependency.readAllBytes(), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new ComponentException("Can't retrieve resource from a dependency.", e); + } + + String contentFromResourceDynamicDependency; + try (InputStream resourceStreamFromDynamicDependency = DynamicDependenciesWithSPIService.class.getClassLoader() + .getResourceAsStream("CLASSLOADER-TEST-SPI/resource.properties")) { + contentFromResourceDynamicDependency = + new String(resourceStreamFromDynamicDependency.readAllBytes(), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new ComponentException("Can't retrieve resource from a dependency.", e); + } + + String contentFromMultipleResrouces; + try { + boolean isFirst = true; + Enumeration resources = DynamicDependenciesWithSPIService.class.getClassLoader() + .getResources("MULTIPLE_RESOURCE/common.properties"); + + StringBuilder stringBuilder = new StringBuilder(); + while (resources.hasMoreElements()) { + URL url = resources.nextElement(); + + try (InputStream is = url.openStream()) { + String content = new String(is.readAllBytes(), StandardCharsets.UTF_8); + stringBuilder.append(isFirst ? "" : System.lineSeparator()); + stringBuilder.append(content); + isFirst = false; + } + } + contentFromMultipleResrouces = stringBuilder.toString(); + + } catch (IOException e) { + throw new ComponentException("Can't retrieve multiple resources at once.", e); + } + StringMapTransformer stringMapTransformer = new StringMapTransformer<>(true); List records = stringMapTransformer - .transform(s -> recordBuilderFactory.newRecordBuilder().withString("value", s).build()); + .transform(s -> recordBuilderFactory.newRecordBuilder() + .withString("value", s) + .withString("contentFromResourceDependency", contentFromResourceDependency) + .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) + .withString("contentFromMultipleResrouces", contentFromMultipleResrouces) + .build()); return records.iterator(); } diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer deleted file mode 100644 index 5f7ce3b1beea4..0000000000000 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer +++ /dev/null @@ -1 +0,0 @@ -org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.service.CustomizeClassLoader \ No newline at end of file From cad91324f11d62e6ee602a0ab6e98ef3ad21fa64 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 27 Nov 2025 17:45:05 +0100 Subject: [PATCH 34/41] feat(QTDI-1914): Add multiple resources load. --- .../MULTIPLE_RESOURCE/common.properties | 15 +++++++++++++++ .../CLASSLOADER-TEST-SPI/resource.properties | 2 +- .../MULTIPLE_RESOURCE/common.properties | 15 +++++++++++++++ .../DynamicDependenciesWithSPIService.java | 17 +++++++++++------ 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/MULTIPLE_RESOURCE/common.properties b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/MULTIPLE_RESOURCE/common.properties index 416a8adeb83ad..80e0e08d4ada1 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/MULTIPLE_RESOURCE/common.properties +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/resources/MULTIPLE_RESOURCE/common.properties @@ -1 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example content=from dependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties index a0602276759b4..82a427b40e5a2 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties @@ -12,5 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. # Here you can change all your configuration display names to use more explicit labels -# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example>>>>>>>>>>>>>>>>>> +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi.message=This is a resource file from classloader-test-spi. \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties index 7a069e5a6bc52..c130ce1b42e6f 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties @@ -1 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example content=from dynamic dependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java index 8200ae5fc8280..0ee0f6f3cffae 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java @@ -15,8 +15,10 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.service; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.Serializable; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -86,7 +88,7 @@ public Iterator getRecordIterator() { throw new ComponentException("Can't retrieve resource from a dependency.", e); } - String contentFromMultipleResrouces; + String contentFromMultipleResources; try { boolean isFirst = true; Enumeration resources = DynamicDependenciesWithSPIService.class.getClassLoader() @@ -97,14 +99,17 @@ public Iterator getRecordIterator() { URL url = resources.nextElement(); try (InputStream is = url.openStream()) { - String content = new String(is.readAllBytes(), StandardCharsets.UTF_8); stringBuilder.append(isFirst ? "" : System.lineSeparator()); - stringBuilder.append(content); + BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); + reader.lines() + .filter(line -> !line.trim().startsWith("#")) + .filter(line -> !line.trim().isEmpty()) + .forEach(stringBuilder::append); + reader.close(); isFirst = false; } } - contentFromMultipleResrouces = stringBuilder.toString(); - + contentFromMultipleResources = stringBuilder.toString(); } catch (IOException e) { throw new ComponentException("Can't retrieve multiple resources at once.", e); } @@ -115,7 +120,7 @@ public Iterator getRecordIterator() { .withString("value", s) .withString("contentFromResourceDependency", contentFromResourceDependency) .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) - .withString("contentFromMultipleResrouces", contentFromMultipleResrouces) + .withString("contentFromMultipleResources", contentFromMultipleResources) .build()); return records.iterator(); } From e94f6ceac5cdc02a32a3cb86787c1c2cdda84ce0 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Fri, 28 Nov 2025 15:31:58 +0100 Subject: [PATCH 35/41] feat(QTDI-1914): Add SPI resource for classloader customizer. --- ...end.sdk.component.runtime.manager.ComponentManager$Customizer | 1 + 1 file changed, 1 insertion(+) create mode 100644 sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer new file mode 100644 index 0000000000000..5f7ce3b1beea4 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/resources/META-INF/services/org.talend.sdk.component.runtime.manager.ComponentManager$Customizer @@ -0,0 +1 @@ +org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.service.CustomizeClassLoader \ No newline at end of file From 08548c96a1264752d2d03afcc70661fb7324f8c9 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Fri, 28 Nov 2025 15:43:07 +0100 Subject: [PATCH 36/41] feat(QTDI-1914): Rename StringMapTransformer t o StringListTransformer. --- ...ringMapTransformer.java => StringListTransformer.java} | 4 ++-- .../classloadertestspi/StringMapProviderImplTest.java | 8 +++----- .../service/DynamicDependenciesWithSPIService.java | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) rename sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/{StringMapTransformer.java => StringListTransformer.java} (96%) diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringListTransformer.java similarity index 96% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java rename to sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringListTransformer.java index 232f393df3eb2..a219849bef3ac 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringMapTransformer.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringListTransformer.java @@ -29,11 +29,11 @@ import org.talend.sdk.component.api.exception.ComponentException; -public class StringMapTransformer { +public class StringListTransformer { private final StringProvider stringMapProvider; - public StringMapTransformer(final boolean failIfSeveralServicesFound) { + public StringListTransformer(final boolean failIfSeveralServicesFound) { ServiceLoader serviceLoader = ServiceLoader.load(StringProvider.class); List stringMapProviderList = new ArrayList<>(); diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java index f5a3a54c48f56..06d865cc4140a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java @@ -15,22 +15,20 @@ */ package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi; -import static org.junit.jupiter.api.Assertions.*; - import java.util.ArrayList; import java.util.List; import java.util.function.Function; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapTransformer; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringListTransformer; class StringMapProviderImplTest { @Test void testSPI() { - StringMapTransformer stringMapTransformer = new StringMapTransformer<>(true); - List transform = stringMapTransformer.transform(Function.identity()); + StringListTransformer stringListTransformer = new StringListTransformer<>(true); + List transform = stringListTransformer.transform(Function.identity()); List sorted = new ArrayList<>(transform); sorted.sort(String::compareTo); String collect = String.join("/", sorted); diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java index 0ee0f6f3cffae..3663aa807b914 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java @@ -36,7 +36,7 @@ import org.talend.sdk.component.api.service.dependency.DynamicDependencies; import org.talend.sdk.component.api.service.record.RecordBuilderFactory; import org.talend.sdk.component.api.service.schema.DiscoverSchema; -import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringMapTransformer; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringListTransformer; import org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.config.Dataset; import lombok.extern.slf4j.Slf4j; @@ -114,8 +114,8 @@ public Iterator getRecordIterator() { throw new ComponentException("Can't retrieve multiple resources at once.", e); } - StringMapTransformer stringMapTransformer = new StringMapTransformer<>(true); - List records = stringMapTransformer + StringListTransformer stringListTransformer = new StringListTransformer<>(true); + List records = stringListTransformer .transform(s -> recordBuilderFactory.newRecordBuilder() .withString("value", s) .withString("contentFromResourceDependency", contentFromResourceDependency) From 2d946605408627099973c1b69cd0db47a661954f Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Mon, 1 Dec 2025 19:05:52 +0100 Subject: [PATCH 37/41] feat(QTDI-1914): Refactoring + external dependency. --- .../classloader-test-library/pom.xml | 1 - .../StringsProviderFromExternalSPI.java} | 11 +- .../StringsProviderSPIAsDependency.java} | 6 +- ...StringsProviderSPIAsDynamicDependency.java | 24 +++++ .../AbstractSPIConsumer.java} | 42 +++----- .../spiConsumers/DependencySPIConsumer.java | 32 ++++++ .../DynamicDependencySPIConsumer.java | 32 ++++++ .../ExternalDependencySPIConsumer.java | 32 ++++++ .../dynamic-dependencies-common/pom.xml | 1 - .../pom.xml | 1 - .../dynamic-dependencies-with-dataset/pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../dynamic-dependencies-with-spi/pom.xml | 14 ++- .../withspi/service/CustomizeClassLoader.java | 5 +- .../DynamicDependenciesWithSPIService.java | 102 +++++++++++++----- .../DynamicDependenciesWithSPIInputTest.java | 22 +++- .../dynamic-dependencies/pom.xml | 4 +- .../service-provider-from-dependency/pom.xml | 55 ++++++++++ .../ServiceProviderFromDependency.java | 33 ++++++ .../FROM_DEPENDENCY/resource.properties} | 2 +- ...eInterfaces.StringsProviderSPIAsDependency | 16 +++ .../MULTIPLE_RESOURCE/common.properties | 16 +++ .../ServiceProviderFromDependencyTest.java} | 14 +-- .../pom.xml | 7 +- .../ServiceProviderFromDynamicDependency.java | 33 ++++++ .../resource.properties | 2 +- ...aces.StringsProviderSPIAsDynamicDependency | 16 +++ .../MULTIPLE_RESOURCE/common.properties | 0 .../ServiceProviderFromDependencyTest.java | 40 +++++++ .../pom.xml | 55 ++++++++++ ...ServiceProviderFromExternalDependency.java | 33 ++++++ .../resource.properties | 16 +++ ...eInterfaces.StringsProviderFromExternalSPI | 16 +++ .../MULTIPLE_RESOURCE/common.properties | 16 +++ ...iceProviderFromExternalDependencyTest.java | 39 +++++++ 36 files changed, 647 insertions(+), 94 deletions(-) rename sample-parent/sample-features/dynamic-dependencies/{classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringProviderImpl.java => classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderFromExternalSPI.java} (68%) rename sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/{StringProvider.java => serviceInterfaces/StringsProviderSPIAsDependency.java} (83%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderSPIAsDynamicDependency.java rename sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/{StringListTransformer.java => spiConsumers/AbstractSPIConsumer.java} (54%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/DependencySPIConsumer.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/DynamicDependencySPIConsumer.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/ExternalDependencySPIConsumer.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdependency/ServiceProviderFromDependency.java rename sample-parent/sample-features/dynamic-dependencies/{classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider => service-provider-from-dependency/src/main/resources/FROM_DEPENDENCY/resource.properties} (89%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDependency create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties rename sample-parent/sample-features/dynamic-dependencies/{classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java => service-provider-from-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdependency/ServiceProviderFromDependencyTest.java} (69%) rename sample-parent/sample-features/dynamic-dependencies/{classloader-test-spi => service-provider-from-dynamic-dependency}/pom.xml (86%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdynamicdependency/ServiceProviderFromDynamicDependency.java rename sample-parent/sample-features/dynamic-dependencies/{classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI => service-provider-from-dynamic-dependency/src/main/resources/FROM_DYNAMIC_DEPENDENCY}/resource.properties (85%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDynamicDependency rename sample-parent/sample-features/dynamic-dependencies/{classloader-test-spi => service-provider-from-dynamic-dependency}/src/main/resources/MULTIPLE_RESOURCE/common.properties (100%) create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdynamicdependency/ServiceProviderFromDependencyTest.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/pom.xml create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromexternaldependency/ServiceProviderFromExternalDependency.java create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/FROM_EXTERNAL_DEPENDENCY/resource.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderFromExternalSPI create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties create mode 100644 sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromexternaldependency/ServiceProviderFromExternalDependencyTest.java diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml index 856dd4a180b5b..ab792bf04f8d7 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/pom.xml @@ -23,7 +23,6 @@ 1.88.0-SNAPSHOT - org.talend.sdk.samplefeature.dynamicdependencies classloader-test-library jar diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringProviderImpl.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderFromExternalSPI.java similarity index 68% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringProviderImpl.java rename to sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderFromExternalSPI.java index aa59002b0bf0e..5943c646f6631 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringProviderImpl.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderFromExternalSPI.java @@ -13,17 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi; +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces; -import java.util.Arrays; import java.util.List; -import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider; +public interface StringsProviderFromExternalSPI { -public class StringProviderImpl implements StringProvider { + List getStringsFromExternalSPI(); - @Override - public List getStrings() { - return Arrays.asList("value1", "value2", "value3"); - } } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringProvider.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderSPIAsDependency.java similarity index 83% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringProvider.java rename to sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderSPIAsDependency.java index d45ded5e8bae8..f9613bf474586 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringProvider.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderSPIAsDependency.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary; +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces; import java.util.List; -public interface StringProvider { +public interface StringsProviderSPIAsDependency { - List getStrings(); + List getStringsFromDependency(); } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderSPIAsDynamicDependency.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderSPIAsDynamicDependency.java new file mode 100644 index 0000000000000..f0ec46aea1478 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/serviceInterfaces/StringsProviderSPIAsDynamicDependency.java @@ -0,0 +1,24 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces; + +import java.util.List; + +public interface StringsProviderSPIAsDynamicDependency { + + List getStringsFromASPIAsDynamicDependency(); + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringListTransformer.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/AbstractSPIConsumer.java similarity index 54% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringListTransformer.java rename to sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/AbstractSPIConsumer.java index a219849bef3ac..57d74a366415e 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/StringListTransformer.java +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/AbstractSPIConsumer.java @@ -13,34 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary; +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers; -import java.io.IOException; -import java.io.InputStream; -import java.io.UncheckedIOException; -import java.net.URL; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.ServiceLoader; import java.util.function.Function; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.talend.sdk.component.api.exception.ComponentException; -public class StringListTransformer { +public abstract class AbstractSPIConsumer { - private final StringProvider stringMapProvider; + private final S spiImpl; - public StringListTransformer(final boolean failIfSeveralServicesFound) { - ServiceLoader serviceLoader = ServiceLoader.load(StringProvider.class); + protected AbstractSPIConsumer(final Class clazz, final boolean failIfSeveralServicesFound) { + ServiceLoader serviceLoader = ServiceLoader.load(clazz); - List stringMapProviderList = new ArrayList<>(); + List stringMapProviderList = new ArrayList<>(); serviceLoader.iterator().forEachRemaining(stringMapProviderList::add); if (stringMapProviderList.size() <= 0) { - throw new ComponentException("No SPI service found for %s.".formatted(StringProvider.class)); + throw new ComponentException("No SPI service found for %s.".formatted(clazz)); } if (stringMapProviderList.size() > 1 && failIfSeveralServicesFound) { @@ -48,32 +42,24 @@ public StringListTransformer(final boolean failIfSeveralServicesFound) { .map(m -> m.getClass().getName()) .collect(Collectors.joining("\n")); throw new ComponentException("More than one %s service has been found: %s" - .formatted(StringProvider.class, join)); + .formatted(clazz, join)); } - this.stringMapProvider = stringMapProviderList.get(0); + this.spiImpl = stringMapProviderList.get(0); } + public abstract List getValues(); + public List transform(final Function function) { - List strings = stringMapProvider.getStrings(); + List strings = this.getValues(); return strings .stream() .map(function::apply) .toList(); } - public String getResourceContent() { - Stream resources = this.getClass().getClassLoader().resources("CLASSLOADER-TEST-SPI/resource.properties"); - return resources - .map(url -> { - try (InputStream is = url.openStream()) { - return new String(is.readAllBytes(), StandardCharsets.UTF_8); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - }) - .filter(l -> !l.startsWith("#")) - .collect(Collectors.joining("\n")); + public S getSPIImpl() { + return this.spiImpl; } } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/DependencySPIConsumer.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/DependencySPIConsumer.java new file mode 100644 index 0000000000000..c914853ab410f --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/DependencySPIConsumer.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers; + +import java.util.List; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDependency; + +public class DependencySPIConsumer extends AbstractSPIConsumer { + + public DependencySPIConsumer(final boolean failIfSeveralServicesFound) { + super(StringsProviderSPIAsDependency.class, failIfSeveralServicesFound); + } + + public List getValues() { + return this.getSPIImpl().getStringsFromDependency(); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/DynamicDependencySPIConsumer.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/DynamicDependencySPIConsumer.java new file mode 100644 index 0000000000000..c5919b9057aaf --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/DynamicDependencySPIConsumer.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers; + +import java.util.List; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDynamicDependency; + +public class DynamicDependencySPIConsumer extends AbstractSPIConsumer { + + public DynamicDependencySPIConsumer(final boolean failIfSeveralServicesFound) { + super(StringsProviderSPIAsDynamicDependency.class, failIfSeveralServicesFound); + } + + public List getValues() { + return this.getSPIImpl().getStringsFromASPIAsDynamicDependency(); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/ExternalDependencySPIConsumer.java b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/ExternalDependencySPIConsumer.java new file mode 100644 index 0000000000000..cc9ffff107539 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/classloader-test-library/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestlibrary/spiConsumers/ExternalDependencySPIConsumer.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers; + +import java.util.List; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderFromExternalSPI; + +public class ExternalDependencySPIConsumer extends AbstractSPIConsumer { + + public ExternalDependencySPIConsumer(final boolean failIfSeveralServicesFound) { + super(StringsProviderFromExternalSPI.class, failIfSeveralServicesFound); + } + + public List getValues() { + return this.getSPIImpl().getStringsFromExternalSPI(); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml index 023b5246e1816..6550a660db2b3 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/pom.xml @@ -24,7 +24,6 @@ - org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-common jar Component Runtime :: Sample Feature @DynamicDependency Common diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml index 99f1de33a2b9a..09ec14904ce37 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataprepRunAnnotation/pom.xml @@ -22,7 +22,6 @@ 1.88.0-SNAPSHOT - org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-dataprepRunAnnotation jar Component Runtime :: Sample Feature @DynamicDependency with DataprepRun annotation diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml index e4025b41ee4f6..17ef3b9b34751 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/pom.xml @@ -21,7 +21,6 @@ 1.88.0-SNAPSHOT - org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-dataset jar Component Runtime :: Sample Feature @DynamicDependency with Dataset diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml index bfa6379243909..0668afefe3c3a 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/pom.xml @@ -22,7 +22,6 @@ 1.88.0-SNAPSHOT - org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-datastore jar Component Runtime :: Sample Feature @DynamicDependency with Datastore diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml index c458e84c4506c..77b00dd412b75 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/pom.xml @@ -21,7 +21,6 @@ 1.88.0-SNAPSHOT - org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-dynamicDependenciesConfiguration jar Component Runtime :: Sample Feature @DynamicDependency with DynamicDependenciesConfiguration diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml index 18386e8e6f801..8a9fe4bca3f7d 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml @@ -22,7 +22,6 @@ 1.88.0-SNAPSHOT - org.talend.sdk.samplefeature.dynamicdependencies dynamic-dependencies-with-spi jar Component Runtime :: Sample Feature @DynamicDependency with spi @@ -46,7 +45,18 @@ org.talend.sdk.samplefeature.dynamicdependencies - classloader-test-spi + service-provider-from-dependency + ${project.version} + + + org.talend.sdk.samplefeature.dynamicdependencies + service-provider-from-dynamic-dependency + ${project.version} + test + + + org.talend.sdk.samplefeature.dynamicdependencies + service-provider-from-external-dependency ${project.version} test diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/CustomizeClassLoader.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/CustomizeClassLoader.java index fcc8571fb8270..2fb302a9540c8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/CustomizeClassLoader.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/CustomizeClassLoader.java @@ -24,6 +24,9 @@ public class CustomizeClassLoader implements ComponentManager.Customizer { @Override public Stream containerClassesAndPackages() { return Stream.of( - "org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider"); + // Implementation should come from a dynamic dependency + "org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDependency", + // Implementation should come from runtime + "org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDynamicDependency"); } } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java index 3663aa807b914..2abe97ae64cad 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java @@ -22,11 +22,13 @@ import java.io.Serializable; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Properties; +import java.util.stream.Collectors; import org.talend.sdk.component.api.configuration.Option; import org.talend.sdk.component.api.exception.ComponentException; @@ -36,7 +38,9 @@ import org.talend.sdk.component.api.service.dependency.DynamicDependencies; import org.talend.sdk.component.api.service.record.RecordBuilderFactory; import org.talend.sdk.component.api.service.schema.DiscoverSchema; -import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringListTransformer; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers.DependencySPIConsumer; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers.DynamicDependencySPIConsumer; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers.ExternalDependencySPIConsumer; import org.talend.sdk.component.sample.feature.dynamicdependencies.withspi.config.Dataset; import lombok.extern.slf4j.Slf4j; @@ -54,7 +58,6 @@ public class DynamicDependenciesWithSPIService implements Serializable { public List getDynamicDependencies(@Option("theDataset") final Dataset dataset) { String dep = "org.talend.sdk.samplefeature.dynamicdependencies:classloader-test-spi:" + loadVersion(); - System.out.println("Dynamic dependency to load: " + dep); return Collections.singletonList(dep); } @@ -70,23 +73,16 @@ public Schema guessSchema4Input(final @Option("configuration") Dataset dse) { } public Iterator getRecordIterator() { - String contentFromResourceDependency; - try (InputStream resourceStreamFromDependency = DynamicDependenciesWithSPIService.class.getClassLoader() - .getResourceAsStream("CLASSLOADER-TEST-LIBRARY/resource.properties")) { - contentFromResourceDependency = - new String(resourceStreamFromDependency.readAllBytes(), StandardCharsets.UTF_8); - } catch (IOException e) { - throw new ComponentException("Can't retrieve resource from a dependency.", e); - } + String contentFromResourceDependency = loadAPropertyFromResource("FROM_DEPENDENCY/resource.properties", + "ServiceProviderFromDependency.message"); - String contentFromResourceDynamicDependency; - try (InputStream resourceStreamFromDynamicDependency = DynamicDependenciesWithSPIService.class.getClassLoader() - .getResourceAsStream("CLASSLOADER-TEST-SPI/resource.properties")) { - contentFromResourceDynamicDependency = - new String(resourceStreamFromDynamicDependency.readAllBytes(), StandardCharsets.UTF_8); - } catch (IOException e) { - throw new ComponentException("Can't retrieve resource from a dependency.", e); - } + String contentFromResourceDynamicDependency = loadAPropertyFromResource( + "FROM_DYNAMIC_DEPENDENCY/resource.properties", + "ServiceProviderFromDynamicDependency.message"); + + String contentFromResourceExternalDependency = loadAPropertyFromResource( + "FROM_EXTERNAL_DEPENDENCY/resource.properties", + "ServiceProviderFromExternalDependency.message"); String contentFromMultipleResources; try { @@ -99,13 +95,11 @@ public Iterator getRecordIterator() { URL url = resources.nextElement(); try (InputStream is = url.openStream()) { - stringBuilder.append(isFirst ? "" : System.lineSeparator()); - BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); - reader.lines() - .filter(line -> !line.trim().startsWith("#")) - .filter(line -> !line.trim().isEmpty()) - .forEach(stringBuilder::append); - reader.close(); + String content = filterComments(is); + stringBuilder.append(content); + if (!isFirst) { + stringBuilder.append(System.lineSeparator()); + } isFirst = false; } } @@ -114,15 +108,40 @@ public Iterator getRecordIterator() { throw new ComponentException("Can't retrieve multiple resources at once.", e); } - StringListTransformer stringListTransformer = new StringListTransformer<>(true); - List records = stringListTransformer + DependencySPIConsumer dependencySPIConsumer = new DependencySPIConsumer<>(true); + List recordsFromDependencySPI = dependencySPIConsumer .transform(s -> recordBuilderFactory.newRecordBuilder() .withString("value", s) .withString("contentFromResourceDependency", contentFromResourceDependency) .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) + .withString("contentFromResourceExternalDependency", contentFromResourceExternalDependency) .withString("contentFromMultipleResources", contentFromMultipleResources) .build()); - return records.iterator(); + + DynamicDependencySPIConsumer dynamicDependencySPIConsumer = new DynamicDependencySPIConsumer<>(true); + List recordsFromDynamicDependencySPI = dynamicDependencySPIConsumer + .transform(s -> recordBuilderFactory.newRecordBuilder() + .withString("value", s) + .withString("contentFromResourceDependency", contentFromResourceDependency) + .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) + .withString("contentFromMultipleResources", contentFromMultipleResources) + .build()); + + ExternalDependencySPIConsumer externalDependencySPI = new ExternalDependencySPIConsumer<>(true); + List recordsFromExternalSPI = externalDependencySPI + .transform(s -> recordBuilderFactory.newRecordBuilder() + .withString("value", s) + .withString("contentFromResourceDependency", contentFromResourceDependency) + .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) + .withString("contentFromMultipleResources", contentFromMultipleResources) + .build()); + + List values = new ArrayList<>(); + values.addAll(recordsFromDependencySPI); + values.addAll(recordsFromDynamicDependencySPI); + values.addAll(recordsFromExternalSPI); + + return values.iterator(); } private static String loadVersion() { @@ -139,4 +158,31 @@ private static String loadVersion() { return version; } + private String filterComments(final InputStream stream) { + BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); + + String collect = reader.lines() + .filter(line -> !line.trim().startsWith("#")) + .filter(line -> !line.trim().isEmpty()) + .collect(Collectors.joining(System.lineSeparator())); + try { + reader.close(); + } catch (IOException e) { + throw new ComponentException("Can't close a resource reader.", e); + } + + return collect; + } + + private String loadAPropertyFromResource(final String resource, final String property) { + try (InputStream resourceStreamFromDependency = DynamicDependenciesWithSPIService.class.getClassLoader() + .getResourceAsStream(resource)) { + Properties prop = new Properties(); + prop.load(resourceStreamFromDependency); + return prop.getProperty(property); + } catch (IOException e) { + throw new ComponentException("Can't retrieve resource from a dependency.", e); + } + } + } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java index 6bc91900cac36..89c674ff52dc0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java @@ -48,10 +48,24 @@ public void testGeneratedRecord() { .run(); List collectedData = handler.getCollectedData(Record.class); - Assertions.assertEquals(3, collectedData.size()); - Assertions.assertEquals("value1", collectedData.get(0).getString("value")); - Assertions.assertEquals("value2", collectedData.get(1).getString("value")); - Assertions.assertEquals("value3", collectedData.get(2).getString("value")); + Assertions.assertEquals(9, collectedData.size()); + + int i = 0; + for (; i < 3; i++) { + Assertions.assertEquals("ServiceProviderFromDependency_" + (i + 1), + collectedData.get(i).getString("value")); + } + + for (; i < 6; i++) { + Assertions.assertEquals("ServiceProviderFromDynamicDependency_" + (i - 2), + collectedData.get(i).getString("value")); + } + + for (; i < 9; i++) { + Assertions.assertEquals("ServiceProviderFromExternalDependency_" + (i - 5), + collectedData.get(i).getString("value")); + } + } } \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/pom.xml b/sample-parent/sample-features/dynamic-dependencies/pom.xml index d1092ead9f6c1..6941d099636bc 100644 --- a/sample-parent/sample-features/dynamic-dependencies/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/pom.xml @@ -36,7 +36,9 @@ dynamic-dependencies-with-dataprepRunAnnotation dynamic-dependencies-with-spi classloader-test-library - classloader-test-spi + service-provider-from-dependency + service-provider-from-dynamic-dependency + service-provider-from-external-dependency diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/pom.xml b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/pom.xml new file mode 100644 index 0000000000000..7cd7a8ce0a669 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/pom.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + + org.talend.sdk.samplefeature.dynamicdependencies + dynamic-dependencies + 1.88.0-SNAPSHOT + + + service-provider-from-dependency + + jar + Component Runtime :: Sample Feature @DynamicDependency :: a service provider that should be part of dependencies + + + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-library + 1.88.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.talend.sdk.samplefeature.dynamicdependencies.serviceproviderfromdependency + + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdependency/ServiceProviderFromDependency.java b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdependency/ServiceProviderFromDependency.java new file mode 100644 index 0000000000000..0705f3424db90 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdependency/ServiceProviderFromDependency.java @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromdependency; + +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDependency; + +public class ServiceProviderFromDependency implements StringsProviderSPIAsDependency { + + public List getStringsFromDependency() { + List values = new ArrayList<>(); + for (int i = 1; i <= 3; i++) { + values.add("ServiceProviderFromDependency_" + i); + } + return values; + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/FROM_DEPENDENCY/resource.properties similarity index 89% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider rename to sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/FROM_DEPENDENCY/resource.properties index 6a81451058bcf..7e542381a7a66 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringProvider +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/FROM_DEPENDENCY/resource.properties @@ -13,4 +13,4 @@ # limitations under the License. # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi.StringProviderImpl \ No newline at end of file +ServiceProviderFromDependency.message=Message from a dependency resource. \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDependency b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDependency new file mode 100644 index 0000000000000..2210f4f2d3539 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDependency @@ -0,0 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromdependency.ServiceProviderFromDependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties new file mode 100644 index 0000000000000..8f2c010153f00 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties @@ -0,0 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +content=from independent dependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdependency/ServiceProviderFromDependencyTest.java similarity index 69% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java rename to sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdependency/ServiceProviderFromDependencyTest.java index 06d865cc4140a..d05767b1904e9 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/classloadertestspi/StringMapProviderImplTest.java +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdependency/ServiceProviderFromDependencyTest.java @@ -13,26 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi; +package org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromdependency; import java.util.ArrayList; import java.util.List; -import java.util.function.Function; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.StringListTransformer; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers.DependencySPIConsumer; -class StringMapProviderImplTest { +class ServiceProviderFromDependencyTest { @Test void testSPI() { - StringListTransformer stringListTransformer = new StringListTransformer<>(true); - List transform = stringListTransformer.transform(Function.identity()); + DependencySPIConsumer integerListTransformer = new DependencySPIConsumer<>(true); + List transform = integerListTransformer.transform(String::valueOf); List sorted = new ArrayList<>(transform); sorted.sort(String::compareTo); String collect = String.join("/", sorted); - Assertions.assertEquals("value1/value2/value3", + Assertions.assertEquals("ServiceProviderFromDependency_1/" + + "ServiceProviderFromDependency_2/ServiceProviderFromDependency_3", collect); } diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/pom.xml similarity index 86% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml rename to sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/pom.xml index ff77d1ce82fc9..f3b6aef2f86d2 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/pom.xml +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/pom.xml @@ -23,11 +23,10 @@ 1.88.0-SNAPSHOT - org.talend.sdk.samplefeature.dynamicdependencies - classloader-test-spi + service-provider-from-dynamic-dependency jar - Component Runtime :: Sample Feature @DynamicDependency :: a spi service + Component Runtime :: Sample Feature @DynamicDependency :: a service provider that should be part of dynamic dependencies @@ -45,7 +44,7 @@ - dynamic.dependencies.dynamicdependencyspi + org.talend.sdk.samplefeature.dynamicdependencies.serviceproviderfromdynamicdependency diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdynamicdependency/ServiceProviderFromDynamicDependency.java b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdynamicdependency/ServiceProviderFromDynamicDependency.java new file mode 100644 index 0000000000000..23a7a5004a480 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdynamicdependency/ServiceProviderFromDynamicDependency.java @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromdynamicdependency; + +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDynamicDependency; + +public class ServiceProviderFromDynamicDependency implements StringsProviderSPIAsDynamicDependency { + + @Override + public List getStringsFromASPIAsDynamicDependency() { + List values = new ArrayList<>(); + for (int i = 1; i <= 3; i++) { + values.add("ServiceProviderFromDynamicDependency_" + i); + } + return values; + } +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/FROM_DYNAMIC_DEPENDENCY/resource.properties similarity index 85% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties rename to sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/FROM_DYNAMIC_DEPENDENCY/resource.properties index 82a427b40e5a2..2d3b4c75218c1 100644 --- a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/CLASSLOADER-TEST-SPI/resource.properties +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/FROM_DYNAMIC_DEPENDENCY/resource.properties @@ -13,4 +13,4 @@ # limitations under the License. # Here you can change all your configuration display names to use more explicit labels # You can also translate your configuration by adding one file by local Messages_fr.properties for french for example -org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestspi.message=This is a resource file from classloader-test-spi. \ No newline at end of file +ServiceProviderFromDynamicDependency.message=Message from a dynamic dependency resource. \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDynamicDependency b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDynamicDependency new file mode 100644 index 0000000000000..cc4ed0ca6c8e3 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderSPIAsDynamicDependency @@ -0,0 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromdynamicdependency.ServiceProviderFromDynamicDependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties similarity index 100% rename from sample-parent/sample-features/dynamic-dependencies/classloader-test-spi/src/main/resources/MULTIPLE_RESOURCE/common.properties rename to sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdynamicdependency/ServiceProviderFromDependencyTest.java b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdynamicdependency/ServiceProviderFromDependencyTest.java new file mode 100644 index 0000000000000..2c38cc7ac5489 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-dynamic-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromdynamicdependency/ServiceProviderFromDependencyTest.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromdynamicdependency; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers.DynamicDependencySPIConsumer; + +class ServiceProviderFromDependencyTest { + + @Test + void testSPI() { + DynamicDependencySPIConsumer useADynamicDependencySPI = new DynamicDependencySPIConsumer<>(true); + List transform = useADynamicDependencySPI.transform(Function.identity()); + List sorted = new ArrayList<>(transform); + sorted.sort(String::compareTo); + String collect = String.join("/", sorted); + Assertions.assertEquals("ServiceProviderFromDynamicDependency_1/" + + "ServiceProviderFromDynamicDependency_2/ServiceProviderFromDynamicDependency_3", + collect); + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/pom.xml b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/pom.xml new file mode 100644 index 0000000000000..b1fd55d9efc99 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/pom.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + + org.talend.sdk.samplefeature.dynamicdependencies + dynamic-dependencies + 1.88.0-SNAPSHOT + + + service-provider-from-external-dependency + + jar + Component Runtime :: Sample Feature @DynamicDependency :: a service provider that should be part of an external dependencies + + + + org.talend.sdk.samplefeature.dynamicdependencies + classloader-test-library + 1.88.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.talend.sdk.samplefeature.dynamicdependencies.serviceproviderfromexternaldependency + + + + + + + + \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromexternaldependency/ServiceProviderFromExternalDependency.java b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromexternaldependency/ServiceProviderFromExternalDependency.java new file mode 100644 index 0000000000000..554671ddac4ea --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromexternaldependency/ServiceProviderFromExternalDependency.java @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromexternaldependency; + +import java.util.ArrayList; +import java.util.List; + +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderFromExternalSPI; + +public class ServiceProviderFromExternalDependency implements StringsProviderFromExternalSPI { + + public List getStringsFromExternalSPI() { + List values = new ArrayList<>(); + for (int i = 1; i <= 3; i++) { + values.add("ServiceProviderFromExternalDependency_" + i); + } + return values; + } + +} \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/FROM_EXTERNAL_DEPENDENCY/resource.properties b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/FROM_EXTERNAL_DEPENDENCY/resource.properties new file mode 100644 index 0000000000000..218bf5fc1676d --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/FROM_EXTERNAL_DEPENDENCY/resource.properties @@ -0,0 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +ServiceProviderFromExternalDependency.message=Message from an external dependency resource. \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderFromExternalSPI b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderFromExternalSPI new file mode 100644 index 0000000000000..5ad242d22eb76 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/META-INF/services/org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.serviceInterfaces.StringsProviderFromExternalSPI @@ -0,0 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromexternaldependency.ServiceProviderFromExternalDependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties new file mode 100644 index 0000000000000..b98702b679641 --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/main/resources/MULTIPLE_RESOURCE/common.properties @@ -0,0 +1,16 @@ +# Copyright (C) 2006-2025 Talend Inc. - www.talend.com +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Here you can change all your configuration display names to use more explicit labels +# You can also translate your configuration by adding one file by local Messages_fr.properties for french for example +content=from external dependency \ No newline at end of file diff --git a/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromexternaldependency/ServiceProviderFromExternalDependencyTest.java b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromexternaldependency/ServiceProviderFromExternalDependencyTest.java new file mode 100644 index 0000000000000..fb4f54b0ce84a --- /dev/null +++ b/sample-parent/sample-features/dynamic-dependencies/service-provider-from-external-dependency/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/serviceproviderfromexternaldependency/ServiceProviderFromExternalDependencyTest.java @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2006-2025 Talend Inc. - www.talend.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.talend.sdk.component.sample.feature.dynamicdependencies.serviceproviderfromexternaldependency; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.talend.sdk.component.sample.feature.dynamicdependencies.classloadertestlibrary.spiConsumers.ExternalDependencySPIConsumer; + +class ServiceProviderFromExternalDependencyTest { + + @Test + void testSPI() { + ExternalDependencySPIConsumer values = new ExternalDependencySPIConsumer<>(true); + List transform = values.transform(String::valueOf); + List sorted = new ArrayList<>(transform); + sorted.sort(String::compareTo); + String collect = String.join("/", sorted); + Assertions.assertEquals("ServiceProviderFromExternalDependency_1/" + + "ServiceProviderFromExternalDependency_2/ServiceProviderFromExternalDependency_3", + collect); + } + +} \ No newline at end of file From 103c741ee17b1f07318f74f416610345946ebc9b Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 4 Dec 2025 15:20:34 +0100 Subject: [PATCH 38/41] feat(QTDI-1914): Add a class from standard dependency. --- .../config/Dependency.java | 4 ++++ .../AbstractDynamicDependenciesService.java | 20 +++++++++++++------ .../DynamicDependenciesWithSPIService.java | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java index a4c67f8826dbd..08c1fde7ccc2c 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/config/Dependency.java @@ -21,9 +21,13 @@ import org.talend.sdk.component.api.configuration.ui.layout.GridLayout; import org.talend.sdk.component.api.meta.Documentation; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; @Data +@NoArgsConstructor +@AllArgsConstructor @GridLayout(value = { @GridLayout.Row({ "groupId", "artifactId", "version", "clazz" }) }) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java index 8d1aa84c2781f..28c2be905d6b0 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java @@ -86,16 +86,26 @@ public abstract class AbstractDynamicDependenciesService implements Serializable public Iterator loadIterator(final DynamicDependencyConfig dynamicDependencyConfig) { Schema schema = buildSchema(dynamicDependencyConfig); - List standardDependencies = loadStandarDependencies(dynamicDependencyConfig, schema); + List standardDependencies = loadStandardDependencies(dynamicDependencyConfig, schema); List additionalConnectors = loadConnectors(dynamicDependencyConfig, schema); return Stream.concat(standardDependencies.stream(), additionalConnectors.stream()).iterator(); } - private List loadStandarDependencies(final DynamicDependencyConfig dynamicDependencyConfig, + private List loadStandardDependencies(final DynamicDependencyConfig dynamicDependencyConfig, final Schema schema) { List records = new ArrayList<>(); - for (Dependency dependency : dynamicDependencyConfig.getDependencies()) { + + List dependencies = new ArrayList<>(); + // Add a class that should be imported by a 'standard' dependency (not a dynamic one) + // to have an example from which classloaded it is loaded + // In that case the version doesn't matter. + dependencies.add(new Dependency("org.talend.sdk.samplefeature.dynamicdependencies", + "dynamic-dependencies-common", + "N/A", + "org.talend.sdk.component.sample.feature.dynamicdependencies.config.Dependency")); + dependencies.addAll(dynamicDependencyConfig.getDependencies()); + for (Dependency dependency : dependencies) { String maven = String.format("%s:%s:%s", dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); @@ -185,9 +195,7 @@ private Record buildRecord(final Schema schema, .withString(ENTRY_FROM_LOCATION, fromLocation) .withBoolean(ENTRY_IS_TCK_CONTAINER, isTckContainer); - if (firstRecord.isPresent()) { - builder.withRecord(ENTRY_FIRST_RECORD, firstRecord.get()); - } + firstRecord.ifPresent(record -> builder.withRecord(ENTRY_FIRST_RECORD, record)); if (dynamicDependencyConfig.isEnvironmentInformation()) { String rootRepository = System.getProperty("talend.component.manager.m2.repository"); diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java index 2abe97ae64cad..b7366d3f02eca 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java @@ -56,7 +56,7 @@ public class DynamicDependenciesWithSPIService implements Serializable { @DynamicDependencies public List getDynamicDependencies(@Option("theDataset") final Dataset dataset) { - String dep = "org.talend.sdk.samplefeature.dynamicdependencies:classloader-test-spi:" + String dep = "org.talend.sdk.samplefeature.dynamicdependencies:service-provider-from-dynamic-dependency:" + loadVersion(); return Collections.singletonList(dep); } From 9e50baf488133d40a04889d825a88c23947ac7c2 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 4 Dec 2025 16:51:49 +0100 Subject: [PATCH 39/41] feat(QTDI-1914): Complete the readme.md. --- .../dynamic-dependencies/README.md | 453 +++++++++++++++++- 1 file changed, 432 insertions(+), 21 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/README.md b/sample-parent/sample-features/dynamic-dependencies/README.md index e13a0d5c5e064..1909bb4d88227 100644 --- a/sample-parent/sample-features/dynamic-dependencies/README.md +++ b/sample-parent/sample-features/dynamic-dependencies/README.md @@ -1,37 +1,448 @@ -# Component Runtime :: Sample Feature :: DynamicDependency +# Dynamic Dependencies Module Documentation -## Table of Contents -- [Overview](#overview) -- [Usage](#usage) - - [How to build the connector plugin](#how-to-build-the-sample-connector-plugin) - - [How to use](#how-to-use) +## Overview +The `dynamic-dependencies` module is a test TCK connector plugin designed to validate the `@DynamicDependencies` feature in the Talend Component Kit [1](#3-0) . It contains 5 test connectors organized into two categories: dependency checking and SPI checking. -## Overview -This is a test TCK connector plugin to test and validate the DynamicDependency input feature. +## Dependency Checking Connectors + +### 1. DynamicDependenciesWithDataset +- **Family**: `DynamicDependenciesWithDataset` +- **Parameter**: Uses `@Dataset` configuration +- **What it checks**: Validates dynamic dependency loading when triggered from a dataset configuration +- **Record generation**: Extends `AbstractDynamicDependenciesService` to generate diagnostic records [2](#3-1) + +### 2. DynamicDependenciesWithDatastore +- **Family**: `DynamicDependenciesWithDatastore` +- **Parameter**: Uses `@Datastore` configuration +- **What it checks**: Tests dynamic dependency resolution from datastore parameters +- **Record generation**: Uses `AbstractDynamicDependenciesService` through its service layer [3](#3-2) + +### 3. DynamicDependenciesWithDynamicDependenciesConfiguration +- **Family**: `DynamicDependenciesWithDynamicDependenciesConfiguration` +- **Parameter**: Uses `@DynamicDependenciesConfiguration` annotated sub-config +- **What it checks**: Validates the `@DynamicDependenciesConfiguration` annotation behavior +- **Record generation**: Extends `AbstractDynamicDependenciesService` for record output [4](#3-3) + +### 4. DynamicDependenciesWithDataprepRunAnnotation +- **Family**: `DynamicDependenciesWithDataprepRunAnnotation` +- **Parameter**: Uses custom `@DynamicDependencySupported` annotation +- **What it checks**: Tests compatibility with the dataprep run annotation (temporary for testing) +- **Record generation**: Extends `AbstractDynamicDependenciesService` for diagnostic output [5](#3-4) + +### Generated Records for Dependency Checkers + +All dependency checking connectors generate records through `AbstractDynamicDependenciesService.loadIterator()` [6](#3-5) . Each record contains: + +- `maven`: GAV coordinate of the dependency +- `class`: Class name being loaded +- `is_loaded`: Whether the class was successfully loaded +- `connector_classloader`: Classloader ID of the connector +- `clazz_classloader`: Classloader ID of the loaded class +- `from_location`: JAR location where the class was found +- `is_tck_container`: Whether this is a TCK container +- `first_record`: First record from additional connectors (if any) +- `root_repository`: Maven repository path (if environment info enabled) +- `runtime_classpath`: Runtime classpath (if environment info enabled) +- `working_directory`: Current working directory (if environment info enabled) [7](#3-6) + +## SPI Checking Connector -This project contains 4 test connectors: -### DynamicDependency with Dataset -The service of this connector use a dataset as parameter. +### DynamicDependenciesWithSPI +- **Family**: `DynamicDependenciesWithSPI` [8](#3-7) +- **Parameter**: Uses `@Dataset` configuration +- **What it checks**: Validates Java SPI loading from different dependency scopes: + - Standard dependencies (via `DependencySPIConsumer`) + - Dynamic dependencies (via `DynamicDependencySPIConsumer`) + - External/runtime dependencies (via `ExternalDependencySPIConsumer`) +- **Dynamic dependency**: Returns `org.talend.sdk.samplefeature.dynamicdependencies:service-provider-from-dynamic-dependency:{version}` [9](#3-8) -### DynamicDependency with Datastore -The service of this connector use a datastore as parameter. +### Resource Files Loaded -### DynamicDependency with Dataprep run annotation -The service of this connector use a new annotation @DynamicDependencySupported. +The SPI connector loads the following resource files and checks their content [10](#3-9) : -### DynamicDependency with @DynamicDependenciesConfiguration -The service of this connector use a config which using @DynamicDependenciesConfiguration. +1. **FROM_DEPENDENCY/resource.properties** + - Loaded from standard dependency + - Expected property: `ServiceProviderFromDependency.message` + +2. **FROM_DYNAMIC_DEPENDENCY/resource.properties** + - Loaded from dynamic dependency + - Expected property: `ServiceProviderFromDynamicDependency.message` + +3. **FROM_EXTERNAL_DEPENDENCY/resource.properties** + - Loaded from external/runtime dependency + - Expected property: `ServiceProviderFromExternalDependency.message` + +4. **MULTIPLE_RESOURCE/common.properties** + - Loaded from all dependencies using `getResources()` + - Content is combined from all sources (filtered to remove comments and empty lines) + +### Generated Records for SPI Checker + +The SPI connector generates 9 records total (3 from each SPI type) through `DynamicDependenciesWithSPIService.getRecordIterator()` [11](#3-10) . Each record contains: + +- `value`: Value from the SPI implementation + - Records 0-2: `ServiceProviderFromDependency_1`, `_2`, `_3` + - Records 3-5: `ServiceProviderFromDynamicDependency_1`, `_2`, `_3` + - Records 6-8: `ServiceProviderFromExternalDependency_1`, `_2`, `_3` +- `contentFromResourceDependency`: Content from `FROM_DEPENDENCY/resource.properties` +- `contentFromResourceDynamicDependency`: Content from `FROM_DYNAMIC_DEPENDENCY/resource.properties` +- `contentFromResourceExternalDependency`: Content from `FROM_EXTERNAL_DEPENDENCY/resource.properties` +- `contentFromMultipleResources`: Combined content from `MULTIPLE_RESOURCE/common.properties` + +## Module Structure + +### Core Module +- **dynamic-dependencies-common**: Shared library containing: + - `AbstractDynamicDependenciesService`: Base service for dependency loading and record generation [12](#3-11) + - Configuration interfaces (`DynamicDependencyConfig`, `Dependency`, `Connector`) + +### SPI Testing Modules +- **classloader-test-library**: Library providing SPI consumers for testing [13](#3-12) +- **service-provider-from-dependency**: SPI provider as standard dependency [14](#3-13) +- **service-provider-from-dynamic-dependency**: SPI provider loaded dynamically [15](#3-14) +- **service-provider-from-external-dependency**: SPI provider from runtime [16](#3-15) ## Usage -### How to build the sample connector plugin -Checkout the code from the repository and build the project using `mvn clean install` -Alternatively build the feature module using `mvn install -am -pl :dynamicdependencies` +### Building +```bash +mvn clean install -am -pl :dynamicdependencies +``` + +### Testing in Studio +1. Deploy any connector CAR file to Studio: +```bash +java -jar dynamic-dependencies-with-dataset-1.88.0-SNAPSHOT.car studio-deploy --location +``` +2. Create a job with the connector +3. Click "Guess schema" to trigger dynamic dependency loading +4. Run the job to see generated diagnostic records [17](#3-16) + +## Using Connectors in Talend Studio Jobs + +This section provides step-by-step instructions for testing each dynamic dependencies connector in Talend Studio to validate all use cases. + +### Prerequisites + +1. Build all connectors: +```bash +mvn clean install -am -pl :dynamicdependencies +``` + +2. Deploy each connector CAR file to Studio: +```bash +java -jar dynamic-dependencies-with-dataset-1.88.0-SNAPSHOT.car studio-deploy --location +java -jar dynamic-dependencies-with-datastore-1.88.0-SNAPSHOT.car studio-deploy --location +java -jar dynamic-dependencies-with-dynamicDependenciesConfiguration-1.88.0-SNAPSHOT.car studio-deploy --location +java -jar dynamic-dependencies-with-dataprepRunAnnotation-1.88.0-SNAPSHOT.car studio-deploy --location +java -jar dynamic-dependencies-with-spi-1.88.0-SNAPSHOT.car studio-deploy --location +``` + +### Testing Dependency Checking Connectors + +#### Step 1: Create Test Job +1. Create a new Standard Job in Studio +2. Add the connector to test (e.g., `DynamicDependenciesWithDataset` > `Input`) +3. Add a `tLogRow` component to view output +4. Connect the connector to `tLogRow` + +#### Step 2: Configure Dependencies +For each dependency checking connector, configure the test dependency: + +1. Open the component configuration +2. In the **Dependencies** table, add: + - **Group ID**: `org.apache.commons` + - **Artifact ID**: `commons-numbers-primes` + - **Version**: `1.2` + - **Class**: `org.apache.commons.numbers.primes.SmallPrimes` + +3. Enable **Environment Information** to see additional diagnostic data + +#### Step 3: Validate Dynamic Loading +1. Click **Guess Schema** on the connector + - This triggers the `@DynamicDependencies` service + - Validates that the dependency is loaded dynamically +2. Check Studio logs for dependency loading messages +3. Run the job to generate diagnostic records + +#### Step 4: Verify Output Records +Check the `tLogRow` output for these fields: +- `maven`: Should show `org.apache.commons:commons-numbers-primes:1.2` +- `class`: Should show `org.apache.commons.numbers.primes.SmallPrimes` +- `is_loaded`: Should be `true` +- `from_location`: Path to the downloaded JAR +- Additional fields if environment info is enabled + +### Testing SPI Connector + +#### Step 1: Create SPI Test Job +1. Create a new Standard Job +2. Add `DynamicDependenciesWithSPI` > `Input` component +3. Add `tLogRow` component +4. Connect them + +#### Step 2: Validate SPI Loading +1. Click **Guess Schema** to trigger dynamic dependency loading +2. The connector will: + - Load `service-provider-from-dynamic-dependency` dynamically + - Discover SPI implementations from all three scopes +3. Run the job + +#### Step 3: Verify SPI Output +Check for 9 records with this pattern: + +| Record | value Field | Expected Content | +|--------|-------------|------------------| +| 0-2 | ServiceProviderFromDependency_1/2/3 | From standard dependency | +| 3-5 | ServiceProviderFromDynamicDependency_1/2/3 | From dynamic dependency | +| 6-8 | ServiceProviderFromExternalDependency_1/2/3 | From external dependency | + +Each record should also contain: +- `contentFromResourceDependency`: Message from standard dependency resource +- `contentFromResourceDynamicDependency`: Message from dynamic dependency resource +- `contentFromResourceExternalDependency`: Message from external dependency resource +- `contentFromMultipleResources`: Combined content from all dependencies + +### Validation Checklist + +For each connector, verify: + +- [ ] **Guess Schema** triggers without errors +- [ ] Dynamic dependencies are downloaded and loaded +- [ ] Generated records contain expected fields +- [ ] Class loading information is correct +- [ ] Resource loading works (for SPI connector) +- [ ] No classloader conflicts occur + +### Common Issues and Solutions + +1. **Dependency not found**: Check Maven repository configuration in Studio +2. **Class loading fails**: Verify the GAV coordinates and class name +3. **SPI not discovered**: Ensure all service provider modules are deployed +4. **Resource loading fails**: Check that resource files exist in the correct paths + +### Advanced Testing + +To test multiple dependencies or connectors: +1. Add multiple entries in the Dependencies/Connectors tables +2. Use different Maven coordinates +3. Verify that all dependencies are loaded and reported in the output + +## Notes + +- The `@DynamicDependencySupported` annotation in the dataprep module is temporary and should be removed after testing [18](#3-17) +- All modules use `org.talend.sdk.samplefeature.dynamicdependencies` as groupId to avoid automatic exclusion +- Test modules use `commons-numbers-primes` as a simulated dynamic dependency [19](#3-18) +- The SPI connector uses a custom classloader customizer to ensure proper SPI loading from different dependency scopes [20](#3-19) + +### Citations + +**File:** sample-parent/sample-features/dynamic-dependencies/README.md (L11-12) +```markdown +This is a test TCK connector plugin to test and validate the DynamicDependency input feature. + +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/README.md (L31-37) +```markdown ### How to use - Deploy the connector into Studio: java -jar dynamic-dependencies-with-dataset-x.y.z-SNAPSHOT.car studio-deploy --location c:\Talend-Studio-20251010_0827-V8.0.2SNAPSHOT - Use the connector in the job. - Click "Guess schema" of the connector. -- Add others you want to use in the job, then run the job. \ No newline at end of file +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java (L43-66) +```java +public class Config implements DynamicDependencyConfig, Serializable { + + @Option + @Documentation("The dataset configuration.") + private Dataset dse = new Dataset(); + + @Option + @Documentation("If enable throw an exception for any error, if not just log the error.") + private boolean dieOnError = false; + + @Option + @Documentation("More environment information.") + private boolean environmentInformation = false; + + @Override + public List getDependencies() { + return new ArrayList<>(this.getDse().getDependencies()); + } + + public List getConnectors() { + return new ArrayList<>(this.getDse().getConnectors()); + } + +} +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/DynamicDependenciesWithDatastoreInput.java (L50-53) +```java + @PostConstruct + public void init() { + this.recordIterator = this.service.loadIterator(this.config); + } +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java (L31-37) +```java +@Data +@DynamicDependenciesConfiguration +@GridLayout({ + @GridLayout.Row({ "dependencies" }), + @GridLayout.Row({ "connectors" }) +}) +public class SubConfig implements Serializable { +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/package-info.java (L16-20) +```java +@Components( + family = "DynamicDependenciesWithSPI", + categories = "sample") +@Icon(value = Icon.IconType.CUSTOM, custom = "icon") +package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi; +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java (L57-62) +```java + @DynamicDependencies + public List getDynamicDependencies(@Option("theDataset") final Dataset dataset) { + String dep = "org.talend.sdk.samplefeature.dynamicdependencies:service-provider-from-dynamic-dependency:" + + loadVersion(); + return Collections.singletonList(dep); + } +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java (L75-145) +```java + public Iterator getRecordIterator() { + String contentFromResourceDependency = loadAPropertyFromResource("FROM_DEPENDENCY/resource.properties", + "ServiceProviderFromDependency.message"); + + String contentFromResourceDynamicDependency = loadAPropertyFromResource( + "FROM_DYNAMIC_DEPENDENCY/resource.properties", + "ServiceProviderFromDynamicDependency.message"); + + String contentFromResourceExternalDependency = loadAPropertyFromResource( + "FROM_EXTERNAL_DEPENDENCY/resource.properties", + "ServiceProviderFromExternalDependency.message"); + + String contentFromMultipleResources; + try { + boolean isFirst = true; + Enumeration resources = DynamicDependenciesWithSPIService.class.getClassLoader() + .getResources("MULTIPLE_RESOURCE/common.properties"); + + StringBuilder stringBuilder = new StringBuilder(); + while (resources.hasMoreElements()) { + URL url = resources.nextElement(); + + try (InputStream is = url.openStream()) { + String content = filterComments(is); + stringBuilder.append(content); + if (!isFirst) { + stringBuilder.append(System.lineSeparator()); + } + isFirst = false; + } + } + contentFromMultipleResources = stringBuilder.toString(); + } catch (IOException e) { + throw new ComponentException("Can't retrieve multiple resources at once.", e); + } + + DependencySPIConsumer dependencySPIConsumer = new DependencySPIConsumer<>(true); + List recordsFromDependencySPI = dependencySPIConsumer + .transform(s -> recordBuilderFactory.newRecordBuilder() + .withString("value", s) + .withString("contentFromResourceDependency", contentFromResourceDependency) + .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) + .withString("contentFromResourceExternalDependency", contentFromResourceExternalDependency) + .withString("contentFromMultipleResources", contentFromMultipleResources) + .build()); + + DynamicDependencySPIConsumer dynamicDependencySPIConsumer = new DynamicDependencySPIConsumer<>(true); + List recordsFromDynamicDependencySPI = dynamicDependencySPIConsumer + .transform(s -> recordBuilderFactory.newRecordBuilder() + .withString("value", s) + .withString("contentFromResourceDependency", contentFromResourceDependency) + .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) + .withString("contentFromMultipleResources", contentFromMultipleResources) + .build()); + + ExternalDependencySPIConsumer externalDependencySPI = new ExternalDependencySPIConsumer<>(true); + List recordsFromExternalSPI = externalDependencySPI + .transform(s -> recordBuilderFactory.newRecordBuilder() + .withString("value", s) + .withString("contentFromResourceDependency", contentFromResourceDependency) + .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) + .withString("contentFromMultipleResources", contentFromMultipleResources) + .build()); + + List values = new ArrayList<>(); + values.addAll(recordsFromDependencySPI); + values.addAll(recordsFromDynamicDependencySPI); + values.addAll(recordsFromExternalSPI); + + return values.iterator(); + } +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java (L50-68) +```java + List collectedData = handler.getCollectedData(Record.class); + Assertions.assertEquals(9, collectedData.size()); + + int i = 0; + for (; i < 3; i++) { + Assertions.assertEquals("ServiceProviderFromDependency_" + (i + 1), + collectedData.get(i).getString("value")); + } + + for (; i < 6; i++) { + Assertions.assertEquals("ServiceProviderFromDynamicDependency_" + (i - 2), + collectedData.get(i).getString("value")); + } + + for (; i < 9; i++) { + Assertions.assertEquals("ServiceProviderFromExternalDependency_" + (i - 5), + collectedData.get(i).getString("value")); + } + +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml (L46-50) +```text + + org.talend.sdk.samplefeature.dynamicdependencies + service-provider-from-dependency + ${project.version} + +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml (L51-56) +```text + + org.talend.sdk.samplefeature.dynamicdependencies + service-provider-from-dynamic-dependency + ${project.version} + test + +``` + +**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml (L57-62) +```text + + org.talend.sdk.samplefeature.dynamicdependencies + service-provider-from-external-dependency + ${project.version} + test + +``` \ No newline at end of file From 42396891271c1ed1e36bf8918e48ec9512c4e251 Mon Sep 17 00:00:00 2001 From: Yves Piel Date: Thu, 4 Dec 2025 19:13:00 +0100 Subject: [PATCH 40/41] feat(QTDI-1914): Complete the readme.md. --- .../dynamic-dependencies/README.md | 303 ++---------------- 1 file changed, 33 insertions(+), 270 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/README.md b/sample-parent/sample-features/dynamic-dependencies/README.md index 1909bb4d88227..1a9914a75edc8 100644 --- a/sample-parent/sample-features/dynamic-dependencies/README.md +++ b/sample-parent/sample-features/dynamic-dependencies/README.md @@ -2,80 +2,54 @@ ## Overview -The `dynamic-dependencies` module is a test TCK connector plugin designed to validate the `@DynamicDependencies` feature in the Talend Component Kit [1](#3-0) . It contains 5 test connectors organized into two categories: dependency checking and SPI checking. +The `dynamic-dependencies` module provides several TCK connector plugins designed to validate the `@DynamicDependencies` feature in the Talend Component Kit. It contains 5 test connectors organized into two categories: dependencies checking and SPI (_Service Provider Interface_) checking. ## Dependency Checking Connectors +All `dynamic-dependencies-with-*` provide a TCK connector that will get a list of dynamic dependencies (_defined with maven GAV_) and a list of dynamic loaded TCK connectors. They all rely on `dynamic-dependencies-common` to generate same kind of records. -### 1. DynamicDependenciesWithDataset -- **Family**: `DynamicDependenciesWithDataset` -- **Parameter**: Uses `@Dataset` configuration -- **What it checks**: Validates dynamic dependency loading when triggered from a dataset configuration -- **Record generation**: Extends `AbstractDynamicDependenciesService` to generate diagnostic records [2](#3-1) - -### 2. DynamicDependenciesWithDatastore -- **Family**: `DynamicDependenciesWithDatastore` -- **Parameter**: Uses `@Datastore` configuration -- **What it checks**: Tests dynamic dependency resolution from datastore parameters -- **Record generation**: Uses `AbstractDynamicDependenciesService` through its service layer [3](#3-2) - -### 3. DynamicDependenciesWithDynamicDependenciesConfiguration -- **Family**: `DynamicDependenciesWithDynamicDependenciesConfiguration` -- **Parameter**: Uses `@DynamicDependenciesConfiguration` annotated sub-config -- **What it checks**: Validates the `@DynamicDependenciesConfiguration` annotation behavior -- **Record generation**: Extends `AbstractDynamicDependenciesService` for record output [4](#3-3) - -### 4. DynamicDependenciesWithDataprepRunAnnotation -- **Family**: `DynamicDependenciesWithDataprepRunAnnotation` -- **Parameter**: Uses custom `@DynamicDependencySupported` annotation -- **What it checks**: Tests compatibility with the dataprep run annotation (temporary for testing) -- **Record generation**: Extends `AbstractDynamicDependenciesService` for diagnostic output [5](#3-4) +Each `dynamic-dependencies-with-*` module proposes its own implementation of a `@DynamicSchema` service, that serves a list of GAV, each expect a different kind of TCK configuration as parameter: +- `dynamic-dependencies-with-datastore` has a `@DynamicSchema` that expect a `@Datastore` +- `dynamic-dependencies-with-dataset` has a `@DynamicSchema` that expect a `@Dataset` +- `dynamic-dependencies-with-dynamicDependenciesConfiguration` has a `@DynamicSchema` that expect a `@DynamicDependenciesConfiguration` +- `dynamic-dependencies-with-dataPrepRunAnnotation` has a `@DynamicSchema` that expect a `@DynamicDependencySupported`. this annotation is cuurently provided and used in connectors-se/dataprep, and that should be removed afterward ### Generated Records for Dependency Checkers -All dependency checking connectors generate records through `AbstractDynamicDependenciesService.loadIterator()` [6](#3-5) . Each record contains: +All dependency checking connectors generate records through `AbstractDynamicDependenciesService.loadIterator()`. +Each record contains: -- `maven`: GAV coordinate of the dependency -- `class`: Class name being loaded +- `maven`: GAV coordinate of the dependency (_this is set by the user in the connectors' configuration_) +- `class`: Class name being loaded (_this is set by the user in the connectors' configuration_) - `is_loaded`: Whether the class was successfully loaded - `connector_classloader`: Classloader ID of the connector - `clazz_classloader`: Classloader ID of the loaded class - `from_location`: JAR location where the class was found - `is_tck_container`: Whether this is a TCK container -- `first_record`: First record from additional connectors (if any) +- `first_record`: First record from additional connectors (if any). If a record is retrieved, it means the connectors has been well loaded. - `root_repository`: Maven repository path (if environment info enabled) - `runtime_classpath`: Runtime classpath (if environment info enabled) -- `working_directory`: Current working directory (if environment info enabled) [7](#3-6) +- `working_directory`: Current working directory (if environment info enabled) ## SPI Checking Connector - -### DynamicDependenciesWithSPI -- **Family**: `DynamicDependenciesWithSPI` [8](#3-7) -- **Parameter**: Uses `@Dataset` configuration -- **What it checks**: Validates Java SPI loading from different dependency scopes: - - Standard dependencies (via `DependencySPIConsumer`) - - Dynamic dependencies (via `DynamicDependencySPIConsumer`) - - External/runtime dependencies (via `ExternalDependencySPIConsumer`) -- **Dynamic dependency**: Returns `org.talend.sdk.samplefeature.dynamicdependencies:service-provider-from-dynamic-dependency:{version}` [9](#3-8) - -### Resource Files Loaded - -The SPI connector loads the following resource files and checks their content [10](#3-9) : - -1. **FROM_DEPENDENCY/resource.properties** - - Loaded from standard dependency - - Expected property: `ServiceProviderFromDependency.message` - -2. **FROM_DYNAMIC_DEPENDENCY/resource.properties** - - Loaded from dynamic dependency - - Expected property: `ServiceProviderFromDynamicDependency.message` - -3. **FROM_EXTERNAL_DEPENDENCY/resource.properties** - - Loaded from external/runtime dependency - - Expected property: `ServiceProviderFromExternalDependency.message` - -4. **MULTIPLE_RESOURCE/common.properties** - - Loaded from all dependencies using `getResources()` - - Content is combined from all sources (filtered to remove comments and empty lines) +The `jvm` provides the `Service Provider Interface` (_SPI_) mechanism. It allows to load implementations of interfaces without explicitly specifying them. The classloader search for all resource files in `META-INF/services/` that have the same name as the full qualified name of the interface you want some implementation. See more information in [ServiceLoader javadoc](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/ServiceLoader.html). The goal is to check that SPI implementations can be loaded in several case, for instance when the implementation is provided by a dynamic dependency or by te runtime, etc... + +### The dynamic-dependencies-with-spi module +It provides a connector that has `classloader-test-library` as dependency. This library contains several interfaces that have their implementations provided by `SPI` mechanism, loading them from `service-provided-from-*` modules. The connector will also try to load some resources from those modules: + +- `service-provider-from-dependency` is a direct dependency of `dynamic-dependencies-with-spi` + - It proposes those resource files to load: + - `FROM_DEPENDENCY/resource.properties` + - `MULTIPLE_RESOURCE/common.properties` +- `service-provider-from-dynamic-dependency` is a dynamic dependency returned by `DynamicDependenciesWithSPIService#getDynamicDependencies` service that is annotated with `@DynamicDependencies` + - It proposes those resource files to load: + - `FROM_DYNAMIC_DEPENDENCY/resource.properties` + - `MULTIPLE_RESOURCE/common.properties` +- `service-provider-from-external-dependency` is a library that should be loaded and provided by the runtime, for instance in a studio job, it should be loaded by a `tLibraryLoad` + - It proposes those resource files to load: + - `FROM_EXTERNAL_DEPENDENCY/resource.properties` + - `MULTIPLE_RESOURCE/common.properties` + +The connector in `dynamic-dependencies-with-spi` tries to load `FROM_xxxx/resource.properties` resources with `classloadOfTheDependency.getResourceAsStream(resource)`, and, it tries to load `MULTIPLE_RESOURCE/common.properties` with `classloadOfTheDependency.getResources("MULTIPLE_RESOURCE/common.properties")`. ### Generated Records for SPI Checker @@ -234,215 +208,4 @@ To test multiple dependencies or connectors: - The `@DynamicDependencySupported` annotation in the dataprep module is temporary and should be removed after testing [18](#3-17) - All modules use `org.talend.sdk.samplefeature.dynamicdependencies` as groupId to avoid automatic exclusion - Test modules use `commons-numbers-primes` as a simulated dynamic dependency [19](#3-18) -- The SPI connector uses a custom classloader customizer to ensure proper SPI loading from different dependency scopes [20](#3-19) - -### Citations - -**File:** sample-parent/sample-features/dynamic-dependencies/README.md (L11-12) -```markdown -This is a test TCK connector plugin to test and validate the DynamicDependency input feature. - -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/README.md (L31-37) -```markdown -### How to use -- Deploy the connector into Studio: -java -jar dynamic-dependencies-with-dataset-x.y.z-SNAPSHOT.car studio-deploy --location c:\Talend-Studio-20251010_0827-V8.0.2SNAPSHOT - -- Use the connector in the job. -- Click "Guess schema" of the connector. -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dataset/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdataset/config/Config.java (L43-66) -```java -public class Config implements DynamicDependencyConfig, Serializable { - - @Option - @Documentation("The dataset configuration.") - private Dataset dse = new Dataset(); - - @Option - @Documentation("If enable throw an exception for any error, if not just log the error.") - private boolean dieOnError = false; - - @Option - @Documentation("More environment information.") - private boolean environmentInformation = false; - - @Override - public List getDependencies() { - return new ArrayList<>(this.getDse().getDependencies()); - } - - public List getConnectors() { - return new ArrayList<>(this.getDse().getConnectors()); - } - -} -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-datastore/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withdatastore/input/DynamicDependenciesWithDatastoreInput.java (L50-53) -```java - @PostConstruct - public void init() { - this.recordIterator = this.service.loadIterator(this.config); - } -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-dynamicDependenciesConfiguration/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withDynamicDependenciesConfiguration/config/SubConfig.java (L31-37) -```java -@Data -@DynamicDependenciesConfiguration -@GridLayout({ - @GridLayout.Row({ "dependencies" }), - @GridLayout.Row({ "connectors" }) -}) -public class SubConfig implements Serializable { -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/package-info.java (L16-20) -```java -@Components( - family = "DynamicDependenciesWithSPI", - categories = "sample") -@Icon(value = Icon.IconType.CUSTOM, custom = "icon") -package org.talend.sdk.component.sample.feature.dynamicdependencies.withspi; -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java (L57-62) -```java - @DynamicDependencies - public List getDynamicDependencies(@Option("theDataset") final Dataset dataset) { - String dep = "org.talend.sdk.samplefeature.dynamicdependencies:service-provider-from-dynamic-dependency:" - + loadVersion(); - return Collections.singletonList(dep); - } -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/service/DynamicDependenciesWithSPIService.java (L75-145) -```java - public Iterator getRecordIterator() { - String contentFromResourceDependency = loadAPropertyFromResource("FROM_DEPENDENCY/resource.properties", - "ServiceProviderFromDependency.message"); - - String contentFromResourceDynamicDependency = loadAPropertyFromResource( - "FROM_DYNAMIC_DEPENDENCY/resource.properties", - "ServiceProviderFromDynamicDependency.message"); - - String contentFromResourceExternalDependency = loadAPropertyFromResource( - "FROM_EXTERNAL_DEPENDENCY/resource.properties", - "ServiceProviderFromExternalDependency.message"); - - String contentFromMultipleResources; - try { - boolean isFirst = true; - Enumeration resources = DynamicDependenciesWithSPIService.class.getClassLoader() - .getResources("MULTIPLE_RESOURCE/common.properties"); - - StringBuilder stringBuilder = new StringBuilder(); - while (resources.hasMoreElements()) { - URL url = resources.nextElement(); - - try (InputStream is = url.openStream()) { - String content = filterComments(is); - stringBuilder.append(content); - if (!isFirst) { - stringBuilder.append(System.lineSeparator()); - } - isFirst = false; - } - } - contentFromMultipleResources = stringBuilder.toString(); - } catch (IOException e) { - throw new ComponentException("Can't retrieve multiple resources at once.", e); - } - - DependencySPIConsumer dependencySPIConsumer = new DependencySPIConsumer<>(true); - List recordsFromDependencySPI = dependencySPIConsumer - .transform(s -> recordBuilderFactory.newRecordBuilder() - .withString("value", s) - .withString("contentFromResourceDependency", contentFromResourceDependency) - .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) - .withString("contentFromResourceExternalDependency", contentFromResourceExternalDependency) - .withString("contentFromMultipleResources", contentFromMultipleResources) - .build()); - - DynamicDependencySPIConsumer dynamicDependencySPIConsumer = new DynamicDependencySPIConsumer<>(true); - List recordsFromDynamicDependencySPI = dynamicDependencySPIConsumer - .transform(s -> recordBuilderFactory.newRecordBuilder() - .withString("value", s) - .withString("contentFromResourceDependency", contentFromResourceDependency) - .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) - .withString("contentFromMultipleResources", contentFromMultipleResources) - .build()); - - ExternalDependencySPIConsumer externalDependencySPI = new ExternalDependencySPIConsumer<>(true); - List recordsFromExternalSPI = externalDependencySPI - .transform(s -> recordBuilderFactory.newRecordBuilder() - .withString("value", s) - .withString("contentFromResourceDependency", contentFromResourceDependency) - .withString("contentFromResourceDynamicDependency", contentFromResourceDynamicDependency) - .withString("contentFromMultipleResources", contentFromMultipleResources) - .build()); - - List values = new ArrayList<>(); - values.addAll(recordsFromDependencySPI); - values.addAll(recordsFromDynamicDependencySPI); - values.addAll(recordsFromExternalSPI); - - return values.iterator(); - } -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/src/test/java/org/talend/sdk/component/sample/feature/dynamicdependencies/withspi/input/DynamicDependenciesWithSPIInputTest.java (L50-68) -```java - List collectedData = handler.getCollectedData(Record.class); - Assertions.assertEquals(9, collectedData.size()); - - int i = 0; - for (; i < 3; i++) { - Assertions.assertEquals("ServiceProviderFromDependency_" + (i + 1), - collectedData.get(i).getString("value")); - } - - for (; i < 6; i++) { - Assertions.assertEquals("ServiceProviderFromDynamicDependency_" + (i - 2), - collectedData.get(i).getString("value")); - } - - for (; i < 9; i++) { - Assertions.assertEquals("ServiceProviderFromExternalDependency_" + (i - 5), - collectedData.get(i).getString("value")); - } - -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml (L46-50) -```text - - org.talend.sdk.samplefeature.dynamicdependencies - service-provider-from-dependency - ${project.version} - -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml (L51-56) -```text - - org.talend.sdk.samplefeature.dynamicdependencies - service-provider-from-dynamic-dependency - ${project.version} - test - -``` - -**File:** sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-with-spi/pom.xml (L57-62) -```text - - org.talend.sdk.samplefeature.dynamicdependencies - service-provider-from-external-dependency - ${project.version} - test - -``` \ No newline at end of file +- The SPI connector uses a custom classloader customizer to ensure proper SPI loading from different dependency scopes [20](#3-19) \ No newline at end of file From 33dd8e23509d6000aab16266d8a10f91c0463945 Mon Sep 17 00:00:00 2001 From: Emmanuel GALLOIS Date: Fri, 12 Dec 2025 09:07:27 +0100 Subject: [PATCH 41/41] feat(QTDI-1914): fix json2Map and record builder --- .../AbstractDynamicDependenciesService.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java index 28c2be905d6b0..62175dff7d4e1 100644 --- a/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java +++ b/sample-parent/sample-features/dynamic-dependencies/dynamic-dependencies-common/src/main/java/org/talend/sdk/component/sample/feature/dynamicdependencies/service/AbstractDynamicDependenciesService.java @@ -21,10 +21,12 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Serializable; +import java.io.StringReader; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -34,6 +36,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonReader; + import org.talend.sdk.component.api.exception.ComponentException; import org.talend.sdk.component.api.record.Record; import org.talend.sdk.component.api.record.Record.Builder; @@ -220,7 +226,20 @@ private Optional testLoadingData(final Connector connector) { private Map json2Map(final String json) { // Transform the given json to map - return Collections.emptyMap(); + if (json == null || json.isBlank()) { + return Collections.emptyMap(); + } + try (JsonReader reader = Json.createReader(new StringReader(json))) { + JsonObject jsonObject = reader.readObject(); + Map map = new HashMap<>(); + for (String key : jsonObject.keySet()) { + map.put(key, jsonObject.getString(key, null)); + } + return map; + } catch (Exception e) { + log.error("conversion JSON: {}", e.getMessage(), e); + return Collections.emptyMap(); + } } protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConfig) { @@ -232,8 +251,8 @@ protected Schema buildSchema(final DynamicDependencyConfig dynamicDependencyConf factory.newEntryBuilder().withName(ENTRY_CONNECTOR_CLASSLOADER).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_CLAZZ_CLASSLOADER).withType(Type.STRING).build()) .withEntry(factory.newEntryBuilder().withName(ENTRY_FROM_LOCATION).withType(Type.STRING).build()) - .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_TCK_CONTAINER).withType(Type.BOOLEAN).build()); - + .withEntry(factory.newEntryBuilder().withName(ENTRY_IS_TCK_CONTAINER).withType(Type.BOOLEAN).build()) + .withEntry(factory.newEntryBuilder().withName(ENTRY_FIRST_RECORD).withType(Type.RECORD).build()); if (dynamicDependencyConfig.isEnvironmentInformation()) { builder = builder .withEntry(factory.newEntryBuilder().withName(ENTRY_ROOT_REPOSITORY).withType(Type.STRING).build())