This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch console in repository https://gitbox.apache.org/repos/asf/camel.git
commit 51ec4b675fe73c3884baeda766748e672b9c8621 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Dec 30 09:51:28 2021 +0100 CAMEL-17384: Developer Console SPI --- catalog/camel-catalog-console/pom.xml | 135 +++++++++++++++++++++ .../services/org/apache/camel/dev-console/catalog | 2 + .../camel/catalog/console/CatalogConsole.java | 82 +++++++++++++ catalog/pom.xml | 1 + 4 files changed, 220 insertions(+) diff --git a/catalog/camel-catalog-console/pom.xml b/catalog/camel-catalog-console/pom.xml new file mode 100644 index 0000000..bef95f0 --- /dev/null +++ b/catalog/camel-catalog-console/pom.xml @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<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"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.camel</groupId> + <artifactId>catalog</artifactId> + <version>3.15.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-catalog-console</artifactId> + <packaging>jar</packaging> + <name>Camel :: Catalog :: Console</name> + <description>Camel Catalog Developer Console</description> + + <properties> + <firstVersion>3.15.0</firstVersion> + <label>tooling</label> + </properties> + + <dependencies> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-console</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-catalog</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- disable all components --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-allcomponents</artifactId> + <version>${project.version}</version> + <type>pom</type> + <exclusions> + <exclusion> + <groupId>org.apache.camel</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <scope>test</scope> + </dependency> + + <!-- logging --> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + + <plugin> + <groupId>org.apache.camel</groupId> + <artifactId>camel-bundle-plugin</artifactId> + </plugin> + + <plugin> + <groupId>org.apache.camel</groupId> + <artifactId>camel-package-maven-plugin</artifactId> + <executions> + <execution> + <id>generate</id> + <goals> + <goal>generate</goal> + </goals> + <phase>process-classes</phase> + </execution> + <execution> + <id>generate-postcompile</id> + <goals> + <goal>generate-postcompile</goal> + </goals> + <phase>prepare-package</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + <goal>add-resource</goal> + </goals> + <configuration> + <sources> + <source>src/generated/java</source> + </sources> + <resources> + <resource> + <directory>src/generated/resources</directory> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/catalog/camel-catalog-console/src/generated/resources/META-INF/services/org/apache/camel/dev-console/catalog b/catalog/camel-catalog-console/src/generated/resources/META-INF/services/org/apache/camel/dev-console/catalog new file mode 100644 index 0000000..03d5cbd --- /dev/null +++ b/catalog/camel-catalog-console/src/generated/resources/META-INF/services/org/apache/camel/dev-console/catalog @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.catalog.console.CatalogConsole diff --git a/catalog/camel-catalog-console/src/main/java/org/apache/camel/catalog/console/CatalogConsole.java b/catalog/camel-catalog-console/src/main/java/org/apache/camel/catalog/console/CatalogConsole.java new file mode 100644 index 0000000..c7f94ff --- /dev/null +++ b/catalog/camel-catalog-console/src/main/java/org/apache/camel/catalog/console/CatalogConsole.java @@ -0,0 +1,82 @@ +/* + * 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.console; + +import java.util.Map; + +import org.apache.camel.catalog.CamelCatalog; +import org.apache.camel.catalog.DefaultCamelCatalog; +import org.apache.camel.impl.console.AbstractDevConsole; +import org.apache.camel.spi.annotations.DevConsole; +import org.apache.camel.tooling.model.ComponentModel; +import org.apache.camel.tooling.model.DataFormatModel; +import org.apache.camel.tooling.model.LanguageModel; + +@DevConsole("catalog") +public class CatalogConsole extends AbstractDevConsole { + + private final CamelCatalog catalog = new DefaultCamelCatalog(true); + + public CatalogConsole() { + super("camel", "catalog", "Catalog", "Lists all the used Camel Components"); + } + + @Override + protected Object doCall(MediaType mediaType, Map<String, Object> options) { + // only text is supported + StringBuilder sb = new StringBuilder(); + + // components + for (String name : getCamelContext().getComponentNames()) { + ComponentModel model = catalog.componentModel(name); + if (model != null) { + sb.append(String.format("\n %s (%s)", name, model.getSupportLevel())); + if (model.isDeprecated()) { + sb.append(" (deprecated)"); + } + } else { + sb.append("\n ").append(name); + } + } + // data formats + for (String name : getCamelContext().getDataFormatNames()) { + DataFormatModel model = catalog.dataFormatModel(name); + if (model != null) { + sb.append(String.format("\n %s (%s)", name, model.getSupportLevel())); + if (model.isDeprecated()) { + sb.append(" (deprecated)"); + } + } else { + sb.append("\n ").append(name); + } + } + // languages + for (String name : getCamelContext().getLanguageNames()) { + LanguageModel model = catalog.languageModel(name); + if (model != null) { + sb.append(String.format("\n %s (%s)", name, model.getSupportLevel())); + if (model.isDeprecated()) { + sb.append(" (deprecated)"); + } + } else { + sb.append("\n ").append(name); + } + } + + return sb.toString(); + } +} diff --git a/catalog/pom.xml b/catalog/pom.xml index 8bb0e27..2b68c02 100644 --- a/catalog/pom.xml +++ b/catalog/pom.xml @@ -40,6 +40,7 @@ <module>dummy-component</module> <!-- catalog --> <module>camel-catalog</module> + <module>camel-catalog-console</module> <module>camel-catalog-lucene</module> <module>camel-catalog-maven</module> <!-- tooling that depends on catalog -->