You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/04/27 19:57:13 UTC
[camel] branch main updated: camel-jbang - Classloader to load additional files from classpath - move to later phase so custom properties can influence the option what to include.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 433d4395912 camel-jbang - Classloader to load additional files from classpath - move to later phase so custom properties can influence the option what to include.
433d4395912 is described below
commit 433d43959127b10b65d9e894a33f241dc4d367c1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Apr 27 21:56:57 2022 +0200
camel-jbang - Classloader to load additional files from classpath - move to later phase so custom properties can influence the option what to include.
---
.../java/org/apache/camel/main/KameletMain.java | 31 +++++++++++++---------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
index 4cd3563f0c7..341e0b460d2 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
@@ -128,17 +128,6 @@ public class KameletMain extends MainCommandLineSupport {
// Implementation methods
// -------------------------------------------------------------------------
- protected ClassLoader createApplicationContextClassLoader() {
- // any additional files to add to classpath
- ClassLoader parentCL = KameletMain.class.getClassLoader();
- String cpFiles = getInitialProperties().getProperty("camel.jbang.classpathFiles");
- if (cpFiles != null) {
- parentCL = new ExtraFilesClassLoader(parentCL, cpFiles.split(","));
- LOG.info("Additional files added to classpath: {}", cpFiles);
- }
- return new GroovyClassLoader(parentCL);
- }
-
@Override
protected void doInit() throws Exception {
super.doInit();
@@ -192,7 +181,6 @@ public class KameletMain extends MainCommandLineSupport {
LOG.info(info);
}
- answer.setApplicationContextClassLoader(createApplicationContextClassLoader());
answer.setRegistry(registry);
// load camel component and custom health-checks
answer.setLoadHealthChecks(true);
@@ -267,6 +255,25 @@ public class KameletMain extends MainCommandLineSupport {
return answer;
}
+ @Override
+ protected void autoconfigure(CamelContext camelContext) throws Exception {
+ // create classloader that may include additional JARs
+ camelContext.setApplicationContextClassLoader(createApplicationContextClassLoader());
+ // auto configure camel afterwards
+ super.autoconfigure(camelContext);
+ }
+
+ protected ClassLoader createApplicationContextClassLoader() {
+ // any additional files to add to classpath
+ ClassLoader parentCL = KameletMain.class.getClassLoader();
+ String cpFiles = getInitialProperties().getProperty("camel.jbang.classpathFiles");
+ if (cpFiles != null) {
+ parentCL = new ExtraFilesClassLoader(parentCL, cpFiles.split(","));
+ LOG.info("Additional files added to classpath: {}", cpFiles);
+ }
+ return new GroovyClassLoader(parentCL);
+ }
+
@Override
protected void configureRoutesLoader(CamelContext camelContext) {
if (download) {