Skip to content

Commit 7808e1e

Browse files
authored
Merge branch 'master' into ouf/QTDI-2893_pattern_instanceof
2 parents e6240c6 + 1c5775e commit 7808e1e

217 files changed

Lines changed: 6928 additions & 224 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

component-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>org.talend.sdk.component</groupId>
2121
<artifactId>component-runtime</artifactId>
22-
<version>1.92.0-SNAPSHOT</version>
22+
<version>1.93.0-SNAPSHOT</version>
2323
</parent>
2424

2525
<artifactId>component-api</artifactId>

component-api/src/main/java/org/talend/sdk/component/api/configuration/type/DynamicDependenciesServiceConfiguration.java renamed to component-api/src/main/java/org/talend/sdk/component/api/configuration/type/DynamicDependenciesConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
@Target(TYPE)
2828
@Retention(RUNTIME)
29-
@ConfigurationType("dynamicDependenciesServiceConfiguration")
30-
@Documentation("Mark a model (complex object) as being the configuration used in services annotated with @DynamicDependencies.")
31-
public @interface DynamicDependenciesServiceConfiguration {
29+
@ConfigurationType("dynamicDependenciesConfiguration")
30+
@Documentation("Mark a model (complex object) as being the configuration expected to compute dynamic dependencies.")
31+
public @interface DynamicDependenciesConfiguration {
3232

3333
String value() default "default";
3434
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright (C) 2006-2026 Talend Inc. - www.talend.com
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.talend.sdk.component.api.service.dependency;
17+
18+
import java.util.function.Predicate;
19+
20+
public interface ClassLoaderDefinition {
21+
22+
/**
23+
*
24+
* @return the parent classloader to use for the classloader to create.
25+
*/
26+
ClassLoader getParent();
27+
28+
/**
29+
*
30+
* @return a filter to apply on the classes to load from the classloader to create. If the filter returns false for
31+
* a class, the classloader to create will try to load it from its parent.
32+
*/
33+
Predicate<String> getClassesFilter();
34+
35+
/**
36+
*
37+
* @return a filter to apply on the classes to load from the parent classloader. If the filter returns false for a
38+
* class, the classloader to create will try to load it by itself instead of delegating to its parent.
39+
*/
40+
Predicate<String> getParentClassesFilter();
41+
42+
/**
43+
*
44+
* @return a filter to apply on the resources to load from the parent classloader. The {@link String} argument of
45+
* the predicate is the path of the resource as obtained from {@code URL#getFile()} (i.e. the full URL/file path),
46+
* not the logical resource name used in {@link ClassLoader#getResource(String)}. If the filter returns
47+
* {@code false} for a resource, the classloader to create will try to load it by itself instead of delegating to
48+
* its parent.
49+
*/
50+
Predicate<String> getParentResourcesFilter();
51+
52+
/**
53+
*
54+
* @return true if the classloader to create should support resource dependencies (i.e. the dependencies.txt can
55+
* also list resources to load and not only classes). Note that if this is true, the classloader to create will try
56+
* to load resources by itself instead of delegating to its parent.
57+
*
58+
*/
59+
boolean isSupportsResourceDependencies();
60+
61+
/**
62+
*
63+
* @return the resource path to the plugins mapping file ("TALEND-INF/plugins.properties").
64+
*/
65+
String getNestedPluginMappingResource();
66+
}

component-api/src/main/java/org/talend/sdk/component/api/service/dependency/Resolver.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,37 @@ default ClassLoaderDescriptor mapDescriptorToClassLoader(final List<String> gavs
4646
new ByteArrayInputStream(String.join("\n", gavs).getBytes(StandardCharsets.UTF_8)));
4747
}
4848

49+
/**
50+
* Creates a classloader from the passed classloader configuration and descriptor (dependencies.txt).
51+
*
52+
* WARNING: note it is very important to close the descriptor once no more used otherwise
53+
* you can leak memory.
54+
*
55+
* <p>
56+
* The default implementation of this method is unsupported and will always throw
57+
* {@link UnsupportedOperationException}. Implementations that support configurable
58+
* classloader creation must override this method.
59+
* </p>
60+
*
61+
* @param descriptor the dependencies.txt InputStream.
62+
* @param configuration the classloader configuration to apply when creating the classloader.
63+
* @return the classloader initialized with the configuration provided and the resolved dependencies.
64+
* @throws UnsupportedOperationException if this implementation does not support configurable
65+
* classloader creation.
66+
*/
67+
default ClassLoaderDescriptor mapDescriptorToClassLoader(InputStream descriptor,
68+
final ClassLoaderDefinition configuration) {
69+
throw new UnsupportedOperationException(
70+
"ClassLoader configuration is not supported by this implementation; "
71+
+ "override mapDescriptorToClassLoader(InputStream, ClassLoaderDefinition) to provide an implementation");
72+
}
73+
74+
default ClassLoaderDescriptor mapDescriptorToClassLoader(final List<String> gavs,
75+
final ClassLoaderDefinition configuration) {
76+
return mapDescriptorToClassLoader(
77+
new ByteArrayInputStream(String.join("\n", gavs).getBytes(StandardCharsets.UTF_8)), configuration);
78+
}
79+
4980
/**
5081
* Resolves the dependencies from the descriptor passed as an InputStream.
5182
*

component-form/component-form-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>org.talend.sdk.component</groupId>
2121
<artifactId>component-form</artifactId>
22-
<version>1.92.0-SNAPSHOT</version>
22+
<version>1.93.0-SNAPSHOT</version>
2323
</parent>
2424

2525
<artifactId>component-form-core</artifactId>

component-form/component-form-core/src/main/java/org/talend/sdk/component/form/internal/validation/JavascriptRegex.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
*/
1616
package org.talend.sdk.component.form.internal.validation;
1717

18+
import java.util.ServiceLoader;
1819
import java.util.function.Predicate;
1920

2021
import org.mozilla.javascript.Context;
22+
import org.mozilla.javascript.RegExpLoader;
23+
import org.mozilla.javascript.ScriptRuntime;
2124
import org.mozilla.javascript.Scriptable;
2225

2326
public class JavascriptRegex implements Predicate<CharSequence> {
@@ -47,6 +50,15 @@ public boolean test(final CharSequence text) {
4750
final String script = "new RegExp(regex, indicators).test(text)";
4851
final Context context = Context.enter();
4952
try {
53+
// Rhino 1.9.0+: RegExp is registered via ServiceLoader<RegExpLoader>.
54+
// The ServiceLoader uses Thread.currentThread().getContextClassLoader() by default,
55+
// which may not find the service in an isolated classloader context.
56+
// Explicitly register RegExpProxy using Rhino's own classloader as fallback.
57+
if (ScriptRuntime.getRegExpProxy(context) == null) {
58+
ServiceLoader.load(RegExpLoader.class, context.getClass().getClassLoader())
59+
.findFirst()
60+
.ifPresent(loader -> ScriptRuntime.setRegExpProxy(context, loader.newProxy()));
61+
}
5062
final Scriptable scope = context.initStandardObjects();
5163
scope.put("text", scope, text);
5264
scope.put("regex", scope, regex);

component-form/component-form-model/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>org.talend.sdk.component</groupId>
2121
<artifactId>component-form</artifactId>
22-
<version>1.92.0-SNAPSHOT</version>
22+
<version>1.93.0-SNAPSHOT</version>
2323
</parent>
2424

2525
<artifactId>component-form-model</artifactId>

component-form/component-uispec-mapper/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>org.talend.sdk.component</groupId>
2121
<artifactId>component-form</artifactId>
22-
<version>1.92.0-SNAPSHOT</version>
22+
<version>1.93.0-SNAPSHOT</version>
2323
</parent>
2424

2525
<artifactId>component-uispec-mapper</artifactId>

component-form/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>org.talend.sdk.component</groupId>
2121
<artifactId>component-runtime</artifactId>
22-
<version>1.92.0-SNAPSHOT</version>
22+
<version>1.93.0-SNAPSHOT</version>
2323
</parent>
2424

2525
<artifactId>component-form</artifactId>

component-runtime-beam/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<groupId>org.talend.sdk.component</groupId>
2121
<artifactId>component-runtime</artifactId>
22-
<version>1.92.0-SNAPSHOT</version>
22+
<version>1.93.0-SNAPSHOT</version>
2323
</parent>
2424

2525
<artifactId>component-runtime-beam</artifactId>

0 commit comments

Comments
 (0)