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 2023/09/26 11:40:12 UTC

[camel-kamelets-examples] branch main updated: Use factory bean in example

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-kamelets-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new 890cf94  Use factory bean in example
890cf94 is described below

commit 890cf94f1901955e60bbe1562f3a6e33557af803
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Sep 26 13:38:35 2023 +0200

    Use factory bean in example
---
 jbang/blueprint-to-yaml/OrderHelper.java    | 14 ++++++++++++++
 jbang/blueprint-to-yaml/OrderService.java   |  5 -----
 jbang/blueprint-to-yaml/order-blueprint.xml |  4 +++-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/jbang/blueprint-to-yaml/OrderHelper.java b/jbang/blueprint-to-yaml/OrderHelper.java
new file mode 100644
index 0000000..06c9ab3
--- /dev/null
+++ b/jbang/blueprint-to-yaml/OrderHelper.java
@@ -0,0 +1,14 @@
+package com.foo;
+
+import com.foo.Address;
+
+public class OrderHelper {
+
+    public static OrderService newOrderService(boolean customer, Address address) {
+    	OrderService order = new OrderService();
+        order.setCustomer(customer ? "Acme" : "None");
+        order.setAddress(address);
+        return order;
+    }
+
+}
\ No newline at end of file
diff --git a/jbang/blueprint-to-yaml/OrderService.java b/jbang/blueprint-to-yaml/OrderService.java
index 3f2e86c..2bd5254 100644
--- a/jbang/blueprint-to-yaml/OrderService.java
+++ b/jbang/blueprint-to-yaml/OrderService.java
@@ -7,11 +7,6 @@ public class OrderService {
    private String customer;
    private Address address;
 
-   public OrderService(boolean customer, Address address) {
-       this.customer = customer ? "Acme" : "None";
-       this.address = address;
-   }
-
    public void setCustomer(String customer) {
        this.customer = customer;
    }
diff --git a/jbang/blueprint-to-yaml/order-blueprint.xml b/jbang/blueprint-to-yaml/order-blueprint.xml
index b71d868..3258183 100644
--- a/jbang/blueprint-to-yaml/order-blueprint.xml
+++ b/jbang/blueprint-to-yaml/order-blueprint.xml
@@ -5,7 +5,9 @@
            http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
 
    <!-- beans -->
-   <bean id="orderService" class="com.foo.OrderService">
+   <bean id="orderHelper" class="com.foo.OrderHelper"/>
+   <bean id="orderService" class="com.foo.OrderService"
+         factory-ref="orderHelper" factory-method="newOrderService">
        <argument index="0" value="true"/>
        <argument index="1" ref="office"/>
    </bean>