You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2022/10/17 15:42:43 UTC
[camel-quarkus] branch main updated: Add usage section to ref documentation for CDI integration
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 32841d0570 Add usage section to ref documentation for CDI integration
32841d0570 is described below
commit 32841d05702846b7797cacc659a741c219b3238f
Author: James Netherton <ja...@gmail.com>
AuthorDate: Mon Oct 17 14:54:56 2022 +0100
Add usage section to ref documentation for CDI integration
---
.../ROOT/pages/reference/extensions/ref.adoc | 45 ++++++++++++++++++++++
extensions/ref/runtime/src/main/doc/usage.adoc | 41 ++++++++++++++++++++
2 files changed, 86 insertions(+)
diff --git a/docs/modules/ROOT/pages/reference/extensions/ref.adoc b/docs/modules/ROOT/pages/reference/extensions/ref.adoc
index 8c10a6fd31..c27d0cbb02 100644
--- a/docs/modules/ROOT/pages/reference/extensions/ref.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/ref.adoc
@@ -44,3 +44,48 @@ Or add the coordinates to your existing project:
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]
+
+[id="extensions-ref-usage"]
+== Usage
+CDI producer methods can be harnessed to bind endpoints to the Camel registry, so that they can be resolved
+using the `ref` URI scheme in Camel routes.
+
+For example, to produce endpoint beans:
+
+[source,java]
+----
+@ApplicationScoped
+public class MyEndpointProducers {
+ @Inject
+ CamelContext context;
+
+ @Singleton
+ @Produces
+ @Named("endpoint1")
+ public Endpoint directStart() {
+ return context.getEndpoint("direct:start");
+ }
+
+ @Singleton
+ @Produces
+ @Named("endpoint2")
+ public Endpoint logEnd() {
+ return context.getEndpoint("log:end");
+ }
+}
+----
+
+Use `ref:` to refer to the names of the CDI beans that were bound to the Camel registry:
+
+[source,java]
+----
+public class MyRefRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ // direct:start -> log:end
+ from("ref:endpoint1")
+ .to("ref:endpoint2");
+ }
+}
+----
+
diff --git a/extensions/ref/runtime/src/main/doc/usage.adoc b/extensions/ref/runtime/src/main/doc/usage.adoc
new file mode 100644
index 0000000000..e21494d3ae
--- /dev/null
+++ b/extensions/ref/runtime/src/main/doc/usage.adoc
@@ -0,0 +1,41 @@
+CDI producer methods can be harnessed to bind endpoints to the Camel registry, so that they can be resolved
+using the `ref` URI scheme in Camel routes.
+
+For example, to produce endpoint beans:
+
+[source,java]
+----
+@ApplicationScoped
+public class MyEndpointProducers {
+ @Inject
+ CamelContext context;
+
+ @Singleton
+ @Produces
+ @Named("endpoint1")
+ public Endpoint directStart() {
+ return context.getEndpoint("direct:start");
+ }
+
+ @Singleton
+ @Produces
+ @Named("endpoint2")
+ public Endpoint logEnd() {
+ return context.getEndpoint("log:end");
+ }
+}
+----
+
+Use `ref:` to refer to the names of the CDI beans that were bound to the Camel registry:
+
+[source,java]
+----
+public class MyRefRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ // direct:start -> log:end
+ from("ref:endpoint1")
+ .to("ref:endpoint2");
+ }
+}
+----