You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2019/06/30 20:45:38 UTC

[camel] 02/02: upgrade the broken camel-example-cdi-osgi to the camel 3 API

This is an automated email from the ASF dual-hosted git repository.

bvahdat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0388d3a9424b25e9c70cfff2aa59851dfbc3d567
Author: Babak Vahdat <bv...@apache.org>
AuthorDate: Sun Jun 30 22:43:33 2019 +0200

    upgrade the broken camel-example-cdi-osgi to the camel 3 API
---
 examples/camel-example-cdi-osgi/README.md           | 21 +++++++++++++++++++--
 examples/camel-example-cdi-osgi/pom.xml             | 17 ++++++-----------
 .../org/apache/camel/example/cdi/osgi/Config.java   |  2 +-
 .../org/apache/camel/example/cdi/osgi/Consumer.java |  2 +-
 .../java/org/apache/camel/example/cdi/osgi/Jms.java |  4 ++--
 .../org/apache/camel/example/cdi/osgi/Producer.java |  4 ++--
 .../apache/camel/example/cdi/osgi/CdiOsgiIT.java    |  7 ++++---
 .../camel/example/cdi/osgi/PaxExamOptions.java      |  2 +-
 8 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/examples/camel-example-cdi-osgi/README.md b/examples/camel-example-cdi-osgi/README.md
index eec30d4..2d23df6 100644
--- a/examples/camel-example-cdi-osgi/README.md
+++ b/examples/camel-example-cdi-osgi/README.md
@@ -37,8 +37,25 @@ $ mvn camel:run
 When the Camel application starts, you should see the following message being logged to the console, e.g.:
 
 ```
-2016-02-01 20:13:46,922 [cdi.Main.main()] INFO  DefaultCamelContext - Apache Camel 2.17.0 (CamelContext: osgi-example) started in 0.769 seconds
-2016-02-01 20:13:47,008 [ Session Task-1] INFO  consumer-route      - Received message [Sample Message] from [Producer]
+2019-06-30 22:31:28,826 [cdi.Main.main()] INFO  Version                        - WELD-000900: 3.0.5 (Final)
+2019-06-30 22:31:29,152 [cdi.Main.main()] INFO  Bootstrap                      - WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
+2019-06-30 22:31:29,337 [cdi.Main.main()] INFO  Event                          - WELD-000411: Observer method [BackedAnnotatedMethod] private org.apache.camel.cdi.CdiCamelExtension.processAnnotatedType(@Observes ProcessAnnotatedType<?>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
+2019-06-30 22:31:30,010 [cdi.Main.main()] INFO  CdiCamelExtension              - Camel CDI is starting Camel context [osgi-example]
+2019-06-30 22:31:30,016 [cdi.Main.main()] INFO  DefaultCamelContext            - Apache Camel 3.0.0 (CamelContext: osgi-example) is starting
+2019-06-30 22:31:30,016 [cdi.Main.main()] INFO  DefaultCamelContext            - Tracing is enabled on CamelContext: osgi-example
+2019-06-30 22:31:30,017 [cdi.Main.main()] INFO  DefaultManagementStrategy      - JMX is disabled
+2019-06-30 22:31:30,367 [cdi.Main.main()] INFO  DefaultCamelContext            - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
+2019-06-30 22:31:30,434 [cdi.Main.main()] INFO  BrokerService                  - Using Persistence Adapter: MemoryPersistenceAdapter
+2019-06-30 22:31:30,594 [cdi.Main.main()] INFO  BrokerService                  - Apache ActiveMQ 5.15.9 (broker, ID:Babaks-iMac-50846-1561926690454-0:1) is starting
+2019-06-30 22:31:30,599 [cdi.Main.main()] INFO  BrokerService                  - Apache ActiveMQ 5.15.9 (broker, ID:Babaks-iMac-50846-1561926690454-0:1) started
+2019-06-30 22:31:30,599 [cdi.Main.main()] INFO  BrokerService                  - For help or more information please see: http://activemq.apache.org
+2019-06-30 22:31:30,626 [cdi.Main.main()] INFO  TransportConnector             - Connector vm://broker started
+2019-06-30 22:31:30,711 [cdi.Main.main()] INFO  DefaultCamelContext            - Route: consumer-route started and consuming from: sjms://sample.queue
+2019-06-30 22:31:30,713 [cdi.Main.main()] INFO  DefaultCamelContext            - Total 1 routes, of which 1 are started
+2019-06-30 22:31:30,714 [cdi.Main.main()] INFO  DefaultCamelContext            - Apache Camel 3.0.0 (CamelContext: osgi-example) started in 0.701 seconds
+2019-06-30 22:31:30,779 [ Session Task-1] INFO  consumer-route                 - Received message [Sample Message] from [Producer]
+2019-06-30 22:31:30,785 [cdi.Main.main()] INFO  Bootstrap                      - WELD-ENV-002003: Weld SE container 6dd6ff85-2756-49eb-ba0e-50d7feece6b6 initialized
+2019-06-30 22:31:30,792 [cdi.Main.main()] INFO  MainSupport                    - Using properties from classpath:application.properties
 ```
 
 The Camel application can be stopped pressing <kbd>ctrl</kbd>+<kbd>c</kbd> in the shell.
diff --git a/examples/camel-example-cdi-osgi/pom.xml b/examples/camel-example-cdi-osgi/pom.xml
index 5197469..9354e41 100644
--- a/examples/camel-example-cdi-osgi/pom.xml
+++ b/examples/camel-example-cdi-osgi/pom.xml
@@ -24,7 +24,7 @@
   <parent>
     <groupId>org.apache.camel.example</groupId>
     <artifactId>examples</artifactId>
-    <version>2.24.1</version>
+    <version>3.0.0-SNAPSHOT</version>
   </parent>
 
   <artifactId>camel-example-cdi-osgi</artifactId>
@@ -43,7 +43,7 @@
     <dependency>
       <groupId>javax.enterprise</groupId>
       <artifactId>cdi-api</artifactId>
-      <version>${cdi-api-1.2-version}</version>
+      <version>${cdi-api-2.0-version}</version>
       <scope>provided</scope>
     </dependency>
 
@@ -71,15 +71,10 @@
     <!-- OSGi API -->
     <dependency>
       <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
+      <artifactId>osgi.core</artifactId>
       <scope>provided</scope>
     </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.compendium</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    
+
     <!-- logging -->
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
@@ -238,8 +233,8 @@
           </dependency>
           <dependency>
             <groupId>org.jboss.weld.se</groupId>
-            <artifactId>weld-se</artifactId>
-            <version>${weld2-version}</version>
+            <artifactId>weld-se-shaded</artifactId>
+            <version>${weld3-version}</version>
           </dependency>
         </dependencies>
       </plugin>
diff --git a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Config.java b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Config.java
index 4af90c5..1129b7d 100644
--- a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Config.java
+++ b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Config.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
diff --git a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Consumer.java b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Consumer.java
index b524f45..216ff25 100644
--- a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Consumer.java
+++ b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Consumer.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
diff --git a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Jms.java b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Jms.java
index fe71c42..8aa0bb6 100644
--- a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Jms.java
+++ b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Jms.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -38,4 +38,4 @@ public class Jms {
         component.setConnectionCount(maxConnections);
         return component;
     }
-}
\ No newline at end of file
+}
diff --git a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Producer.java b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Producer.java
index dd508cc..1db322a 100644
--- a/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Producer.java
+++ b/examples/camel-example-cdi-osgi/src/main/java/org/apache/camel/example/cdi/osgi/Producer.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -20,7 +20,7 @@ import javax.enterprise.event.Observes;
 
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.cdi.Uri;
-import org.apache.camel.management.event.CamelContextStartedEvent;
+import org.apache.camel.spi.CamelEvent.CamelContextStartedEvent;
 
 public class Producer {
 
diff --git a/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java
index 2d7aaba..d6aefe4 100644
--- a/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java
+++ b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/CdiOsgiIT.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -23,6 +23,7 @@ import javax.inject.Inject;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ServiceStatus;
+import org.apache.camel.api.management.ManagedCamelContext;
 import org.apache.camel.api.management.mbean.ManagedRouteMBean;
 import org.apache.karaf.shell.api.console.Session;
 import org.apache.karaf.shell.api.console.SessionFactory;
@@ -83,12 +84,12 @@ public class CdiOsgiIT {
     @Test
     public void testRouteStatus() {
         assertThat("Route status is incorrect!",
-            context.getRouteStatus("consumer-route"), equalTo(ServiceStatus.Started));
+            context.getRouteController().getRouteStatus("consumer-route"), equalTo(ServiceStatus.Started));
     }
 
     @Test
     public void testExchangesCompleted() throws Exception {
-        ManagedRouteMBean route = context.getManagedRoute(context.getRoute("consumer-route").getId(), ManagedRouteMBean.class);
+        ManagedRouteMBean route = context.getExtension(ManagedCamelContext.class).getManagedRoute(context.getRoute("consumer-route").getId(), ManagedRouteMBean.class);
         assertThat("Number of exchanges completed is incorrect!",
             route.getExchangesCompleted(), equalTo(1L));
     }
diff --git a/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/PaxExamOptions.java b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/PaxExamOptions.java
index 5d1287c..840c1ab 100644
--- a/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/PaxExamOptions.java
+++ b/examples/camel-example-cdi-osgi/src/test/java/org/apache/camel/example/cdi/osgi/PaxExamOptions.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.