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 2021/02/11 16:49:15 UTC

[camel-spring-boot] branch master updated: CAMEL-16170: Modularize camel-spring

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

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/master by this push:
     new a352d47  CAMEL-16170: Modularize camel-spring
a352d47 is described below

commit a352d476fd69b08e0b79be57b81ff95e4a0e8aa4
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Feb 11 17:48:13 2021 +0100

    CAMEL-16170: Modularize camel-spring
---
 components-starter/camel-corda-starter/pom.xml     |   8 --
 .../FileLockClusterServiceAutoConfiguration.java   |   3 +-
 components-starter/camel-iota-starter/pom.xml      |  12 --
 core/camel-spring-boot/pom.xml                     |  19 +---
 .../camel/spring/boot/CamelAutoConfiguration.java  |   4 +-
 .../boot/CamelSpringBootBeanPostProcessor.java     |   2 +-
 .../boot/SpringBootXmlCamelContextConfigurer.java  |   2 +-
 .../ClusteredRouteControllerAutoConfiguration.java |   1 -
 .../spring/boot/cluster/TimePatternConverter.java  | 122 +++++++++++++++++++++
 tooling/camel-spring-boot-dependencies/pom.xml     |   5 +
 10 files changed, 137 insertions(+), 41 deletions(-)

diff --git a/components-starter/camel-corda-starter/pom.xml b/components-starter/camel-corda-starter/pom.xml
index 158a2e5..d667b96 100644
--- a/components-starter/camel-corda-starter/pom.xml
+++ b/components-starter/camel-corda-starter/pom.xml
@@ -41,14 +41,6 @@
       <!--START OF GENERATED CODE-->
       <exclusions>
         <exclusion>
-          <groupId>ch.qos.logback</groupId>
-          <artifactId>logback-classic</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>ch.qos.logback</groupId>
-          <artifactId>logback-core</artifactId>
-        </exclusion>
-        <exclusion>
           <groupId>org.apache.logging.log4j</groupId>
           <artifactId>log4j-core</artifactId>
         </exclusion>
diff --git a/components-starter/camel-file-starter/src/main/java/org/apache/camel/component/file/springboot/cluster/FileLockClusterServiceAutoConfiguration.java b/components-starter/camel-file-starter/src/main/java/org/apache/camel/component/file/springboot/cluster/FileLockClusterServiceAutoConfiguration.java
index c7baf91..fd5756c 100644
--- a/components-starter/camel-file-starter/src/main/java/org/apache/camel/component/file/springboot/cluster/FileLockClusterServiceAutoConfiguration.java
+++ b/components-starter/camel-file-starter/src/main/java/org/apache/camel/component/file/springboot/cluster/FileLockClusterServiceAutoConfiguration.java
@@ -16,15 +16,14 @@
  */
 package org.apache.camel.component.file.springboot.cluster;
 
-
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.camel.catalog.impl.TimePatternConverter;
 import org.apache.camel.cluster.CamelClusterService;
 import org.apache.camel.component.file.cluster.FileLockClusterService;
 import org.apache.camel.spring.boot.CamelAutoConfiguration;
 import org.apache.camel.spring.boot.cluster.ClusteredRouteControllerAutoConfiguration;
+import org.apache.camel.spring.boot.cluster.TimePatternConverter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
 import org.springframework.boot.autoconfigure.AutoConfigureBefore;
diff --git a/components-starter/camel-iota-starter/pom.xml b/components-starter/camel-iota-starter/pom.xml
index 758052f..95d1ad5 100644
--- a/components-starter/camel-iota-starter/pom.xml
+++ b/components-starter/camel-iota-starter/pom.xml
@@ -38,18 +38,6 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-iota</artifactId>
       <version>${camel-version}</version>
-      <!--START OF GENERATED CODE-->
-      <exclusions>
-        <exclusion>
-          <groupId>ch.qos.logback</groupId>
-          <artifactId>logback-classic</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>ch.qos.logback</groupId>
-          <artifactId>logback-core</artifactId>
-        </exclusion>
-      </exclusions>
-      <!--END OF GENERATED CODE-->
     </dependency>
     <!--START OF GENERATED CODE-->
     <dependency>
diff --git a/core/camel-spring-boot/pom.xml b/core/camel-spring-boot/pom.xml
index 8cf7b4f..5492ea3 100644
--- a/core/camel-spring-boot/pom.xml
+++ b/core/camel-spring-boot/pom.xml
@@ -26,7 +26,7 @@
         <groupId>org.apache.camel.springboot</groupId>
         <artifactId>core-modules</artifactId>
         <version>3.8.0-SNAPSHOT</version>
-        <relativePath>..</relativePath>
+        <relativePath>../pom.xml</relativePath>
     </parent>
 
     <name>Camel SB :: Spring Boot</name>
@@ -68,28 +68,24 @@
 
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-spring</artifactId>
+            <artifactId>camel-spring-xml</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-cloud</artifactId>
+            <artifactId>camel-spring-main</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-cluster</artifactId>
+            <artifactId>camel-cloud</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core-catalog</artifactId>
+            <artifactId>camel-cluster</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-health</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-main</artifactId>
-        </dependency>
 
         <!-- Optional Spring web support -->
         <dependency>
@@ -123,11 +119,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core-xml</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
             <artifactId>camel-management</artifactId>
             <scope>test</scope>
         </dependency>
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
index bc5f4c2..b8f1212 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
@@ -34,9 +34,9 @@ import org.apache.camel.main.RoutesCollector;
 import org.apache.camel.model.Model;
 import org.apache.camel.spi.BeanRepository;
 import org.apache.camel.spi.StartupStepRecorder;
-import org.apache.camel.spring.CamelBeanPostProcessor;
 import org.apache.camel.spring.spi.ApplicationContextBeanRepository;
-import org.apache.camel.spring.spi.XmlCamelContextConfigurer;
+import org.apache.camel.spring.xml.CamelBeanPostProcessor;
+import org.apache.camel.spring.xml.XmlCamelContextConfigurer;
 import org.apache.camel.support.CamelContextHelper;
 import org.apache.camel.support.DefaultRegistry;
 import org.apache.camel.support.startup.LoggingStartupStepRecorder;
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootBeanPostProcessor.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootBeanPostProcessor.java
index 0fcf5a7..6780c00 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootBeanPostProcessor.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootBeanPostProcessor.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.spring.boot;
 
-import org.apache.camel.spring.CamelBeanPostProcessor;
+import org.apache.camel.spring.xml.CamelBeanPostProcessor;
 import org.springframework.context.ApplicationContext;
 
 public final class CamelSpringBootBeanPostProcessor extends CamelBeanPostProcessor {
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootXmlCamelContextConfigurer.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootXmlCamelContextConfigurer.java
index 79c75f2..9c38c36 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootXmlCamelContextConfigurer.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringBootXmlCamelContextConfigurer.java
@@ -18,7 +18,7 @@ package org.apache.camel.spring.boot;
 
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spring.SpringCamelContext;
-import org.apache.camel.spring.spi.XmlCamelContextConfigurer;
+import org.apache.camel.spring.xml.XmlCamelContextConfigurer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.ApplicationContext;
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cluster/ClusteredRouteControllerAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cluster/ClusteredRouteControllerAutoConfiguration.java
index 7002d3d..de025a0 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cluster/ClusteredRouteControllerAutoConfiguration.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cluster/ClusteredRouteControllerAutoConfiguration.java
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 
-import org.apache.camel.catalog.impl.TimePatternConverter;
 import org.apache.camel.cluster.CamelClusterService;
 import org.apache.camel.impl.cluster.ClusteredRouteConfiguration;
 import org.apache.camel.impl.cluster.ClusteredRouteController;
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cluster/TimePatternConverter.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cluster/TimePatternConverter.java
new file mode 100644
index 0000000..40f0da7
--- /dev/null
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/cluster/TimePatternConverter.java
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.boot.cluster;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * This class is a copy from camel-core so we do not have direct dependency on internal classes
+ */
+public final class TimePatternConverter {
+    private static final Pattern NUMBERS_ONLY_STRING_PATTERN = Pattern.compile("^[-]?(\\d)+$", Pattern.CASE_INSENSITIVE);
+    private static final Pattern HOUR_REGEX_PATTERN = Pattern.compile("((\\d)*(\\d))h(our(s)?)?", Pattern.CASE_INSENSITIVE);
+    private static final Pattern MINUTES_REGEX_PATTERN
+            = Pattern.compile("((\\d)*(\\d))m(in(ute(s)?)?)?", Pattern.CASE_INSENSITIVE);
+    private static final Pattern SECONDS_REGEX_PATTERN
+            = Pattern.compile("((\\d)*(\\d))s(ec(ond)?(s)?)?", Pattern.CASE_INSENSITIVE);
+
+    /**
+     * Utility classes should not have a public constructor.
+     */
+    private TimePatternConverter() {
+    }
+
+    public static long toMilliSeconds(String source) throws IllegalArgumentException {
+        long milliseconds = 0;
+        boolean foundFlag = false;
+
+        checkCorrectnessOfPattern(source);
+        Matcher matcher;
+
+        matcher = createMatcher(NUMBERS_ONLY_STRING_PATTERN, source);
+        if (matcher.find()) {
+            // Note: This will also be used for regular numeric strings.
+            //       This String -> long converter will be used for all strings.
+            milliseconds = Long.valueOf(source);
+        } else {
+            matcher = createMatcher(HOUR_REGEX_PATTERN, source);
+            if (matcher.find()) {
+                milliseconds = milliseconds + (3600000 * Long.valueOf(matcher.group(1)));
+                foundFlag = true;
+            }
+
+            matcher = createMatcher(MINUTES_REGEX_PATTERN, source);
+            if (matcher.find()) {
+                long minutes = Long.valueOf(matcher.group(1));
+                if ((minutes > 59) && foundFlag) {
+                    throw new IllegalArgumentException("Minutes should contain a valid value between 0 and 59: " + source);
+                }
+                foundFlag = true;
+                milliseconds = milliseconds + (60000 * minutes);
+            }
+
+            matcher = createMatcher(SECONDS_REGEX_PATTERN, source);
+            if (matcher.find()) {
+                long seconds = Long.valueOf(matcher.group(1));
+                if ((seconds > 59) && foundFlag) {
+                    throw new IllegalArgumentException("Seconds should contain a valid value between 0 and 59: " + source);
+                }
+                foundFlag = true;
+                milliseconds = milliseconds + (1000 * seconds);
+            }
+
+            // No pattern matched... initiating fallback check and conversion (if required).
+            // The source at this point may contain illegal values or special characters
+            if (!foundFlag) {
+                milliseconds = Long.valueOf(source);
+            }
+        }
+
+        return milliseconds;
+    }
+
+    private static void checkCorrectnessOfPattern(String source) {
+        //replace only numbers once
+        Matcher matcher = createMatcher(NUMBERS_ONLY_STRING_PATTERN, source);
+        String replaceSource = matcher.replaceFirst("");
+
+        //replace hour string once
+        matcher = createMatcher(HOUR_REGEX_PATTERN, replaceSource);
+        if (matcher.find() && matcher.find()) {
+            throw new IllegalArgumentException("Hours should not be specified more then once: " + source);
+        }
+        replaceSource = matcher.replaceFirst("");
+
+        //replace minutes once
+        matcher = createMatcher(MINUTES_REGEX_PATTERN, replaceSource);
+        if (matcher.find() && matcher.find()) {
+            throw new IllegalArgumentException("Minutes should not be specified more then once: " + source);
+        }
+        replaceSource = matcher.replaceFirst("");
+
+        //replace seconds once
+        matcher = createMatcher(SECONDS_REGEX_PATTERN, replaceSource);
+        if (matcher.find() && matcher.find()) {
+            throw new IllegalArgumentException("Seconds should not be specified more then once: " + source);
+        }
+        replaceSource = matcher.replaceFirst("");
+
+        if (replaceSource.length() > 0) {
+            throw new IllegalArgumentException("Illegal characters: " + source);
+        }
+    }
+
+    private static Matcher createMatcher(Pattern pattern, String source) {
+        return pattern.matcher(source);
+    }
+}
diff --git a/tooling/camel-spring-boot-dependencies/pom.xml b/tooling/camel-spring-boot-dependencies/pom.xml
index f8428ac..c5f05df 100644
--- a/tooling/camel-spring-boot-dependencies/pom.xml
+++ b/tooling/camel-spring-boot-dependencies/pom.xml
@@ -3769,6 +3769,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-spring-xml</artifactId>
+        <version>3.8.0-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-sql</artifactId>
         <version>3.8.0-SNAPSHOT</version>
       </dependency>