syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [syncope] branch master updated: Restoring Camel scripting features for Groovy
Date Thu, 18 Jul 2019 13:12:03 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new c880152  Restoring Camel scripting features for Groovy
c880152 is described below

commit c880152a92095bde4e962c7d1d827abd27d02990
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
AuthorDate: Thu Jul 18 15:11:53 2019 +0200

    Restoring Camel scripting features for Groovy
---
 ext/camel/provisioning-camel/pom.xml                   |  4 ++++
 .../core/provisioning/camel/SyncopeCamelContext.java   | 18 ++++++++----------
 pom.xml                                                | 15 +++++++++++++++
 3 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/ext/camel/provisioning-camel/pom.xml b/ext/camel/provisioning-camel/pom.xml
index ded4831..68ea7c0 100644
--- a/ext/camel/provisioning-camel/pom.xml
+++ b/ext/camel/provisioning-camel/pom.xml
@@ -52,6 +52,10 @@ under the License.
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-groovy</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-metrics</artifactId>
     </dependency>
     <dependency>
diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java
b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java
index 5184074..19f8fc2 100644
--- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java
+++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/SyncopeCamelContext.java
@@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
-import org.apache.camel.CamelContext;
 import org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory;
 import org.apache.camel.model.ModelHelper;
 import org.apache.camel.model.RoutesDefinition;
@@ -49,7 +48,7 @@ public class SyncopeCamelContext {
 
     private SpringCamelContext camelContext;
 
-    public CamelContext getCamelContext() {
+    public SpringCamelContext getCamelContext() {
         synchronized (this) {
             if (camelContext == null) {
                 camelContext = ApplicationContextProvider.getBeanFactory().getBean(SpringCamelContext.class);
@@ -60,7 +59,7 @@ public class SyncopeCamelContext {
                 List<CamelRoute> routes = routeDAO.findAll();
                 LOG.debug("{} route(s) are going to be loaded ", routes.size());
 
-                loadRouteDefinitions(routes.stream().map(input -> input.getContent()).collect(Collectors.toList()));
+                loadRouteDefinitions(routes.stream().map(CamelRoute::getContent).collect(Collectors.toList()));
             }
         }
 
@@ -76,22 +75,22 @@ public class SyncopeCamelContext {
                             + "</routes>", StandardCharsets.UTF_8));
             camelContext.addRouteDefinitions(routeDefs.getRoutes());
         } catch (Exception e) {
-            LOG.error("While adding route definitions into Camel Context {}", camelContext,
e);
+            LOG.error("While adding route definitions into Camel Context {}", getCamelContext(),
e);
             throw new CamelException(e);
         }
     }
 
     @Transactional(propagation = Propagation.SUPPORTS)
     public void updateContext(final String routeKey) {
-        if (!camelContext.getRouteDefinitions().isEmpty()) {
-            camelContext.getRouteDefinitions().remove(camelContext.getRouteDefinition(routeKey));
+        if (!getCamelContext().getRouteDefinitions().isEmpty()) {
+            getCamelContext().getRouteDefinitions().remove(getCamelContext().getRouteDefinition(routeKey));
             loadRouteDefinitions(Arrays.asList(routeDAO.find(routeKey).getContent()));
         }
     }
 
     public void restoreRoute(final String routeKey, final String routeContent) {
         try {
-            camelContext.getRouteDefinitions().remove(camelContext.getRouteDefinition(routeKey));
+            getCamelContext().getRouteDefinitions().remove(getCamelContext().getRouteDefinition(routeKey));
             loadRouteDefinitions(Arrays.asList(routeContent));
         } catch (Exception e) {
             LOG.error("While restoring Camel route {}", routeKey, e);
@@ -101,12 +100,11 @@ public class SyncopeCamelContext {
 
     public void restartContext() {
         try {
-            camelContext.stop();
-            camelContext.start();
+            getCamelContext().stop();
+            getCamelContext().start();
         } catch (Exception e) {
             LOG.error("While restarting Camel context", e);
             throw new CamelException(e);
         }
     }
-
 }
diff --git a/pom.xml b/pom.xml
index 0a86e5d..ddf0e08 100644
--- a/pom.xml
+++ b/pom.xml
@@ -733,6 +733,21 @@ under the License.
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-groovy</artifactId>
+        <version>${camel.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-core</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-impl</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-metrics</artifactId>
         <version>${camel.version}</version>
         <exclusions>


Mime
View raw message