Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{ "name": "camel.jbang.scriptFiles", "required": false, "description": "Additional shell script files to export to src\/main\/scripts directory", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.sourceDir", "required": false, "description": "Source directory for dynamically loading Camel file(s) to run. When using this, then files cannot be specified at the same time.", "label": "advanced", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.springBootVersion", "required": false, "description": "Spring Boot version", "label": "spring-boot", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.stub", "required": false, "description": "Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = everything).", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.stub", "required": false, "description": "Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints, remote = stub only remote components).", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.tlsFiles", "required": false, "description": "Additional SSL\/TLS files to export to src\/main\/tls directory", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.verbose", "required": false, "description": "Verbose output of startup activity (dependency resolution and downloading", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false }
]
Expand Down
12 changes: 11 additions & 1 deletion docs/user-manual/modules/ROOT/pages/camel-jbang.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,16 @@ Then only the `jms:inbox` endpoint is stubbed.

TIP: You can stub multiple components separated by comma, such as `--stub=jms,sql`

You can also use `--stub=all` to stub all components, or `--stub=remote` to stub only
remote components (components that connect to external systems such as messaging brokers, databases, cloud services, etc.).
The `remote` flag uses the Camel catalog to determine which components are remote, so it automatically
handles new components without needing a hardcoded list.

[source,bash]
----
camel run syncToDatabase.java --stub=remote
----

Camel JBang comes with the `camel cmd stub` command that allows to list all endpoints that
has been stubbed, and also browse any messages that are currently present in their internal queues.
A stub endpoint is based on the `seda` component.
Expand Down Expand Up @@ -4292,7 +4302,7 @@ The camel.jbang supports 48 options, which are listed below.
| *camel.jbang.scriptFiles* | Additional shell script files to export to src/main/scripts directory | | String
| *camel.jbang.sourceDir* | Source directory for dynamically loading Camel file(s) to run. When using this, then files cannot be specified at the same time. | | String
| *camel.jbang.springBootVersion* | Spring Boot version | | String
| *camel.jbang.stub* | Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = everything). | | String
| *camel.jbang.stub* | Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints, remote = stub only remote components). | | String
| *camel.jbang.tlsFiles* | Additional SSL/TLS files to export to src/main/tls directory | | String
| *camel.jbang.verbose* | Verbose output of startup activity (dependency resolution and downloading | false | boolean
|===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ camel debug [options]
| `--source-dir` | Source directory for dynamically loading Camel file(s) to run. When using this, then files cannot be specified at the same time. | | String
| `--spring-boot-version` | Spring Boot version | RuntimeType.SPRING_BOOT_VERSION | String
| `--stop-on-exit` | Whether to stop the running Camel on exit | true | boolean
| `--stub` | Stubs all the matching endpoint uri with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints). | | String
| `--stub` | Stubs all the matching endpoint uri with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints, remote = stub only remote components). | | String
| `--timestamp` | Print timestamp. | true | boolean
| `--trace` | Enables trace logging of the routed messages | false | boolean
| `--verbose` | Verbose output of startup activity (dependency resolution and downloading | false | boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ camel dev [options]
| `--skip-plugins` | Skip resolving plugin dependencies | false | boolean
| `--source-dir` | Source directory for dynamically loading Camel file(s) to run. When using this, then files cannot be specified at the same time. | | String
| `--spring-boot-version` | Spring Boot version | RuntimeType.SPRING_BOOT_VERSION | String
| `--stub` | Stubs all the matching endpoint uri with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints). | | String
| `--stub` | Stubs all the matching endpoint uri with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints, remote = stub only remote components). | | String
| `--trace` | Enables trace logging of the routed messages | false | boolean
| `--verbose` | Verbose output of startup activity (dependency resolution and downloading | false | boolean
| `-h,--help` | Display the help and sub-commands | | boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ camel run [options]
| `--skip-plugins` | Skip resolving plugin dependencies | false | boolean
| `--source-dir` | Source directory for dynamically loading Camel file(s) to run. When using this, then files cannot be specified at the same time. | | String
| `--spring-boot-version` | Spring Boot version | RuntimeType.SPRING_BOOT_VERSION | String
| `--stub` | Stubs all the matching endpoint uri with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints). | | String
| `--stub` | Stubs all the matching endpoint uri with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints, remote = stub only remote components). | | String
| `--trace` | Enables trace logging of the routed messages | false | boolean
| `--verbose` | Verbose output of startup activity (dependency resolution and downloading | false | boolean
| `-h,--help` | Display the help and sub-commands | | boolean
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{ "name": "camel.jbang.scriptFiles", "required": false, "description": "Additional shell script files to export to src\/main\/scripts directory", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.sourceDir", "required": false, "description": "Source directory for dynamically loading Camel file(s) to run. When using this, then files cannot be specified at the same time.", "label": "advanced", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.springBootVersion", "required": false, "description": "Spring Boot version", "label": "spring-boot", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.stub", "required": false, "description": "Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = everything).", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.stub", "required": false, "description": "Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints, remote = stub only remote components).", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.tlsFiles", "required": false, "description": "Additional SSL\/TLS files to export to src\/main\/tls directory", "type": "string", "javaType": "String", "secret": false },
{ "name": "camel.jbang.verbose", "required": false, "description": "Verbose output of startup activity (dependency resolution and downloading", "type": "boolean", "javaType": "boolean", "defaultValue": false, "secret": false }
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ public class Run extends CamelCommand {
public String[] property;

@Option(names = { "--stub" }, description = "Stubs all the matching endpoint uri with the given component name or pattern."
+ " Multiple names can be separated by comma. (all = stub all endpoints).")
+ " Multiple names can be separated by comma."
+ " (all = stub all endpoints, remote = stub only remote components).")
String stub;

// jfr and jfrProfile options are in DebugOptions @ArgGroup
Expand Down Expand Up @@ -734,19 +735,24 @@ private int run() throws Exception {
if ("all".equals(stub)) {
// stub all components only
stub = "component:*";
}
// we need to match by wildcard, to make it easier
StringJoiner sj = new StringJoiner(",");
for (String n : stub.split(",")) {
// you can either refer to a name or a specific endpoint
// if there is a colon then we assume it's a specific endpoint then we should not add wildcard
boolean colon = n.contains(":");
if (!colon && !n.endsWith("*")) {
n = "component:" + n + "*";
} else if ("remote".equals(stub)) {
// stub only remote components (resolved via catalog)
stub = "component:remote";
}
if (!"component:remote".equals(stub)) {
// we need to match by wildcard, to make it easier
StringJoiner sj = new StringJoiner(",");
for (String n : stub.split(",")) {
// you can either refer to a name or a specific endpoint
// if there is a colon then we assume it's a specific endpoint then we should not add wildcard
boolean colon = n.contains(":");
if (!colon && !n.endsWith("*")) {
n = "component:" + n + "*";
}
sj.add(n);
}
sj.add(n);
stub = sj.toString();
}
stub = sj.toString();
writeSetting(main, profileProperties, STUB, stub);
main.setStubPattern(stub);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public final class CamelJBangConstants {
javaType = "String", defaultValue = "1.19.0", label = "kubernetes")
public static final String JKUBE_MAVEN_PLUGIN_VERSION = "camel.jbang.jkube-maven-plugin-version";

@Metadata(description = "Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = everything).",
@Metadata(description = "Stubs all the matching endpoint with the given component name or pattern. Multiple names can be separated by comma. (all = stub all endpoints, remote = stub only remote components).",
javaType = "String")
public static final String STUB = "camel.jbang.stub";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ List<String> buildArgs() {
args.add("--backlog-trace");
}
if (stubMode) {
args.add("--stub=all");
args.add("--stub=remote");
}
if (properties != null) {
for (PropertyEntry pe : properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ private boolean accept(String name) {
return true;
}

// stub only remote components (resolved via catalog)
if ("component:remote".equals(stubPattern)) {
ComponentModel model = catalog.componentModel(name);
return model == null || !model.isRemote();
}

boolean stubbed = false;
for (String n : stubPattern.split(",")) {
if (n.startsWith("component:")) {
Expand Down
Loading