You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/11/09 14:32:25 UTC

[GitHub] [camel-quarkus] jamesnetherton commented on a diff in pull request #4266: controlbus: Added language tests (fixes #4008)

jamesnetherton commented on code in PR #4266:
URL: https://github.com/apache/camel-quarkus/pull/4266#discussion_r1018010978


##########
docs/modules/ROOT/pages/reference/extensions/controlbus.adoc:
##########
@@ -61,6 +64,61 @@ When using the `stats` command endpoint, the `camel-quarkus-management` extensio
 ----
 
 
+[id="extensions-controlbus-usage-languages"]
+=== Languages
+
+[id="extensions-controlbus-usage-bean"]
+==== Bean
+
+The Bean language can be used to invoke a method on a Bean to control the state of routes. The `org.apache.camel.quarkus:camel-quarkus-bean` extension must be added to the classpath. Maven users must add the following dependency to the POM:
+
+[source,xml]
+----
+<dependency>
+    <groupId>org.apache.camel.quarkus</groupId>
+    <artifactId>camel-quarkus-bean</artifactId>
+</dependency>
+----
+
+In native mode, the Bean class must be annotated with `@RegisterForReflection`.
+
+[id="extensions-controlbus-usage-simple"]
+==== Simple
+
+The Simple language can be used to control the state of routes. The following example uses a `ProducerTemplate` to stop a route with the id `foo`:
+
+[source,java]
+----
+template.sendBody(
+    "controlbus:language:simple", 
+    "${camelContext.getRouteController().stopRoute('foo')}"
+);
+----
+
+To use the OGNL notation, the `org.apache.camel.quarkus:camel-quarkus-bean` extension must be added as a dependency.
+
+In native mode, the classes used in the OGNL notation must be registered for reflection. In the above code snippet, the `org.apache.camel.spi.RouteController` class returned from `camelContext.getRouteController()` must be registered. As this is a third-party class, it cannot be annotated with `@RegisterForReflection` - instead you can the following config file to `src/main/resources/reflection-config.json`:

Review Comment:
   You can avoid `reflection-config.json` by either using `@RegisterForReflection` like this:
   
   ```java
   @RegisterForReflection(targets = { RouteController.class })
   public class Foo {
   }
   ```
   
   Or  with some config in `application.properties`:
   
   ```
   quarkus.camel.native.reflection.include-patterns = org.apache.camel.spi.RouteController
   ```
   
   The question is, should we leave this to the user as a manual task, or register `RouteController` for reflection in the controlbus extension in anticipation of the scripting functionality being used.
   
   WDYT @ppalaga 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org