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 2016/11/07 16:50:47 UTC
[01/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Repository: camel
Updated Branches:
refs/heads/camel-2.18.x 961a18309 -> 7530b37ef
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/10a85071
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/10a85071
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/10a85071
Branch: refs/heads/camel-2.18.x
Commit: 10a85071aec9e648d161ed056659067940662dbe
Parents: 961a183
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 12:58:17 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 16:45:17 2016 +0100
----------------------------------------------------------------------
.../org/apache/camel/catalog/CamelCatalog.java | 11 +++
.../camel/catalog/DefaultCamelCatalog.java | 46 ++++-------
.../camel/catalog/DefaultRuntimeProvider.java | 87 ++++++++++++++++++++
.../apache/camel/catalog/RuntimeProvider.java | 53 ++++++++++++
4 files changed, 167 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/10a85071/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
index 5ee8714..426cd02 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/CamelCatalog.java
@@ -29,6 +29,17 @@ import javax.management.MXBean;
public interface CamelCatalog {
/**
+ * To plugin a custom {@link RuntimeProvider} that amends the catalog to only include information that is supported on the runtime.
+ */
+ void setRuntimeProvider(RuntimeProvider provider);
+
+ /**
+ * Gets the {@link RuntimeProvider} in use.
+ * @return
+ */
+ RuntimeProvider getRuntimeProvider();
+
+ /**
* Enables caching of the resources which makes the catalog faster, but keeps data in memory during caching.
* <p/>
* The catalog does not cache by default.
http://git-wip-us.apache.org/repos/asf/camel/blob/10a85071/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index 6f723b4..33ffccf 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -73,9 +73,6 @@ public class DefaultCamelCatalog implements CamelCatalog {
// CHECKSTYLE:OFF
private static final String MODELS_CATALOG = "org/apache/camel/catalog/models.properties";
- private static final String COMPONENTS_CATALOG = "org/apache/camel/catalog/components.properties";
- private static final String DATA_FORMATS_CATALOG = "org/apache/camel/catalog/dataformats.properties";
- private static final String LANGUAGE_CATALOG = "org/apache/camel/catalog/languages.properties";
private static final String MODEL_DIR = "org/apache/camel/catalog/models";
private static final String COMPONENT_DIR = "org/apache/camel/catalog/components";
private static final String DATAFORMAT_DIR = "org/apache/camel/catalog/dataformats";
@@ -100,6 +97,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
private boolean caching;
private SuggestionStrategy suggestionStrategy;
private VersionManager versionManager = new DefaultVersionManager(this);
+ private RuntimeProvider runtimeProvider = new DefaultRuntimeProvider(this);
/**
* Creates the {@link CamelCatalog} without caching enabled.
@@ -117,10 +115,21 @@ public class DefaultCamelCatalog implements CamelCatalog {
}
@Override
+ public RuntimeProvider getRuntimeProvider() {
+ return runtimeProvider;
+ }
+
+ @Override
+ public void setRuntimeProvider(RuntimeProvider runtimeProvider) {
+ this.runtimeProvider = runtimeProvider;
+ }
+
+ @Override
public void enableCache() {
caching = true;
}
+ @Override
public boolean isCaching() {
return caching;
}
@@ -210,15 +219,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
}
if (names == null) {
- names = new ArrayList<String>();
- InputStream is = versionManager.getResourceAsStream(COMPONENTS_CATALOG);
- if (is != null) {
- try {
- CatalogHelper.loadLines(is, names);
- } catch (IOException e) {
- // ignore
- }
- }
+ names = runtimeProvider.findComponentNames();
// include third party components
for (Map.Entry<String, String> entry : extraComponents.entrySet()) {
@@ -243,15 +244,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
}
if (names == null) {
- names = new ArrayList<String>();
- InputStream is = versionManager.getResourceAsStream(DATA_FORMATS_CATALOG);
- if (is != null) {
- try {
- CatalogHelper.loadLines(is, names);
- } catch (IOException e) {
- // ignore
- }
- }
+ names = runtimeProvider.findDataFormatNames();
// include third party data formats
for (Map.Entry<String, String> entry : extraDataFormats.entrySet()) {
@@ -276,15 +269,8 @@ public class DefaultCamelCatalog implements CamelCatalog {
}
if (names == null) {
- names = new ArrayList<String>();
- InputStream is = versionManager.getResourceAsStream(LANGUAGE_CATALOG);
- if (is != null) {
- try {
- CatalogHelper.loadLines(is, names);
- } catch (IOException e) {
- // ignore
- }
- }
+ names = runtimeProvider.findLanguageNames();
+
if (caching) {
cache.put("findLanguageNames", names);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/10a85071/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
new file mode 100644
index 0000000..f3e97d7
--- /dev/null
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
@@ -0,0 +1,87 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.catalog;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+public class DefaultRuntimeProvider implements RuntimeProvider {
+
+ private static final String COMPONENTS_CATALOG = "org/apache/camel/catalog/components.properties";
+ private static final String DATA_FORMATS_CATALOG = "org/apache/camel/catalog/dataformats.properties";
+ private static final String LANGUAGE_CATALOG = "org/apache/camel/catalog/languages.properties";
+
+ private final CamelCatalog camelCatalog;
+
+ public DefaultRuntimeProvider(CamelCatalog camelCatalog) {
+ this.camelCatalog = camelCatalog;
+ }
+
+ @Override
+ public CamelCatalog getCamelCatalog() {
+ return camelCatalog;
+ }
+
+ @Override
+ public String getProviderName() {
+ return "default";
+ }
+
+ @Override
+ public List<String> findComponentNames() {
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(COMPONENTS_CATALOG);
+ if (is != null) {
+ try {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return names;
+ }
+
+ @Override
+ public List<String> findDataFormatNames() {
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(DATA_FORMATS_CATALOG);
+ if (is != null) {
+ try {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return names;
+ }
+
+ @Override
+ public List<String> findLanguageNames() {
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(LANGUAGE_CATALOG);
+ if (is != null) {
+ try {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return names;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/10a85071/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
new file mode 100644
index 0000000..f3e8744
--- /dev/null
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
@@ -0,0 +1,53 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.catalog;
+
+import java.util.List;
+
+/**
+ * A pluggable strategy for chosen runtime to run Camel such as default, karaf, spring-boot, etc.
+ * This allows third party runtimes to provide their own provider, that can amend the catalog
+ * to match the runtime. For example spring-boot or karaf does not support all the default Camel components.
+ */
+public interface RuntimeProvider {
+
+ /**
+ * Gets the {@link CamelCatalog}
+ */
+ CamelCatalog getCamelCatalog();
+
+ /**
+ * Name of provider such as <tt>default</tt>, <tt>karaf</tt>, <tt>spring-boot</tt>
+ */
+ String getProviderName();
+
+ /**
+ * Find all the component names from the Camel catalog supported by the provider
+ */
+ List<String> findComponentNames();
+
+ /**
+ * Find all the data format names from the Camel catalog supported by the provider
+ */
+ List<String> findDataFormatNames();
+
+ /**
+ * Find all the language names from the Camel catalog supported by the provider
+ */
+ List<String> findLanguageNames();
+
+}
[03/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Posted by da...@apache.org.
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4c256b42
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4c256b42
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4c256b42
Branch: refs/heads/camel-2.18.x
Commit: 4c256b4279dc9fa7127ea1f29d3f9f7c475e3f86
Parents: fc27052
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 14:21:05 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 16:46:20 2016 +0100
----------------------------------------------------------------------
platforms/catalog-provider-karaf/pom.xml | 2 +-
.../catalog/karaf/KarafRuntimeProvider.java | 117 ++++++++++++++++++-
.../catalog/karaf/KarafRuntimeProviderTest.java | 93 +++++++++++++++
3 files changed, 208 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4c256b42/platforms/catalog-provider-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/pom.xml b/platforms/catalog-provider-karaf/pom.xml
index 9aafd73..6923faa 100644
--- a/platforms/catalog-provider-karaf/pom.xml
+++ b/platforms/catalog-provider-karaf/pom.xml
@@ -89,7 +89,7 @@
<goal>copy-resources</goal>
</goals>
<configuration>
- <outputDirectory>${basedir}/target/resources</outputDirectory>
+ <outputDirectory>${basedir}/target/classes/org/apache/camel/catalog/karaf</outputDirectory>
<resources>
<resource>
<directory>../karaf/features/target/classes</directory>
http://git-wip-us.apache.org/repos/asf/camel/blob/4c256b42/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java b/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
index 071d6e9..9c8ac17 100644
--- a/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
+++ b/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
@@ -16,14 +16,30 @@
*/
package org.apache.camel.catalog.karaf;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultRuntimeProvider;
+import org.apache.camel.catalog.JSonSchemaHelper;
import org.apache.camel.catalog.RuntimeProvider;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import static org.w3c.dom.Node.ELEMENT_NODE;
public class KarafRuntimeProvider implements RuntimeProvider {
+ private static final String FEATURES = "org/apache/camel/catalog/karaf/features.xml";
private CamelCatalog camelCatalog;
+ private DefaultRuntimeProvider defaultProvider = new DefaultRuntimeProvider();
+
+ private Map<String, List<Map<String, String>>> rowsCache = new HashMap<>();
@Override
public CamelCatalog getCamelCatalog() {
@@ -33,6 +49,7 @@ public class KarafRuntimeProvider implements RuntimeProvider {
@Override
public void setCamelCatalog(CamelCatalog camelCatalog) {
this.camelCatalog = camelCatalog;
+ this.defaultProvider.setCamelCatalog(camelCatalog);
}
@Override
@@ -42,17 +59,111 @@ public class KarafRuntimeProvider implements RuntimeProvider {
@Override
public List<String> findComponentNames() {
- // parse the karaf features xml file
- return null;
+ // find the component name from all the default components
+ List<String> allNames = defaultProvider.findComponentNames();
+
+ List<String> answer = new ArrayList<>();
+
+ // filter out to only include what's in the karaf features file
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(FEATURES);
+ if (is != null) {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setIgnoringComments(true);
+ dbf.setIgnoringElementContentWhitespace(true);
+ dbf.setNamespaceAware(false);
+ dbf.setValidating(false);
+ dbf.setXIncludeAware(false);
+ Document dom = dbf.newDocumentBuilder().parse(is);
+ NodeList children = dom.getElementsByTagName("features");
+
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == ELEMENT_NODE) {
+ NodeList children2 = child.getChildNodes();
+ for (int j = 0; j < children2.getLength(); j++) {
+ Node child2 = children2.item(j);
+ if ("feature".equals(child2.getNodeName())) {
+ // the name attribute is the maven artifact id of the component
+ String artifactId = child2.getAttributes().getNamedItem("name").getTextContent();
+ if (artifactId != null && artifactId.startsWith("camel-")) {
+ // find the component name based on the artifact id
+ String componentName = componentNameFromArtifactId(artifactId, allNames);
+ if (componentName != null) {
+ answer.add(componentName);
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ System.out.println("Total components " + allNames.size() + " karaf supports " + answer.size());
+
+ // clear temporary cache
+ rowsCache.clear();
+
+ return answer;
}
@Override
public List<String> findDataFormatNames() {
- return null;
+ // karaf support all data formats
+ return defaultProvider.findDataFormatNames();
}
@Override
public List<String> findLanguageNames() {
+ // karaf support all languages
+ return defaultProvider.findLanguageNames();
+ }
+
+ private String componentNameFromArtifactId(String artifactId, List<String> allNames) {
+ // try a quick shortcut that is faster
+ String quick = artifactId.startsWith("camel-") ? artifactId.substring(6) : null;
+ if (quick != null) {
+ String json = camelCatalog.componentJSonSchema(quick);
+ if (json != null) {
+ List<Map<String, String>> rows = rowsCache.get(quick);
+ if (rows == null) {
+ rows = JSonSchemaHelper.parseJsonSchema("component", json, false);
+ rowsCache.put(quick, rows);
+ }
+ String componentArtifactId = getArtifactId(rows);
+ if (artifactId.equals(componentArtifactId)) {
+ return quick;
+ }
+ }
+ }
+
+ for (String name : allNames) {
+ String json = camelCatalog.componentJSonSchema(name);
+ if (json != null) {
+ List<Map<String, String>> rows = rowsCache.get(quick);
+ if (rows == null) {
+ rows = JSonSchemaHelper.parseJsonSchema("component", json, false);
+ rowsCache.put(quick, rows);
+ }
+ String componentArtifactId = getArtifactId(rows);
+ if (artifactId.equals(componentArtifactId)) {
+ return name;
+ }
+ }
+ }
return null;
}
+
+ public static String getArtifactId(List<Map<String, String>> rows) {
+ for (Map<String, String> row : rows) {
+ if (row.get("artifactId") != null) {
+ return row.get("artifactId");
+ }
+ }
+ return null;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/4c256b42/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java b/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java
new file mode 100644
index 0000000..9d83d52
--- /dev/null
+++ b/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.catalog.karaf;
+
+import java.util.List;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class KarafRuntimeProviderTest {
+
+ static CamelCatalog catalog;
+
+ @BeforeClass
+ public static void createCamelCatalog() {
+ catalog = new DefaultCamelCatalog();
+ catalog.setRuntimeProvider(new KarafRuntimeProvider());
+ }
+
+ @Test
+ public void testGetVersion() throws Exception {
+ String version = catalog.getCatalogVersion();
+ assertNotNull(version);
+
+ String loaded = catalog.getLoadedVersion();
+ assertNotNull(loaded);
+ assertEquals(version, loaded);
+ }
+
+ @Test
+ public void testProviderName() throws Exception {
+ assertEquals("karaf", catalog.getRuntimeProvider().getProviderName());
+ }
+
+ @Test
+ public void testFindComponentNames() throws Exception {
+ List<String> names = catalog.findComponentNames();
+
+ assertNotNull(names);
+ assertFalse(names.isEmpty());
+
+ assertTrue(names.contains("ftp"));
+ assertTrue(names.contains("paxlogging"));
+ // camel-docker does not work in Karaf
+ assertFalse(names.contains("docker"));
+ }
+
+ @Test
+ public void testFindDataFormatNames() throws Exception {
+ List<String> names = catalog.findDataFormatNames();
+
+ assertNotNull(names);
+ assertFalse(names.isEmpty());
+
+ assertTrue(names.contains("bindy-csv"));
+ assertTrue(names.contains("zip"));
+ assertTrue(names.contains("zipfile"));
+ }
+
+ @Test
+ public void testFindLanguageNames() throws Exception {
+ List<String> names = catalog.findLanguageNames();
+
+ assertNotNull(names);
+ assertFalse(names.isEmpty());
+
+ assertTrue(names.contains("simple"));
+ assertTrue(names.contains("spel"));
+ assertTrue(names.contains("xpath"));
+ }
+
+}
[05/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Posted by da...@apache.org.
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/40ae4590
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/40ae4590
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/40ae4590
Branch: refs/heads/camel-2.18.x
Commit: 40ae45902a2635b88cb7ecab6e8874a591d581f0
Parents: 3ae1e2a
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 15:19:30 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 16:46:37 2016 +0100
----------------------------------------------------------------------
.../camel/maven/packaging/PrepareCatalogKarafMojo.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/40ae4590/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
index fc53c54..8ee7a15 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
@@ -509,10 +509,10 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
}
private Set<String> findKarafFeatures() throws MojoExecutionException, MojoFailureException {
- Set<String> answer = new LinkedHashSet<>();
+ // load features.xml file and parse it
+ Set<String> answer = new LinkedHashSet<>();
try {
- // load features.xml file
InputStream is = new FileInputStream(new File(featuresDir, "features.xml"));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
@@ -522,8 +522,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
dbf.setValidating(false);
dbf.setXIncludeAware(false);
Document dom = dbf.newDocumentBuilder().parse(is);
- NodeList children = dom.getElementsByTagName("features");
+ NodeList children = dom.getElementsByTagName("features");
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == ELEMENT_NODE) {
@@ -531,10 +531,8 @@ public class PrepareCatalogKarafMojo extends AbstractMojo {
for (int j = 0; j < children2.getLength(); j++) {
Node child2 = children2.item(j);
if ("feature".equals(child2.getNodeName())) {
- // the name attribute is the maven artifact id of the component
String artifactId = child2.getAttributes().getNamedItem("name").getTextContent();
if (artifactId != null && artifactId.startsWith("camel-")) {
- // find the component name based on the artifact id
answer.add(artifactId);
}
}
[09/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Posted by da...@apache.org.
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6fa97e6e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6fa97e6e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6fa97e6e
Branch: refs/heads/camel-2.18.x
Commit: 6fa97e6e1c70313456e47959ad5d1db1efca307e
Parents: 4830c6d
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 17:49:50 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 17:49:50 2016 +0100
----------------------------------------------------------------------
.../camel/catalog/springboot/SpringBootRuntimeProviderTest.java | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6fa97e6e/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java b/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
index 28aeb8a..f86c2aa 100644
--- a/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
+++ b/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
@@ -63,8 +63,6 @@ public class SpringBootRuntimeProviderTest {
assertTrue(names.contains("file"));
assertTrue(names.contains("ftp"));
assertTrue(names.contains("jms"));
- // camel-ejb does not work in spring-boot
- assertFalse(names.contains("ejb"));
// camel-pac-logging does not work in spring-boot
assertFalse(names.contains("paxlogging"));
}
[02/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Posted by da...@apache.org.
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fc270524
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fc270524
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fc270524
Branch: refs/heads/camel-2.18.x
Commit: fc27052429fa025f318b8890daeb765d2fd9c802
Parents: 10a8507
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 13:11:55 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 16:45:55 2016 +0100
----------------------------------------------------------------------
platforms/catalog-provider-karaf/pom.xml | 110 +++++++++++++++++++
.../catalog/karaf/KarafRuntimeProvider.java | 58 ++++++++++
.../camel/catalog/DefaultCamelCatalog.java | 2 +
.../camel/catalog/DefaultRuntimeProvider.java | 10 +-
.../apache/camel/catalog/RuntimeProvider.java | 10 ++
platforms/pom.xml | 7 +-
6 files changed, 194 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/fc270524/platforms/catalog-provider-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/pom.xml b/platforms/catalog-provider-karaf/pom.xml
new file mode 100644
index 0000000..9aafd73
--- /dev/null
+++ b/platforms/catalog-provider-karaf/pom.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <!--
+ 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.
+ -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>platforms</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-catalog-provider-karaf</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Platforms :: Catalog :: Provider Karaf</name>
+ <description>Camel Catalog Karaf</description>
+
+ <properties>
+ <camel.osgi.export.pkg>
+ org.apache.camel.catalog.karaf
+ </camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-catalog</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>${maven-resources-plugin-version}</version>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${basedir}/target/resources</outputDirectory>
+ <resources>
+ <resource>
+ <directory>../karaf/features/target/classes</directory>
+ <includes>
+ <include>features.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/fc270524/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java b/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
new file mode 100644
index 0000000..071d6e9
--- /dev/null
+++ b/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
@@ -0,0 +1,58 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.catalog.karaf;
+
+import java.util.List;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.RuntimeProvider;
+
+public class KarafRuntimeProvider implements RuntimeProvider {
+
+ private CamelCatalog camelCatalog;
+
+ @Override
+ public CamelCatalog getCamelCatalog() {
+ return camelCatalog;
+ }
+
+ @Override
+ public void setCamelCatalog(CamelCatalog camelCatalog) {
+ this.camelCatalog = camelCatalog;
+ }
+
+ @Override
+ public String getProviderName() {
+ return "karaf";
+ }
+
+ @Override
+ public List<String> findComponentNames() {
+ // parse the karaf features xml file
+ return null;
+ }
+
+ @Override
+ public List<String> findDataFormatNames() {
+ return null;
+ }
+
+ @Override
+ public List<String> findLanguageNames() {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/fc270524/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index 33ffccf..e498a7b 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -122,6 +122,8 @@ public class DefaultCamelCatalog implements CamelCatalog {
@Override
public void setRuntimeProvider(RuntimeProvider runtimeProvider) {
this.runtimeProvider = runtimeProvider;
+ // inject CamelCatalog to the provider
+ this.runtimeProvider.setCamelCatalog(this);
}
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/fc270524/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
index f3e97d7..a18d193 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
@@ -27,7 +27,10 @@ public class DefaultRuntimeProvider implements RuntimeProvider {
private static final String DATA_FORMATS_CATALOG = "org/apache/camel/catalog/dataformats.properties";
private static final String LANGUAGE_CATALOG = "org/apache/camel/catalog/languages.properties";
- private final CamelCatalog camelCatalog;
+ private CamelCatalog camelCatalog;
+
+ public DefaultRuntimeProvider() {
+ }
public DefaultRuntimeProvider(CamelCatalog camelCatalog) {
this.camelCatalog = camelCatalog;
@@ -39,6 +42,11 @@ public class DefaultRuntimeProvider implements RuntimeProvider {
}
@Override
+ public void setCamelCatalog(CamelCatalog camelCatalog) {
+ this.camelCatalog = camelCatalog;
+ }
+
+ @Override
public String getProviderName() {
return "default";
}
http://git-wip-us.apache.org/repos/asf/camel/blob/fc270524/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
index f3e8744..2ab844f 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
@@ -25,12 +25,22 @@ import java.util.List;
*/
public interface RuntimeProvider {
+ // TODO: maven archetype GAV
+ // original GAV
+ // spring-boot GAV
+ // karaf feature name
+
/**
* Gets the {@link CamelCatalog}
*/
CamelCatalog getCamelCatalog();
/**
+ * Sets the {@link CamelCatalog} to use
+ */
+ void setCamelCatalog(CamelCatalog camelCatalog);
+
+ /**
* Name of provider such as <tt>default</tt>, <tt>karaf</tt>, <tt>spring-boot</tt>
*/
String getProviderName();
http://git-wip-us.apache.org/repos/asf/camel/blob/fc270524/platforms/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/pom.xml b/platforms/pom.xml
index 289fea7..d0811ac 100644
--- a/platforms/pom.xml
+++ b/platforms/pom.xml
@@ -32,11 +32,14 @@
<packaging>pom</packaging>
<modules>
+ <module>commands</module>
+ <module>karaf</module>
+ <module>spring-boot</module>
+ <!-- run catalog last -->
<module>catalog</module>
<module>catalog-lucene</module>
<module>catalog-maven</module>
- <module>commands</module>
- <module>karaf</module>
+ <module>catalog-provider-karaf</module>
</modules>
</project>
[08/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Posted by da...@apache.org.
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4830c6db
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4830c6db
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4830c6db
Branch: refs/heads/camel-2.18.x
Commit: 4830c6db0093f2cbc7d87bbbb9a806b3e5e058ac
Parents: 84a5a6e
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 16:47:59 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 16:47:59 2016 +0100
----------------------------------------------------------------------
platforms/catalog-provider-karaf/pom.xml | 2 +-
platforms/catalog-provider-springboot/pom.xml | 2 +-
platforms/pom.xml | 1 -
3 files changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4830c6db/platforms/catalog-provider-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/pom.xml b/platforms/catalog-provider-karaf/pom.xml
index 5e56781..58be4c5 100644
--- a/platforms/catalog-provider-karaf/pom.xml
+++ b/platforms/catalog-provider-karaf/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>platforms</artifactId>
- <version>2.19.0-SNAPSHOT</version>
+ <version>2.18.1-SNAPSHOT</version>
</parent>
<artifactId>camel-catalog-provider-karaf</artifactId>
http://git-wip-us.apache.org/repos/asf/camel/blob/4830c6db/platforms/catalog-provider-springboot/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/pom.xml b/platforms/catalog-provider-springboot/pom.xml
index 557510f..197b4c0 100644
--- a/platforms/catalog-provider-springboot/pom.xml
+++ b/platforms/catalog-provider-springboot/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>platforms</artifactId>
- <version>2.19.0-SNAPSHOT</version>
+ <version>2.18.1-SNAPSHOT</version>
</parent>
<artifactId>camel-catalog-provider-springboot</artifactId>
http://git-wip-us.apache.org/repos/asf/camel/blob/4830c6db/platforms/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/pom.xml b/platforms/pom.xml
index e75d45f..fc6f361 100644
--- a/platforms/pom.xml
+++ b/platforms/pom.xml
@@ -34,7 +34,6 @@
<modules>
<module>commands</module>
<module>karaf</module>
- <module>spring-boot</module>
<!-- run catalog last -->
<module>catalog</module>
<module>catalog-lucene</module>
[04/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Posted by da...@apache.org.
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3ae1e2a2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3ae1e2a2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3ae1e2a2
Branch: refs/heads/camel-2.18.x
Commit: 3ae1e2a2dd30bd8d06d2a90f82eb5b317d1691f8
Parents: 4c256b4
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 15:13:41 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 16:46:27 2016 +0100
----------------------------------------------------------------------
platforms/catalog-provider-karaf/pom.xml | 24 +-
.../catalog/karaf/KarafRuntimeProvider.java | 144 ++---
.../catalog/karaf/KarafRuntimeProviderTest.java | 6 +-
.../packaging/PrepareCatalogKarafMojo.java | 551 +++++++++++++++++++
4 files changed, 597 insertions(+), 128 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/3ae1e2a2/platforms/catalog-provider-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/pom.xml b/platforms/catalog-provider-karaf/pom.xml
index 6923faa..bc2853a 100644
--- a/platforms/catalog-provider-karaf/pom.xml
+++ b/platforms/catalog-provider-karaf/pom.xml
@@ -77,28 +77,18 @@
<extensions>true</extensions>
</plugin>
+ <!-- generate and include all components in the catalog -->
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>${maven-resources-plugin-version}</version>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-package-maven-plugin</artifactId>
+ <version>${project.version}</version>
<executions>
<execution>
- <id>copy-resources</id>
- <phase>compile</phase>
+ <!-- prepare the catalog before the user guide / readme -->
<goals>
- <goal>copy-resources</goal>
+ <goal>prepare-catalog-karaf</goal>
</goals>
- <configuration>
- <outputDirectory>${basedir}/target/classes/org/apache/camel/catalog/karaf</outputDirectory>
- <resources>
- <resource>
- <directory>../karaf/features/target/classes</directory>
- <includes>
- <include>features.xml</include>
- </includes>
- </resource>
- </resources>
- </configuration>
+ <phase>process-resources</phase>
</execution>
</executions>
</plugin>
http://git-wip-us.apache.org/repos/asf/camel/blob/3ae1e2a2/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java b/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
index 9c8ac17..67c80c3 100644
--- a/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
+++ b/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
@@ -5,9 +5,9 @@
* 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * 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.
@@ -16,30 +16,26 @@
*/
package org.apache.camel.catalog.karaf;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.catalog.DefaultRuntimeProvider;
-import org.apache.camel.catalog.JSonSchemaHelper;
+import org.apache.camel.catalog.CatalogHelper;
import org.apache.camel.catalog.RuntimeProvider;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import static org.w3c.dom.Node.ELEMENT_NODE;
+/**
+ * A karaf based {@link RuntimeProvider} which only includes the supported Camel components, data formats, and languages
+ * which can be installed in Karaf using the Camel Karaf features.xml descriptor.
+ */
public class KarafRuntimeProvider implements RuntimeProvider {
- private static final String FEATURES = "org/apache/camel/catalog/karaf/features.xml";
- private CamelCatalog camelCatalog;
- private DefaultRuntimeProvider defaultProvider = new DefaultRuntimeProvider();
+ private static final String COMPONENTS_CATALOG = "org/apache/camel/catalog/karaf/components.properties";
+ private static final String DATA_FORMATS_CATALOG = "org/apache/camel/catalog/karaf/dataformats.properties";
+ private static final String LANGUAGE_CATALOG = "org/apache/camel/catalog/karaf/languages.properties";
- private Map<String, List<Map<String, String>>> rowsCache = new HashMap<>();
+ private CamelCatalog camelCatalog;
@Override
public CamelCatalog getCamelCatalog() {
@@ -49,7 +45,6 @@ public class KarafRuntimeProvider implements RuntimeProvider {
@Override
public void setCamelCatalog(CamelCatalog camelCatalog) {
this.camelCatalog = camelCatalog;
- this.defaultProvider.setCamelCatalog(camelCatalog);
}
@Override
@@ -59,111 +54,44 @@ public class KarafRuntimeProvider implements RuntimeProvider {
@Override
public List<String> findComponentNames() {
- // find the component name from all the default components
- List<String> allNames = defaultProvider.findComponentNames();
-
- List<String> answer = new ArrayList<>();
-
- // filter out to only include what's in the karaf features file
- InputStream is = camelCatalog.getVersionManager().getResourceAsStream(FEATURES);
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(COMPONENTS_CATALOG);
if (is != null) {
try {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setIgnoringComments(true);
- dbf.setIgnoringElementContentWhitespace(true);
- dbf.setNamespaceAware(false);
- dbf.setValidating(false);
- dbf.setXIncludeAware(false);
- Document dom = dbf.newDocumentBuilder().parse(is);
- NodeList children = dom.getElementsByTagName("features");
-
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == ELEMENT_NODE) {
- NodeList children2 = child.getChildNodes();
- for (int j = 0; j < children2.getLength(); j++) {
- Node child2 = children2.item(j);
- if ("feature".equals(child2.getNodeName())) {
- // the name attribute is the maven artifact id of the component
- String artifactId = child2.getAttributes().getNamedItem("name").getTextContent();
- if (artifactId != null && artifactId.startsWith("camel-")) {
- // find the component name based on the artifact id
- String componentName = componentNameFromArtifactId(artifactId, allNames);
- if (componentName != null) {
- answer.add(componentName);
- }
- }
- }
- }
- }
- }
- } catch (Exception e) {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
// ignore
}
}
-
- System.out.println("Total components " + allNames.size() + " karaf supports " + answer.size());
-
- // clear temporary cache
- rowsCache.clear();
-
- return answer;
+ return names;
}
@Override
public List<String> findDataFormatNames() {
- // karaf support all data formats
- return defaultProvider.findDataFormatNames();
- }
-
- @Override
- public List<String> findLanguageNames() {
- // karaf support all languages
- return defaultProvider.findLanguageNames();
- }
-
- private String componentNameFromArtifactId(String artifactId, List<String> allNames) {
- // try a quick shortcut that is faster
- String quick = artifactId.startsWith("camel-") ? artifactId.substring(6) : null;
- if (quick != null) {
- String json = camelCatalog.componentJSonSchema(quick);
- if (json != null) {
- List<Map<String, String>> rows = rowsCache.get(quick);
- if (rows == null) {
- rows = JSonSchemaHelper.parseJsonSchema("component", json, false);
- rowsCache.put(quick, rows);
- }
- String componentArtifactId = getArtifactId(rows);
- if (artifactId.equals(componentArtifactId)) {
- return quick;
- }
- }
- }
-
- for (String name : allNames) {
- String json = camelCatalog.componentJSonSchema(name);
- if (json != null) {
- List<Map<String, String>> rows = rowsCache.get(quick);
- if (rows == null) {
- rows = JSonSchemaHelper.parseJsonSchema("component", json, false);
- rowsCache.put(quick, rows);
- }
- String componentArtifactId = getArtifactId(rows);
- if (artifactId.equals(componentArtifactId)) {
- return name;
- }
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(DATA_FORMATS_CATALOG);
+ if (is != null) {
+ try {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
+ // ignore
}
}
- return null;
+ return names;
}
- public static String getArtifactId(List<Map<String, String>> rows) {
- for (Map<String, String> row : rows) {
- if (row.get("artifactId") != null) {
- return row.get("artifactId");
+ @Override
+ public List<String> findLanguageNames() {
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(LANGUAGE_CATALOG);
+ if (is != null) {
+ try {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
+ // ignore
}
}
- return null;
+ return names;
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/3ae1e2a2/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java b/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java
index 9d83d52..c652b2f 100644
--- a/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java
+++ b/platforms/catalog-provider-karaf/src/test/java/org/apache/camel/catalog/karaf/KarafRuntimeProviderTest.java
@@ -5,9 +5,9 @@
* 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * 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.
http://git-wip-us.apache.org/repos/asf/camel/blob/3ae1e2a2/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
new file mode 100644
index 0000000..fc53c54
--- /dev/null
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogKarafMojo.java
@@ -0,0 +1,551 @@
+/**
+ * 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.maven.packaging;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import static org.w3c.dom.Node.ELEMENT_NODE;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+
+import static org.apache.camel.maven.packaging.PackageHelper.loadText;
+
+/**
+ * Prepares the Karaf provider camel catalog to include component it supports
+ *
+ * @goal prepare-catalog-karaf
+ */
+public class PrepareCatalogKarafMojo extends AbstractMojo {
+
+ public static final int BUFFER_SIZE = 128 * 1024;
+
+ /**
+ * The maven project.
+ *
+ * @parameter property="project"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * The output directory for components catalog
+ *
+ * @parameter default-value="${project.build.directory}/classes/org/apache/camel/catalog/karaf/components"
+ */
+ protected File componentsOutDir;
+
+ /**
+ * The output directory for dataformats catalog
+ *
+ * @parameter default-value="${project.build.directory}/classes/org/apache/camel/catalog/karaf/dataformats"
+ */
+ protected File dataFormatsOutDir;
+
+ /**
+ * The output directory for languages catalog
+ *
+ * @parameter default-value="${project.build.directory}/classes/org/apache/camel/catalog/karaf/languages"
+ */
+ protected File languagesOutDir;
+
+ /**
+ * The karaf features directory
+ *
+ * @parameter default-value="${project.build.directory}/../../../platforms/karaf/features/src/main/resources/"
+ */
+ protected File featuresDir;
+
+ /**
+ * The components directory where all the Apache Camel components are
+ *
+ * @parameter default-value="${project.build.directory}/../../../components"
+ */
+ protected File componentsDir;
+
+ /**
+ * The camel-core directory where camel-core components are
+ *
+ * @parameter default-value="${project.build.directory}/../../../camel-core"
+ */
+ protected File coreDir;
+
+ /**
+ * Maven ProjectHelper.
+ *
+ * @component
+ * @readonly
+ */
+ private MavenProjectHelper projectHelper;
+
+ /**
+ * Execute goal.
+ *
+ * @throws MojoExecutionException execution of the main class or one of the
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ Set<String> features = findKarafFeatures();
+ executeComponents(features);
+ executeDataFormats(features);
+ executeLanguages(features);
+ }
+
+ protected void executeComponents(Set<String> features) throws MojoExecutionException, MojoFailureException {
+ getLog().info("Copying all Camel component json descriptors");
+
+ // lets use sorted set/maps
+ Set<File> jsonFiles = new TreeSet<File>();
+ Set<File> componentFiles = new TreeSet<File>();
+
+ // find all json files in components and camel-core
+ if (componentsDir != null && componentsDir.isDirectory()) {
+ File[] components = componentsDir.listFiles();
+ if (components != null) {
+ for (File dir : components) {
+ // skip camel-spring-dm
+ if (dir.isDirectory() && "camel-spring-dm".equals(dir.getName())) {
+ continue;
+ }
+
+
+ if (dir.isDirectory() && !"target".equals(dir.getName())) {
+ File target = new File(dir, "target/classes");
+
+ // the directory must be in the list of known features
+ if (!features.contains(dir.getName())) {
+ continue;
+ }
+
+ // special for camel-salesforce which is in a sub dir
+ if ("camel-salesforce".equals(dir.getName())) {
+ target = new File(dir, "camel-salesforce-component/target/classes");
+ } else if ("camel-linkedin".equals(dir.getName())) {
+ target = new File(dir, "camel-linkedin-component/target/classes");
+ }
+
+
+ findComponentFilesRecursive(target, jsonFiles, componentFiles, new CamelComponentsFileFilter());
+ }
+ }
+ }
+ }
+ if (coreDir != null && coreDir.isDirectory()) {
+ File target = new File(coreDir, "target/classes");
+ findComponentFilesRecursive(target, jsonFiles, componentFiles, new CamelComponentsFileFilter());
+ }
+
+ getLog().info("Found " + componentFiles.size() + " component.properties files");
+ getLog().info("Found " + jsonFiles.size() + " component json files");
+
+ // make sure to create out dir
+ componentsOutDir.mkdirs();
+
+ Set<String> alternativeSchemes = new HashSet<>();
+
+ for (File file : jsonFiles) {
+ File to = new File(componentsOutDir, file.getName());
+ try {
+ copyFile(file, to);
+ } catch (IOException e) {
+ throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ }
+ }
+
+ File all = new File(componentsOutDir, "../components.properties");
+ try {
+ FileOutputStream fos = new FileOutputStream(all, false);
+
+ String[] names = componentsOutDir.list();
+ List<String> components = new ArrayList<String>();
+ // sort the names
+ for (String name : names) {
+ if (name.endsWith(".json")) {
+ // strip out .json from the name
+ String componentName = name.substring(0, name.length() - 5);
+ components.add(componentName);
+ }
+ }
+
+ Collections.sort(components);
+ for (String name : components) {
+ fos.write(name.getBytes());
+ fos.write("\n".getBytes());
+ }
+
+ fos.close();
+
+ } catch (IOException e) {
+ throw new MojoFailureException("Error writing to file " + all);
+ }
+ }
+
+ protected void executeDataFormats(Set<String> features) throws MojoExecutionException, MojoFailureException {
+ getLog().info("Copying all Camel dataformat json descriptors");
+
+ // lets use sorted set/maps
+ Set<File> jsonFiles = new TreeSet<File>();
+ Set<File> dataFormatFiles = new TreeSet<File>();
+
+ // find all data formats from the components directory
+ if (componentsDir != null && componentsDir.isDirectory()) {
+ File[] dataFormats = componentsDir.listFiles();
+ if (dataFormats != null) {
+ for (File dir : dataFormats) {
+ if (dir.isDirectory() && !"target".equals(dir.getName())) {
+ // skip camel-spring-dm
+ if (dir.isDirectory() && "camel-spring-dm".equals(dir.getName())) {
+ continue;
+ }
+ // the directory must be in the list of known features
+ if (!features.contains(dir.getName())) {
+ continue;
+ }
+ File target = new File(dir, "target/classes");
+ findDataFormatFilesRecursive(target, jsonFiles, dataFormatFiles, new CamelDataFormatsFileFilter());
+ }
+ }
+ }
+ }
+ if (coreDir != null && coreDir.isDirectory()) {
+ File target = new File(coreDir, "target/classes");
+ findDataFormatFilesRecursive(target, jsonFiles, dataFormatFiles, new CamelDataFormatsFileFilter());
+ }
+
+ getLog().info("Found " + dataFormatFiles.size() + " dataformat.properties files");
+ getLog().info("Found " + jsonFiles.size() + " dataformat json files");
+
+ // make sure to create out dir
+ dataFormatsOutDir.mkdirs();
+
+ for (File file : jsonFiles) {
+ File to = new File(dataFormatsOutDir, file.getName());
+ try {
+ copyFile(file, to);
+ } catch (IOException e) {
+ throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ }
+ }
+
+ File all = new File(dataFormatsOutDir, "../dataformats.properties");
+ try {
+ FileOutputStream fos = new FileOutputStream(all, false);
+
+ String[] names = dataFormatsOutDir.list();
+ List<String> dataFormats = new ArrayList<String>();
+ // sort the names
+ for (String name : names) {
+ if (name.endsWith(".json")) {
+ // strip out .json from the name
+ String dataFormatName = name.substring(0, name.length() - 5);
+ dataFormats.add(dataFormatName);
+ }
+ }
+
+ Collections.sort(dataFormats);
+ for (String name : dataFormats) {
+ fos.write(name.getBytes());
+ fos.write("\n".getBytes());
+ }
+
+ fos.close();
+
+ } catch (IOException e) {
+ throw new MojoFailureException("Error writing to file " + all);
+ }
+ }
+
+ protected void executeLanguages(Set<String> features) throws MojoExecutionException, MojoFailureException {
+ getLog().info("Copying all Camel language json descriptors");
+
+ // lets use sorted set/maps
+ Set<File> jsonFiles = new TreeSet<File>();
+ Set<File> languageFiles = new TreeSet<File>();
+
+ // find all languages from the components directory
+ if (componentsDir != null && componentsDir.isDirectory()) {
+ File[] languages = componentsDir.listFiles();
+ if (languages != null) {
+ for (File dir : languages) {
+ // skip camel-spring-dm
+ if (dir.isDirectory() && "camel-spring-dm".equals(dir.getName())) {
+ continue;
+ }
+ // the directory must be in the list of known features
+ if (!features.contains(dir.getName())) {
+ continue;
+ }
+ if (dir.isDirectory() && !"target".equals(dir.getName())) {
+ File target = new File(dir, "target/classes");
+ findLanguageFilesRecursive(target, jsonFiles, languageFiles, new CamelLanguagesFileFilter());
+ }
+ }
+ }
+ }
+ if (coreDir != null && coreDir.isDirectory()) {
+ File target = new File(coreDir, "target/classes");
+ findLanguageFilesRecursive(target, jsonFiles, languageFiles, new CamelLanguagesFileFilter());
+ }
+
+ getLog().info("Found " + languageFiles.size() + " language.properties files");
+ getLog().info("Found " + jsonFiles.size() + " language json files");
+
+ // make sure to create out dir
+ languagesOutDir.mkdirs();
+
+ for (File file : jsonFiles) {
+ File to = new File(languagesOutDir, file.getName());
+ try {
+ copyFile(file, to);
+ } catch (IOException e) {
+ throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ }
+ }
+
+ File all = new File(languagesOutDir, "../languages.properties");
+ try {
+ FileOutputStream fos = new FileOutputStream(all, false);
+
+ String[] names = languagesOutDir.list();
+ List<String> languages = new ArrayList<String>();
+ // sort the names
+ for (String name : names) {
+ if (name.endsWith(".json")) {
+ // strip out .json from the name
+ String languageName = name.substring(0, name.length() - 5);
+ languages.add(languageName);
+ }
+ }
+
+ Collections.sort(languages);
+ for (String name : languages) {
+ fos.write(name.getBytes());
+ fos.write("\n".getBytes());
+ }
+
+ fos.close();
+
+ } catch (IOException e) {
+ throw new MojoFailureException("Error writing to file " + all);
+ }
+ }
+
+ private void findComponentFilesRecursive(File dir, Set<File> found, Set<File> components, FileFilter filter) {
+ File[] files = dir.listFiles(filter);
+ if (files != null) {
+ for (File file : files) {
+ // skip files in root dirs as Camel does not store information there but others may do
+ boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
+ boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
+ boolean componentFile = !rootDir && file.isFile() && file.getName().equals("component.properties");
+ if (jsonFile) {
+ found.add(file);
+ } else if (componentFile) {
+ components.add(file);
+ } else if (file.isDirectory()) {
+ findComponentFilesRecursive(file, found, components, filter);
+ }
+ }
+ }
+ }
+
+ private void findDataFormatFilesRecursive(File dir, Set<File> found, Set<File> dataFormats, FileFilter filter) {
+ File[] files = dir.listFiles(filter);
+ if (files != null) {
+ for (File file : files) {
+ // skip files in root dirs as Camel does not store information there but others may do
+ boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
+ boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
+ boolean dataFormatFile = !rootDir && file.isFile() && file.getName().equals("dataformat.properties");
+ if (jsonFile) {
+ found.add(file);
+ } else if (dataFormatFile) {
+ dataFormats.add(file);
+ } else if (file.isDirectory()) {
+ findDataFormatFilesRecursive(file, found, dataFormats, filter);
+ }
+ }
+ }
+ }
+
+ private void findLanguageFilesRecursive(File dir, Set<File> found, Set<File> languages, FileFilter filter) {
+ File[] files = dir.listFiles(filter);
+ if (files != null) {
+ for (File file : files) {
+ // skip files in root dirs as Camel does not store information there but others may do
+ boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
+ boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
+ boolean languageFile = !rootDir && file.isFile() && file.getName().equals("language.properties");
+ if (jsonFile) {
+ found.add(file);
+ } else if (languageFile) {
+ languages.add(file);
+ } else if (file.isDirectory()) {
+ findLanguageFilesRecursive(file, found, languages, filter);
+ }
+ }
+ }
+ }
+
+ private class CamelComponentsFileFilter implements FileFilter {
+
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory() && pathname.getName().equals("model")) {
+ // do not check the camel-core model packages as there is no components there
+ return false;
+ }
+ if (pathname.isFile() && pathname.getName().endsWith(".json")) {
+ // must be a components json file
+ try {
+ String json = loadText(new FileInputStream(pathname));
+ return json != null && json.contains("\"kind\": \"component\"");
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("component.properties"));
+ }
+ }
+
+ private class CamelDataFormatsFileFilter implements FileFilter {
+
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory() && pathname.getName().equals("model")) {
+ // do not check the camel-core model packages as there is no components there
+ return false;
+ }
+ if (pathname.isFile() && pathname.getName().endsWith(".json")) {
+ // must be a dataformat json file
+ try {
+ String json = loadText(new FileInputStream(pathname));
+ return json != null && json.contains("\"kind\": \"dataformat\"");
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("dataformat.properties"));
+ }
+ }
+
+ private class CamelLanguagesFileFilter implements FileFilter {
+
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory() && pathname.getName().equals("model")) {
+ // do not check the camel-core model packages as there is no components there
+ return false;
+ }
+ if (pathname.isFile() && pathname.getName().endsWith(".json")) {
+ // must be a language json file
+ try {
+ String json = loadText(new FileInputStream(pathname));
+ return json != null && json.contains("\"kind\": \"language\"");
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("language.properties"));
+ }
+ }
+
+ public static void copyFile(File from, File to) throws IOException {
+ FileChannel in = null;
+ FileChannel out = null;
+ try {
+ in = new FileInputStream(from).getChannel();
+ out = new FileOutputStream(to).getChannel();
+
+ long size = in.size();
+ long position = 0;
+ while (position < size) {
+ position += in.transferTo(position, BUFFER_SIZE, out);
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ private Set<String> findKarafFeatures() throws MojoExecutionException, MojoFailureException {
+ Set<String> answer = new LinkedHashSet<>();
+
+ try {
+ // load features.xml file
+ InputStream is = new FileInputStream(new File(featuresDir, "features.xml"));
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setIgnoringComments(true);
+ dbf.setIgnoringElementContentWhitespace(true);
+ dbf.setNamespaceAware(false);
+ dbf.setValidating(false);
+ dbf.setXIncludeAware(false);
+ Document dom = dbf.newDocumentBuilder().parse(is);
+ NodeList children = dom.getElementsByTagName("features");
+
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == ELEMENT_NODE) {
+ NodeList children2 = child.getChildNodes();
+ for (int j = 0; j < children2.getLength(); j++) {
+ Node child2 = children2.item(j);
+ if ("feature".equals(child2.getNodeName())) {
+ // the name attribute is the maven artifact id of the component
+ String artifactId = child2.getAttributes().getNamedItem("name").getTextContent();
+ if (artifactId != null && artifactId.startsWith("camel-")) {
+ // find the component name based on the artifact id
+ answer.add(artifactId);
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error reading features.xml file", e);
+ }
+
+ return answer;
+ }
+
+}
\ No newline at end of file
[06/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Posted by da...@apache.org.
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/473d90a3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/473d90a3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/473d90a3
Branch: refs/heads/camel-2.18.x
Commit: 473d90a348e7ff784cfdadcea70ca4f6d0f188a0
Parents: 40ae459
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 15:35:55 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 16:46:44 2016 +0100
----------------------------------------------------------------------
platforms/catalog-provider-karaf/pom.xml | 1 -
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
platforms/catalog-provider-springboot/pom.xml | 99 ++++
.../springboot/SpringBootRuntimeProvider.java | 97 ++++
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../SpringBootRuntimeProviderTest.java | 96 ++++
platforms/pom.xml | 1 +
.../packaging/PrepareCatalogSpringBootMojo.java | 520 +++++++++++++++++++
10 files changed, 1241 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/catalog-provider-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/pom.xml b/platforms/catalog-provider-karaf/pom.xml
index bc2853a..5e56781 100644
--- a/platforms/catalog-provider-karaf/pom.xml
+++ b/platforms/catalog-provider-karaf/pom.xml
@@ -84,7 +84,6 @@
<version>${project.version}</version>
<executions>
<execution>
- <!-- prepare the catalog before the user guide / readme -->
<goals>
<goal>prepare-catalog-karaf</goal>
</goals>
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/catalog-provider-karaf/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/src/main/resources/META-INF/LICENSE.txt b/platforms/catalog-provider-karaf/src/main/resources/META-INF/LICENSE.txt
new file mode 100755
index 0000000..6b0b127
--- /dev/null
+++ b/platforms/catalog-provider-karaf/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/catalog-provider-karaf/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/src/main/resources/META-INF/NOTICE.txt b/platforms/catalog-provider-karaf/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/platforms/catalog-provider-karaf/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/catalog-provider-springboot/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/pom.xml b/platforms/catalog-provider-springboot/pom.xml
new file mode 100644
index 0000000..557510f
--- /dev/null
+++ b/platforms/catalog-provider-springboot/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <!--
+ 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.
+ -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>platforms</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-catalog-provider-springboot</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Platforms :: Catalog :: Provider Spring Boot</name>
+ <description>Camel Catalog Spring Boot</description>
+
+ <properties>
+ <camel.osgi.export.pkg>
+ org.apache.camel.catalog.springboot
+ </camel.osgi.export.pkg>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-catalog</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+
+ <!-- generate and include all components in the catalog -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-package-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>prepare-catalog-springboot</goal>
+ </goals>
+ <phase>process-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java b/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java
new file mode 100644
index 0000000..8b61ede
--- /dev/null
+++ b/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java
@@ -0,0 +1,97 @@
+/**
+ * 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.catalog.springboot;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.CatalogHelper;
+import org.apache.camel.catalog.RuntimeProvider;
+
+/**
+ * A Spring Boot based {@link RuntimeProvider} which only includes the supported Camel components, data formats, and languages
+ * which can be installed in Spring Boot using the starter dependencies.
+ */
+public class SpringBootRuntimeProvider implements RuntimeProvider {
+
+ private static final String COMPONENTS_CATALOG = "org/apache/camel/catalog/springboot/components.properties";
+ private static final String DATA_FORMATS_CATALOG = "org/apache/camel/catalog/springboot/dataformats.properties";
+ private static final String LANGUAGE_CATALOG = "org/apache/camel/catalog/springboot/languages.properties";
+
+ private CamelCatalog camelCatalog;
+
+ @Override
+ public CamelCatalog getCamelCatalog() {
+ return camelCatalog;
+ }
+
+ @Override
+ public void setCamelCatalog(CamelCatalog camelCatalog) {
+ this.camelCatalog = camelCatalog;
+ }
+
+ @Override
+ public String getProviderName() {
+ return "springboot";
+ }
+
+ @Override
+ public List<String> findComponentNames() {
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(COMPONENTS_CATALOG);
+ if (is != null) {
+ try {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return names;
+ }
+
+ @Override
+ public List<String> findDataFormatNames() {
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(DATA_FORMATS_CATALOG);
+ if (is != null) {
+ try {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return names;
+ }
+
+ @Override
+ public List<String> findLanguageNames() {
+ List<String> names = new ArrayList<String>();
+ InputStream is = camelCatalog.getVersionManager().getResourceAsStream(LANGUAGE_CATALOG);
+ if (is != null) {
+ try {
+ CatalogHelper.loadLines(is, names);
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return names;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/catalog-provider-springboot/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/src/main/resources/META-INF/LICENSE.txt b/platforms/catalog-provider-springboot/src/main/resources/META-INF/LICENSE.txt
new file mode 100755
index 0000000..6b0b127
--- /dev/null
+++ b/platforms/catalog-provider-springboot/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/catalog-provider-springboot/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/src/main/resources/META-INF/NOTICE.txt b/platforms/catalog-provider-springboot/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/platforms/catalog-provider-springboot/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java b/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
new file mode 100644
index 0000000..879129d
--- /dev/null
+++ b/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
@@ -0,0 +1,96 @@
+/**
+ * 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.catalog.springboot;
+
+import java.util.List;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class SpringBootRuntimeProviderTest {
+
+ static CamelCatalog catalog;
+
+ @BeforeClass
+ public static void createCamelCatalog() {
+ catalog = new DefaultCamelCatalog();
+ catalog.setRuntimeProvider(new SpringBootRuntimeProvider());
+ }
+
+ @Test
+ public void testGetVersion() throws Exception {
+ String version = catalog.getCatalogVersion();
+ assertNotNull(version);
+
+ String loaded = catalog.getLoadedVersion();
+ assertNotNull(loaded);
+ assertEquals(version, loaded);
+ }
+
+ @Test
+ public void testProviderName() throws Exception {
+ assertEquals("springboot", catalog.getRuntimeProvider().getProviderName());
+ }
+
+ @Test
+ public void testFindComponentNames() throws Exception {
+ List<String> names = catalog.findComponentNames();
+
+ assertNotNull(names);
+ assertFalse(names.isEmpty());
+
+ assertTrue(names.contains("file"));
+ assertTrue(names.contains("ftp"));
+ assertTrue(names.contains("jms"));
+ // camel-ejb does not work in spring-boot
+ assertFalse(names.contains("ejb"));
+ // camel-pac-logging does not work in spring-boot
+ assertFalse(names.contains("paxlogging"));
+ }
+
+ @Test
+ public void testFindDataFormatNames() throws Exception {
+ List<String> names = catalog.findDataFormatNames();
+
+ assertNotNull(names);
+ assertFalse(names.isEmpty());
+
+ assertTrue(names.contains("bindy-csv"));
+ assertTrue(names.contains("zip"));
+ assertTrue(names.contains("zipfile"));
+ }
+
+ @Test
+ public void testFindLanguageNames() throws Exception {
+ List<String> names = catalog.findLanguageNames();
+
+ assertNotNull(names);
+ assertFalse(names.isEmpty());
+
+ assertTrue(names.contains("simple"));
+ assertTrue(names.contains("spel"));
+ assertTrue(names.contains("xpath"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/platforms/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/pom.xml b/platforms/pom.xml
index d0811ac..e75d45f 100644
--- a/platforms/pom.xml
+++ b/platforms/pom.xml
@@ -40,6 +40,7 @@
<module>catalog-lucene</module>
<module>catalog-maven</module>
<module>catalog-provider-karaf</module>
+ <module>catalog-provider-springboot</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/473d90a3/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java
new file mode 100644
index 0000000..dffc9de
--- /dev/null
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java
@@ -0,0 +1,520 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.maven.packaging;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
+
+import static org.apache.camel.maven.packaging.PackageHelper.loadText;
+
+/**
+ * Prepares the Spring Boot provider camel catalog to include component it supports
+ *
+ * @goal prepare-catalog-springboot
+ */
+public class PrepareCatalogSpringBootMojo extends AbstractMojo {
+
+ public static final int BUFFER_SIZE = 128 * 1024;
+
+ /**
+ * The maven project.
+ *
+ * @parameter property="project"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * The output directory for components catalog
+ *
+ * @parameter default-value="${project.build.directory}/classes/org/apache/camel/catalog/springboot/components"
+ */
+ protected File componentsOutDir;
+
+ /**
+ * The output directory for dataformats catalog
+ *
+ * @parameter default-value="${project.build.directory}/classes/org/apache/camel/catalog/springboot/dataformats"
+ */
+ protected File dataFormatsOutDir;
+
+ /**
+ * The output directory for languages catalog
+ *
+ * @parameter default-value="${project.build.directory}/classes/org/apache/camel/catalog/springboot/languages"
+ */
+ protected File languagesOutDir;
+
+ /**
+ * The directory where all spring-boot starters are
+ *
+ * @parameter default-value="${project.build.directory}/../../../components-starter"
+ */
+ protected File componentsStarterDir;
+
+ /**
+ * The components directory where all the Apache Camel components are
+ *
+ * @parameter default-value="${project.build.directory}/../../../components"
+ */
+ protected File componentsDir;
+
+ /**
+ * The camel-core directory where camel-core components are
+ *
+ * @parameter default-value="${project.build.directory}/../../../camel-core"
+ */
+ protected File coreDir;
+
+ /**
+ * Maven ProjectHelper.
+ *
+ * @component
+ * @readonly
+ */
+ private MavenProjectHelper projectHelper;
+
+ /**
+ * Execute goal.
+ *
+ * @throws MojoExecutionException execution of the main class or one of the
+ * threads it generated failed.
+ * @throws MojoFailureException something bad happened...
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ Set<String> starters = findSpringBootStarters();
+ executeComponents(starters);
+ executeDataFormats(starters);
+ executeLanguages(starters);
+ }
+
+ protected void executeComponents(Set<String> starters) throws MojoExecutionException, MojoFailureException {
+ getLog().info("Copying all Camel component json descriptors");
+
+ // lets use sorted set/maps
+ Set<File> jsonFiles = new TreeSet<File>();
+ Set<File> componentFiles = new TreeSet<File>();
+
+ // find all json files in components and camel-core
+ if (componentsDir != null && componentsDir.isDirectory()) {
+ File[] components = componentsDir.listFiles();
+ if (components != null) {
+ for (File dir : components) {
+ // skip camel-spring-dm
+ if (dir.isDirectory() && "camel-spring-dm".equals(dir.getName())) {
+ continue;
+ }
+
+
+ if (dir.isDirectory() && !"target".equals(dir.getName())) {
+ File target = new File(dir, "target/classes");
+
+ // the directory must be in the list of known features
+ if (!starters.contains(dir.getName())) {
+ continue;
+ }
+
+ // special for camel-salesforce which is in a sub dir
+ if ("camel-salesforce".equals(dir.getName())) {
+ target = new File(dir, "camel-salesforce-component/target/classes");
+ } else if ("camel-linkedin".equals(dir.getName())) {
+ target = new File(dir, "camel-linkedin-component/target/classes");
+ }
+
+
+ findComponentFilesRecursive(target, jsonFiles, componentFiles, new CamelComponentsFileFilter());
+ }
+ }
+ }
+ }
+ if (coreDir != null && coreDir.isDirectory()) {
+ File target = new File(coreDir, "target/classes");
+ findComponentFilesRecursive(target, jsonFiles, componentFiles, new CamelComponentsFileFilter());
+ }
+
+ getLog().info("Found " + componentFiles.size() + " component.properties files");
+ getLog().info("Found " + jsonFiles.size() + " component json files");
+
+ // make sure to create out dir
+ componentsOutDir.mkdirs();
+
+ Set<String> alternativeSchemes = new HashSet<>();
+
+ for (File file : jsonFiles) {
+ File to = new File(componentsOutDir, file.getName());
+ try {
+ copyFile(file, to);
+ } catch (IOException e) {
+ throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ }
+ }
+
+ File all = new File(componentsOutDir, "../components.properties");
+ try {
+ FileOutputStream fos = new FileOutputStream(all, false);
+
+ String[] names = componentsOutDir.list();
+ List<String> components = new ArrayList<String>();
+ // sort the names
+ for (String name : names) {
+ if (name.endsWith(".json")) {
+ // strip out .json from the name
+ String componentName = name.substring(0, name.length() - 5);
+ components.add(componentName);
+ }
+ }
+
+ Collections.sort(components);
+ for (String name : components) {
+ fos.write(name.getBytes());
+ fos.write("\n".getBytes());
+ }
+
+ fos.close();
+
+ } catch (IOException e) {
+ throw new MojoFailureException("Error writing to file " + all);
+ }
+ }
+
+ protected void executeDataFormats(Set<String> starters) throws MojoExecutionException, MojoFailureException {
+ getLog().info("Copying all Camel dataformat json descriptors");
+
+ // lets use sorted set/maps
+ Set<File> jsonFiles = new TreeSet<File>();
+ Set<File> dataFormatFiles = new TreeSet<File>();
+
+ // find all data formats from the components directory
+ if (componentsDir != null && componentsDir.isDirectory()) {
+ File[] dataFormats = componentsDir.listFiles();
+ if (dataFormats != null) {
+ for (File dir : dataFormats) {
+ if (dir.isDirectory() && !"target".equals(dir.getName())) {
+ // skip camel-spring-dm
+ if (dir.isDirectory() && "camel-spring-dm".equals(dir.getName())) {
+ continue;
+ }
+ // the directory must be in the list of known features
+ if (!starters.contains(dir.getName())) {
+ continue;
+ }
+ File target = new File(dir, "target/classes");
+ findDataFormatFilesRecursive(target, jsonFiles, dataFormatFiles, new CamelDataFormatsFileFilter());
+ }
+ }
+ }
+ }
+ if (coreDir != null && coreDir.isDirectory()) {
+ File target = new File(coreDir, "target/classes");
+ findDataFormatFilesRecursive(target, jsonFiles, dataFormatFiles, new CamelDataFormatsFileFilter());
+ }
+
+ getLog().info("Found " + dataFormatFiles.size() + " dataformat.properties files");
+ getLog().info("Found " + jsonFiles.size() + " dataformat json files");
+
+ // make sure to create out dir
+ dataFormatsOutDir.mkdirs();
+
+ for (File file : jsonFiles) {
+ File to = new File(dataFormatsOutDir, file.getName());
+ try {
+ copyFile(file, to);
+ } catch (IOException e) {
+ throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ }
+ }
+
+ File all = new File(dataFormatsOutDir, "../dataformats.properties");
+ try {
+ FileOutputStream fos = new FileOutputStream(all, false);
+
+ String[] names = dataFormatsOutDir.list();
+ List<String> dataFormats = new ArrayList<String>();
+ // sort the names
+ for (String name : names) {
+ if (name.endsWith(".json")) {
+ // strip out .json from the name
+ String dataFormatName = name.substring(0, name.length() - 5);
+ dataFormats.add(dataFormatName);
+ }
+ }
+
+ Collections.sort(dataFormats);
+ for (String name : dataFormats) {
+ fos.write(name.getBytes());
+ fos.write("\n".getBytes());
+ }
+
+ fos.close();
+
+ } catch (IOException e) {
+ throw new MojoFailureException("Error writing to file " + all);
+ }
+ }
+
+ protected void executeLanguages(Set<String> starters) throws MojoExecutionException, MojoFailureException {
+ getLog().info("Copying all Camel language json descriptors");
+
+ // lets use sorted set/maps
+ Set<File> jsonFiles = new TreeSet<File>();
+ Set<File> languageFiles = new TreeSet<File>();
+
+ // find all languages from the components directory
+ if (componentsDir != null && componentsDir.isDirectory()) {
+ File[] languages = componentsDir.listFiles();
+ if (languages != null) {
+ for (File dir : languages) {
+ // skip camel-spring-dm
+ if (dir.isDirectory() && "camel-spring-dm".equals(dir.getName())) {
+ continue;
+ }
+ // the directory must be in the list of known features
+ if (!starters.contains(dir.getName())) {
+ continue;
+ }
+ if (dir.isDirectory() && !"target".equals(dir.getName())) {
+ File target = new File(dir, "target/classes");
+ findLanguageFilesRecursive(target, jsonFiles, languageFiles, new CamelLanguagesFileFilter());
+ }
+ }
+ }
+ }
+ if (coreDir != null && coreDir.isDirectory()) {
+ File target = new File(coreDir, "target/classes");
+ findLanguageFilesRecursive(target, jsonFiles, languageFiles, new CamelLanguagesFileFilter());
+ }
+
+ getLog().info("Found " + languageFiles.size() + " language.properties files");
+ getLog().info("Found " + jsonFiles.size() + " language json files");
+
+ // make sure to create out dir
+ languagesOutDir.mkdirs();
+
+ for (File file : jsonFiles) {
+ File to = new File(languagesOutDir, file.getName());
+ try {
+ copyFile(file, to);
+ } catch (IOException e) {
+ throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ }
+ }
+
+ File all = new File(languagesOutDir, "../languages.properties");
+ try {
+ FileOutputStream fos = new FileOutputStream(all, false);
+
+ String[] names = languagesOutDir.list();
+ List<String> languages = new ArrayList<String>();
+ // sort the names
+ for (String name : names) {
+ if (name.endsWith(".json")) {
+ // strip out .json from the name
+ String languageName = name.substring(0, name.length() - 5);
+ languages.add(languageName);
+ }
+ }
+
+ Collections.sort(languages);
+ for (String name : languages) {
+ fos.write(name.getBytes());
+ fos.write("\n".getBytes());
+ }
+
+ fos.close();
+
+ } catch (IOException e) {
+ throw new MojoFailureException("Error writing to file " + all);
+ }
+ }
+
+ private void findComponentFilesRecursive(File dir, Set<File> found, Set<File> components, FileFilter filter) {
+ File[] files = dir.listFiles(filter);
+ if (files != null) {
+ for (File file : files) {
+ // skip files in root dirs as Camel does not store information there but others may do
+ boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
+ boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
+ boolean componentFile = !rootDir && file.isFile() && file.getName().equals("component.properties");
+ if (jsonFile) {
+ found.add(file);
+ } else if (componentFile) {
+ components.add(file);
+ } else if (file.isDirectory()) {
+ findComponentFilesRecursive(file, found, components, filter);
+ }
+ }
+ }
+ }
+
+ private void findDataFormatFilesRecursive(File dir, Set<File> found, Set<File> dataFormats, FileFilter filter) {
+ File[] files = dir.listFiles(filter);
+ if (files != null) {
+ for (File file : files) {
+ // skip files in root dirs as Camel does not store information there but others may do
+ boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
+ boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
+ boolean dataFormatFile = !rootDir && file.isFile() && file.getName().equals("dataformat.properties");
+ if (jsonFile) {
+ found.add(file);
+ } else if (dataFormatFile) {
+ dataFormats.add(file);
+ } else if (file.isDirectory()) {
+ findDataFormatFilesRecursive(file, found, dataFormats, filter);
+ }
+ }
+ }
+ }
+
+ private void findLanguageFilesRecursive(File dir, Set<File> found, Set<File> languages, FileFilter filter) {
+ File[] files = dir.listFiles(filter);
+ if (files != null) {
+ for (File file : files) {
+ // skip files in root dirs as Camel does not store information there but others may do
+ boolean rootDir = "classes".equals(dir.getName()) || "META-INF".equals(dir.getName());
+ boolean jsonFile = !rootDir && file.isFile() && file.getName().endsWith(".json");
+ boolean languageFile = !rootDir && file.isFile() && file.getName().equals("language.properties");
+ if (jsonFile) {
+ found.add(file);
+ } else if (languageFile) {
+ languages.add(file);
+ } else if (file.isDirectory()) {
+ findLanguageFilesRecursive(file, found, languages, filter);
+ }
+ }
+ }
+ }
+
+ private class CamelComponentsFileFilter implements FileFilter {
+
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory() && pathname.getName().equals("model")) {
+ // do not check the camel-core model packages as there is no components there
+ return false;
+ }
+ if (pathname.isFile() && pathname.getName().endsWith(".json")) {
+ // must be a components json file
+ try {
+ String json = loadText(new FileInputStream(pathname));
+ return json != null && json.contains("\"kind\": \"component\"");
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("component.properties"));
+ }
+ }
+
+ private class CamelDataFormatsFileFilter implements FileFilter {
+
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory() && pathname.getName().equals("model")) {
+ // do not check the camel-core model packages as there is no components there
+ return false;
+ }
+ if (pathname.isFile() && pathname.getName().endsWith(".json")) {
+ // must be a dataformat json file
+ try {
+ String json = loadText(new FileInputStream(pathname));
+ return json != null && json.contains("\"kind\": \"dataformat\"");
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("dataformat.properties"));
+ }
+ }
+
+ private class CamelLanguagesFileFilter implements FileFilter {
+
+ @Override
+ public boolean accept(File pathname) {
+ if (pathname.isDirectory() && pathname.getName().equals("model")) {
+ // do not check the camel-core model packages as there is no components there
+ return false;
+ }
+ if (pathname.isFile() && pathname.getName().endsWith(".json")) {
+ // must be a language json file
+ try {
+ String json = loadText(new FileInputStream(pathname));
+ return json != null && json.contains("\"kind\": \"language\"");
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return pathname.isDirectory() || (pathname.isFile() && pathname.getName().equals("language.properties"));
+ }
+ }
+
+ public static void copyFile(File from, File to) throws IOException {
+ FileChannel in = null;
+ FileChannel out = null;
+ try {
+ in = new FileInputStream(from).getChannel();
+ out = new FileOutputStream(to).getChannel();
+
+ long size = in.size();
+ long position = 0;
+ while (position < size) {
+ position += in.transferTo(position, BUFFER_SIZE, out);
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ private Set<String> findSpringBootStarters() {
+ Set<String> answer = new LinkedHashSet<>();
+
+ String[] names = componentsStarterDir.list();
+ if (names != null) {
+ for (String name : names) {
+ if (name.startsWith("camel-") && name.endsWith("-starter")) {
+ // remove ending -starter
+ String regular = name.substring(0, name.length() - 8);
+ answer.add(regular);
+ }
+ }
+ }
+ return answer;
+ }
+
+}
\ No newline at end of file
[10/10] camel git commit: Rebuild project
Posted by da...@apache.org.
Rebuild project
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7530b37e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7530b37e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7530b37e
Branch: refs/heads/camel-2.18.x
Commit: 7530b37ef33866947ccde8120dda97e7ffd098ca
Parents: 6fa97e6
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 17:50:38 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 17:50:38 2016 +0100
----------------------------------------------------------------------
components-starter/camel-amqp-starter/pom.xml | 2 +-
.../camel-spring-boot-dependencies/pom.xml | 38 ++++++++++----------
2 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7530b37e/components-starter/camel-amqp-starter/pom.xml
----------------------------------------------------------------------
diff --git a/components-starter/camel-amqp-starter/pom.xml b/components-starter/camel-amqp-starter/pom.xml
index 66880f8..c37b1b9 100644
--- a/components-starter/camel-amqp-starter/pom.xml
+++ b/components-starter/camel-amqp-starter/pom.xml
@@ -25,7 +25,7 @@
<artifactId>camel-amqp-starter</artifactId>
<packaging>jar</packaging>
<name>Spring-Boot Starter :: Camel :: AMQP</name>
- <description>Spring-Boot Starter for Camel AMQP component which is based on the Apache Qid project</description>
+ <description>Spring-Boot Starter for Camel AMQP component which is based on the Apache Qpid project</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
http://git-wip-us.apache.org/repos/asf/camel/blob/7530b37e/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
----------------------------------------------------------------------
diff --git a/spring-boot-dm/camel-spring-boot-dependencies/pom.xml b/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
index 06deb1d..b584122 100644
--- a/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
+++ b/spring-boot-dm/camel-spring-boot-dependencies/pom.xml
@@ -2560,97 +2560,97 @@
<dependency>
<groupId>org.apache.cxf.services.sts</groupId>
<artifactId>cxf-services-sts-core</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf.services.ws-discovery</groupId>
<artifactId>cxf-services-ws-discovery-api</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-xml</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-jaxb</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-simple</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-management</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-jms</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-local</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-addr</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-mex</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-policy</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-rm</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-wsdl</artifactId>
- <version>3.1.7</version>
+ <version>3.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.ftpserver</groupId>
[07/10] camel git commit: CAMEL-10434: Camel catalog support
different runtimes to provide their supported list of components etc.
Posted by da...@apache.org.
CAMEL-10434: Camel catalog support different runtimes to provide their supported list of components etc.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/84a5a6e2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/84a5a6e2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/84a5a6e2
Branch: refs/heads/camel-2.18.x
Commit: 84a5a6e2fa268a93f8df4355552c070ed81db5fc
Parents: 473d90a
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Nov 7 16:05:18 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Nov 7 16:46:52 2016 +0100
----------------------------------------------------------------------
.../catalog/karaf/KarafRuntimeProvider.java | 18 ++++++
.../springboot/SpringBootRuntimeProvider.java | 18 ++++++
.../SpringBootRuntimeProviderTest.java | 24 ++++++++
.../camel/catalog/DefaultCamelCatalog.java | 9 +--
.../camel/catalog/DefaultRuntimeProvider.java | 18 ++++++
.../apache/camel/catalog/RuntimeProvider.java | 20 +++++--
.../packaging/PrepareCatalogSpringBootMojo.java | 63 +++++++++++++++-----
7 files changed, 144 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/84a5a6e2/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java b/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
index 67c80c3..86811e4 100644
--- a/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
+++ b/platforms/catalog-provider-karaf/src/main/java/org/apache/camel/catalog/karaf/KarafRuntimeProvider.java
@@ -31,6 +31,9 @@ import org.apache.camel.catalog.RuntimeProvider;
*/
public class KarafRuntimeProvider implements RuntimeProvider {
+ private static final String COMPONENT_DIR = "org/apache/camel/catalog/karaf/components";
+ private static final String DATAFORMAT_DIR = "org/apache/camel/catalog/karaf/dataformats";
+ private static final String LANGUAGE_DIR = "org/apache/camel/catalog/karaf/languages";
private static final String COMPONENTS_CATALOG = "org/apache/camel/catalog/karaf/components.properties";
private static final String DATA_FORMATS_CATALOG = "org/apache/camel/catalog/karaf/dataformats.properties";
private static final String LANGUAGE_CATALOG = "org/apache/camel/catalog/karaf/languages.properties";
@@ -53,6 +56,21 @@ public class KarafRuntimeProvider implements RuntimeProvider {
}
@Override
+ public String getComponentJSonSchemaDirectory() {
+ return COMPONENT_DIR;
+ }
+
+ @Override
+ public String getDataFormatJSonSchemaDirectory() {
+ return DATAFORMAT_DIR;
+ }
+
+ @Override
+ public String getLanguageJSonSchemaDirectory() {
+ return LANGUAGE_DIR;
+ }
+
+ @Override
public List<String> findComponentNames() {
List<String> names = new ArrayList<String>();
InputStream is = camelCatalog.getVersionManager().getResourceAsStream(COMPONENTS_CATALOG);
http://git-wip-us.apache.org/repos/asf/camel/blob/84a5a6e2/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java b/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java
index 8b61ede..8e06e86 100644
--- a/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java
+++ b/platforms/catalog-provider-springboot/src/main/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProvider.java
@@ -31,6 +31,9 @@ import org.apache.camel.catalog.RuntimeProvider;
*/
public class SpringBootRuntimeProvider implements RuntimeProvider {
+ private static final String COMPONENT_DIR = "org/apache/camel/catalog/springboot/components";
+ private static final String DATAFORMAT_DIR = "org/apache/camel/catalog/springboot/dataformats";
+ private static final String LANGUAGE_DIR = "org/apache/camel/catalog/springboot/languages";
private static final String COMPONENTS_CATALOG = "org/apache/camel/catalog/springboot/components.properties";
private static final String DATA_FORMATS_CATALOG = "org/apache/camel/catalog/springboot/dataformats.properties";
private static final String LANGUAGE_CATALOG = "org/apache/camel/catalog/springboot/languages.properties";
@@ -53,6 +56,21 @@ public class SpringBootRuntimeProvider implements RuntimeProvider {
}
@Override
+ public String getComponentJSonSchemaDirectory() {
+ return COMPONENT_DIR;
+ }
+
+ @Override
+ public String getDataFormatJSonSchemaDirectory() {
+ return DATAFORMAT_DIR;
+ }
+
+ @Override
+ public String getLanguageJSonSchemaDirectory() {
+ return LANGUAGE_DIR;
+ }
+
+ @Override
public List<String> findComponentNames() {
List<String> names = new ArrayList<String>();
InputStream is = camelCatalog.getVersionManager().getResourceAsStream(COMPONENTS_CATALOG);
http://git-wip-us.apache.org/repos/asf/camel/blob/84a5a6e2/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java b/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
index 879129d..28aeb8a 100644
--- a/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
+++ b/platforms/catalog-provider-springboot/src/test/java/org/apache/camel/catalog/springboot/SpringBootRuntimeProviderTest.java
@@ -93,4 +93,28 @@ public class SpringBootRuntimeProviderTest {
assertTrue(names.contains("xpath"));
}
+ @Test
+ public void testComponentArtifactId() throws Exception {
+ String json = catalog.componentJSonSchema("ftp");
+
+ assertNotNull(json);
+ assertTrue(json.contains("camel-ftp-starter"));
+ }
+
+ @Test
+ public void testDataFormatArtifactId() throws Exception {
+ String json = catalog.dataFormatJSonSchema("bindy-csv");
+
+ assertNotNull(json);
+ assertTrue(json.contains("camel-bindy-starter"));
+ }
+
+ @Test
+ public void testLanguageArtifactId() throws Exception {
+ String json = catalog.languageJSonSchema("spel");
+
+ assertNotNull(json);
+ assertTrue(json.contains("camel-spring-starter"));
+ }
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/84a5a6e2/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
index e498a7b..dc4a10b 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultCamelCatalog.java
@@ -74,9 +74,6 @@ public class DefaultCamelCatalog implements CamelCatalog {
private static final String MODELS_CATALOG = "org/apache/camel/catalog/models.properties";
private static final String MODEL_DIR = "org/apache/camel/catalog/models";
- private static final String COMPONENT_DIR = "org/apache/camel/catalog/components";
- private static final String DATAFORMAT_DIR = "org/apache/camel/catalog/dataformats";
- private static final String LANGUAGE_DIR = "org/apache/camel/catalog/languages";
private static final String DOC_DIR = "org/apache/camel/catalog/docs";
private static final String ARCHETYPES_CATALOG = "org/apache/camel/catalog/archetypes/archetype-catalog.xml";
private static final String SCHEMAS_XML = "org/apache/camel/catalog/schemas";
@@ -457,7 +454,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
@Override
public String componentJSonSchema(String name) {
- String file = COMPONENT_DIR + "/" + name + ".json";
+ String file = runtimeProvider.getComponentJSonSchemaDirectory() + "/" + name + ".json";
String answer = null;
if (caching) {
@@ -503,7 +500,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
@Override
public String dataFormatJSonSchema(String name) {
- String file = DATAFORMAT_DIR + "/" + name + ".json";
+ String file = runtimeProvider.getDataFormatJSonSchemaDirectory() + "/" + name + ".json";
String answer = null;
if (caching) {
@@ -554,7 +551,7 @@ public class DefaultCamelCatalog implements CamelCatalog {
name = "bean";
}
- String file = LANGUAGE_DIR + "/" + name + ".json";
+ String file = runtimeProvider.getLanguageJSonSchemaDirectory() + "/" + name + ".json";
String answer = null;
if (caching) {
http://git-wip-us.apache.org/repos/asf/camel/blob/84a5a6e2/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
index a18d193..acdf6a4 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/DefaultRuntimeProvider.java
@@ -23,6 +23,9 @@ import java.util.List;
public class DefaultRuntimeProvider implements RuntimeProvider {
+ private static final String COMPONENT_DIR = "org/apache/camel/catalog/components";
+ private static final String DATAFORMAT_DIR = "org/apache/camel/catalog/dataformats";
+ private static final String LANGUAGE_DIR = "org/apache/camel/catalog/languages";
private static final String COMPONENTS_CATALOG = "org/apache/camel/catalog/components.properties";
private static final String DATA_FORMATS_CATALOG = "org/apache/camel/catalog/dataformats.properties";
private static final String LANGUAGE_CATALOG = "org/apache/camel/catalog/languages.properties";
@@ -52,6 +55,21 @@ public class DefaultRuntimeProvider implements RuntimeProvider {
}
@Override
+ public String getComponentJSonSchemaDirectory() {
+ return COMPONENT_DIR;
+ }
+
+ @Override
+ public String getDataFormatJSonSchemaDirectory() {
+ return DATAFORMAT_DIR;
+ }
+
+ @Override
+ public String getLanguageJSonSchemaDirectory() {
+ return LANGUAGE_DIR;
+ }
+
+ @Override
public List<String> findComponentNames() {
List<String> names = new ArrayList<String>();
InputStream is = camelCatalog.getVersionManager().getResourceAsStream(COMPONENTS_CATALOG);
http://git-wip-us.apache.org/repos/asf/camel/blob/84a5a6e2/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
----------------------------------------------------------------------
diff --git a/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java b/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
index 2ab844f..2bd7fd8 100644
--- a/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
+++ b/platforms/catalog/src/main/java/org/apache/camel/catalog/RuntimeProvider.java
@@ -25,11 +25,6 @@ import java.util.List;
*/
public interface RuntimeProvider {
- // TODO: maven archetype GAV
- // original GAV
- // spring-boot GAV
- // karaf feature name
-
/**
* Gets the {@link CamelCatalog}
*/
@@ -46,6 +41,21 @@ public interface RuntimeProvider {
String getProviderName();
/**
+ * Gets the directory where the component json files are stored in the catalog JAR file
+ */
+ String getComponentJSonSchemaDirectory();
+
+ /**
+ * Gets the directory where the data format json files are stored in the catalog JAR file
+ */
+ String getDataFormatJSonSchemaDirectory();
+
+ /**
+ * Gets the directory where the language json files are stored in the catalog JAR file
+ */
+ String getLanguageJSonSchemaDirectory();
+
+ /**
* Find all the component names from the Camel catalog supported by the provider
*/
List<String> findComponentNames();
http://git-wip-us.apache.org/repos/asf/camel/blob/84a5a6e2/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java
index dffc9de..d0f4841 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PrepareCatalogSpringBootMojo.java
@@ -5,9 +5,9 @@
* 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ * 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.
@@ -24,11 +24,11 @@ import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import java.util.regex.Pattern;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -47,6 +47,8 @@ public class PrepareCatalogSpringBootMojo extends AbstractMojo {
public static final int BUFFER_SIZE = 128 * 1024;
+ private static final Pattern ARTIFACT_PATTERN = Pattern.compile("\"artifactId\": \"camel-(.*)\"");
+
/**
* The maven project.
*
@@ -170,14 +172,23 @@ public class PrepareCatalogSpringBootMojo extends AbstractMojo {
// make sure to create out dir
componentsOutDir.mkdirs();
- Set<String> alternativeSchemes = new HashSet<>();
-
for (File file : jsonFiles) {
- File to = new File(componentsOutDir, file.getName());
+ // for spring-boot we need to amend the json file to use -starter as the artifact-id
try {
- copyFile(file, to);
+ String text = loadText(new FileInputStream(file));
+
+ text = ARTIFACT_PATTERN.matcher(text).replaceFirst("\"artifactId\": \"camel-$1-starter\"");
+
+ // write new json file
+ File to = new File(componentsOutDir, file.getName());
+ FileOutputStream fos = new FileOutputStream(to, false);
+
+ fos.write(text.getBytes());
+
+ fos.close();
+
} catch (IOException e) {
- throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ throw new MojoFailureException("Cannot write json file " + file, e);
}
}
@@ -248,11 +259,22 @@ public class PrepareCatalogSpringBootMojo extends AbstractMojo {
dataFormatsOutDir.mkdirs();
for (File file : jsonFiles) {
- File to = new File(dataFormatsOutDir, file.getName());
+ // for spring-boot we need to amend the json file to use -starter as the artifact-id
try {
- copyFile(file, to);
+ String text = loadText(new FileInputStream(file));
+
+ text = ARTIFACT_PATTERN.matcher(text).replaceFirst("\"artifactId\": \"camel-$1-starter\"");
+
+ // write new json file
+ File to = new File(dataFormatsOutDir, file.getName());
+ FileOutputStream fos = new FileOutputStream(to, false);
+
+ fos.write(text.getBytes());
+
+ fos.close();
+
} catch (IOException e) {
- throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ throw new MojoFailureException("Cannot write json file " + file, e);
}
}
@@ -323,11 +345,22 @@ public class PrepareCatalogSpringBootMojo extends AbstractMojo {
languagesOutDir.mkdirs();
for (File file : jsonFiles) {
- File to = new File(languagesOutDir, file.getName());
+ // for spring-boot we need to amend the json file to use -starter as the artifact-id
try {
- copyFile(file, to);
+ String text = loadText(new FileInputStream(file));
+
+ text = ARTIFACT_PATTERN.matcher(text).replaceFirst("\"artifactId\": \"camel-$1-starter\"");
+
+ // write new json file
+ File to = new File(languagesOutDir, file.getName());
+ FileOutputStream fos = new FileOutputStream(to, false);
+
+ fos.write(text.getBytes());
+
+ fos.close();
+
} catch (IOException e) {
- throw new MojoFailureException("Cannot copy file from " + file + " -> " + to, e);
+ throw new MojoFailureException("Cannot write json file " + file, e);
}
}