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 2020/10/21 14:17:49 UTC
[camel-quarkus] 03/03: Main extension cannot load rest XML
definitions
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 2eab33c2eea54f7db57def4db0bc5cdb91d5c69a
Author: James Netherton <ja...@gmail.com>
AuthorDate: Wed Oct 21 13:28:10 2020 +0100
Main extension cannot load rest XML definitions
Fixes #1852
---
.../quarkus/main/CamelMainRoutesCollector.java | 53 ----------------------
1 file changed, 53 deletions(-)
diff --git a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRoutesCollector.java b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRoutesCollector.java
index db56da9..8595f53 100644
--- a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRoutesCollector.java
+++ b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRoutesCollector.java
@@ -16,22 +16,12 @@
*/
package org.apache.camel.quarkus.main;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Set;
import org.apache.camel.CamelContext;
-import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.RoutesBuilder;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.main.DefaultRoutesCollector;
-import org.apache.camel.model.rest.RestsDefinition;
import org.apache.camel.quarkus.core.RegistryRoutesLoader;
-import org.apache.camel.spi.PackageScanResourceResolver;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.StopWatch;
public class CamelMainRoutesCollector extends DefaultRoutesCollector {
private final RegistryRoutesLoader registryRoutesLoader;
@@ -52,47 +42,4 @@ public class CamelMainRoutesCollector extends DefaultRoutesCollector {
return registryRoutesLoader.collectRoutesFromRegistry(camelContext, excludePattern, includePattern);
}
-
- /**
- * TODO: Remove this when upgrading to Camel > 3.5.0.
- *
- * https://github.com/apache/camel-quarkus/issues/1852
- */
- @Override
- public List<RestsDefinition> collectXmlRestsFromDirectory(CamelContext camelContext, String directory) {
- ExtendedCamelContext ecc = camelContext.adapt(ExtendedCamelContext.class);
- PackageScanResourceResolver resolver = camelContext.adapt(ExtendedCamelContext.class).getPackageScanResourceResolver();
-
- List<RestsDefinition> answer = new ArrayList<>();
-
- StopWatch watch = new StopWatch();
- int count = 0;
- String[] parts = directory.split(",");
- for (String part : parts) {
- log.debug("Loading additional Camel XML rests from: {}", part);
- try {
- Set<InputStream> set = resolver.findResources(part);
- for (InputStream is : set) {
- log.debug("Found XML rest from location: {}", part);
- RestsDefinition rests = (RestsDefinition) ecc.getXMLRoutesDefinitionLoader().loadRestsDefinition(ecc, is);
- if (rests != null) {
- answer.add(rests);
- IOHelper.close(is);
- count += rests.getRests().size();
- }
- }
- } catch (FileNotFoundException e) {
- log.debug("No XML rests found in {}. Skipping XML rests detection.", part);
- } catch (Exception e) {
- throw RuntimeCamelException.wrapRuntimeException(e);
- }
- if (count > 0) {
- log.info("Loaded {} ({} millis) additional Camel XML rests from: {}", count, watch.taken(), directory);
- } else {
- log.info("No additional Camel XML rests discovered from: {}", directory);
- }
- }
-
- return answer;
- }
}