You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2020/04/04 07:32:26 UTC
[camel-quarkus] branch master updated: Fix #706 Improve
RuntimeCatalogConfig docs
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new fcbd110 Fix #706 Improve RuntimeCatalogConfig docs
fcbd110 is described below
commit fcbd1108cd521eba19a3e2071742c67bc09f05df
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Wed Apr 1 09:30:48 2020 +0200
Fix #706 Improve RuntimeCatalogConfig docs
---
.../org/apache/camel/quarkus/core/CamelConfig.java | 38 ++++++++++++----------
.../camel/quarkus/core/CamelRuntimeCatalog.java | 12 ++++---
.../apache/camel/quarkus/core/CoreResource.java | 34 ++++++++++++-------
.../org/apache/camel/quarkus/core/CoreTest.java | 3 +-
4 files changed, 53 insertions(+), 34 deletions(-)
diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java
index 8773f89..b8cc0fd 100644
--- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java
+++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelConfig.java
@@ -39,7 +39,7 @@ public class CamelConfig {
public ServiceConfig service;
/**
- * Build time configuration options for {@link RuntimeCatalogConfig}.
+ * Build time configuration options for {@link org.apache.camel.catalog.RuntimeCamelCatalog}.
*/
@ConfigItem
public RuntimeCatalogConfig runtimeCatalog;
@@ -290,41 +290,45 @@ public class CamelConfig {
@ConfigGroup
public static class RuntimeCatalogConfig {
/**
- * Used to control the resolution of components catalog info.
+ * If {@code true} the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel
+ * components available in the application; otherwise component JSON schemas will not be available in the
+ * Runtime Camel Catalog and any attempt to access those will result in a RuntimeException.
* <p>
- * Note that when building native images, this flag determine if the json metadata files related to components
- * discovered at build time have to be included in the final binary. In JVM mode there is no real benefit of
- * setting this flag to {@code false} if not to make the behavior consistent with native mode.
+ * Setting this to {@code false} helps to reduce the size of the native image. In JVM mode, there is no real
+ * benefit of setting this flag to {@code false} except for making the behavior consistent with native mode.
*/
@ConfigItem(defaultValue = "true")
public boolean components;
/**
- * Used to control the resolution of languages catalog info.
+ * If {@code true} the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel
+ * languages available in the application; otherwise language JSON schemas will not be available in the
+ * Runtime Camel Catalog and any attempt to access those will result in a RuntimeException.
* <p>
- * Note that when building native images, this flag determine if the json metadata files related to languages
- * discovered at build time have to be included in the final binary. In JVM mode there is no real benefit of
- * setting this flag to {@code false} if not to make the behavior consistent with native mode.
+ * Setting this to {@code false} helps to reduce the size of the native image. In JVM mode, there is no real
+ * benefit of setting this flag to {@code false} except for making the behavior consistent with native mode.
*/
@ConfigItem(defaultValue = "true")
public boolean languages;
/**
- * Used to control the resolution of dataformats catalog info.
+ * If {@code true} the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel
+ * data formats available in the application; otherwise data format JSON schemas will not be available in the
+ * Runtime Camel Catalog and any attempt to access those will result in a RuntimeException.
* <p>
- * Note that when building native images, this flag determine if the json metadata files related to dataformats
- * discovered at build time have to be included in the final binary. In JVM mode there is no real benefit of
- * setting this flag to {@code false} if not to make the behavior consistent with native mode.
+ * Setting this to {@code false} helps to reduce the size of the native image. In JVM mode, there is no real
+ * benefit of setting this flag to {@code false} except for making the behavior consistent with native mode.
*/
@ConfigItem(defaultValue = "true")
public boolean dataformats;
/**
- * Used to control the resolution of model catalog info.
+ * If {@code true} the Runtime Camel Catalog embedded in the application will contain JSON schemas of Camel
+ * EIP models available in the application; otherwise EIP model JSON schemas will not be available in the
+ * Runtime Camel Catalog and any attempt to access those will result in a RuntimeException.
* <p>
- * Note that when building native images, this flag determine if the json metadata files related to models
- * has to be included in the final binary. In JVM mode there is no real benefit of setting this flag to
- * {@code false} if not to make the behavior consistent with native mode.
+ * Setting this to {@code false} helps to reduce the size of the native image. In JVM mode, there is no real
+ * benefit of setting this flag to {@code false} except for making the behavior consistent with native mode.
*/
@ConfigItem(defaultValue = "true")
public boolean models;
diff --git a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeCatalog.java b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeCatalog.java
index 98474b3..04820f0 100644
--- a/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeCatalog.java
+++ b/extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRuntimeCatalog.java
@@ -28,7 +28,8 @@ public class CamelRuntimeCatalog extends DefaultRuntimeCamelCatalog {
@Override
public String modelJSonSchema(String name) {
if (!config.models) {
- return null;
+ throw new RuntimeException(
+ "Accessing model JSON schemas was disabled via quarkus.camel.runtime-catalog.models = false");
}
return super.modelJSonSchema(name);
@@ -37,7 +38,8 @@ public class CamelRuntimeCatalog extends DefaultRuntimeCamelCatalog {
@Override
public String componentJSonSchema(String name) {
if (!config.components) {
- return null;
+ throw new RuntimeException(
+ "Accessing component JSON schemas was disabled via quarkus.camel.runtime-catalog.components = false");
}
return super.componentJSonSchema(name);
@@ -46,7 +48,8 @@ public class CamelRuntimeCatalog extends DefaultRuntimeCamelCatalog {
@Override
public String dataFormatJSonSchema(String name) {
if (!config.dataformats) {
- return null;
+ throw new RuntimeException(
+ "Accessing data format JSON schemas was disabled via quarkus.camel.runtime-catalog.dataformats = false");
}
return super.dataFormatJSonSchema(name);
@@ -55,7 +58,8 @@ public class CamelRuntimeCatalog extends DefaultRuntimeCamelCatalog {
@Override
public String languageJSonSchema(String name) {
if (!config.languages) {
- return null;
+ throw new RuntimeException(
+ "Accessing language JSON schemas was disabled via quarkus.camel.runtime-catalog.languages = false");
}
return super.languageJSonSchema(name);
diff --git a/integration-tests/core/src/main/java/org/apache/camel/quarkus/core/CoreResource.java b/integration-tests/core/src/main/java/org/apache/camel/quarkus/core/CoreResource.java
index d5a1e74..12dd640 100644
--- a/integration-tests/core/src/main/java/org/apache/camel/quarkus/core/CoreResource.java
+++ b/integration-tests/core/src/main/java/org/apache/camel/quarkus/core/CoreResource.java
@@ -136,20 +136,30 @@ public class CoreResource {
@Path("/catalog/{type}/{name}")
@GET
@Produces(MediaType.APPLICATION_JSON)
- public String catalog(@PathParam("type") String type, @PathParam("name") String name) throws IOException {
+ public Response catalog(@PathParam("type") String type, @PathParam("name") String name) throws IOException {
final CamelRuntimeCatalog catalog = (CamelRuntimeCatalog) context.getExtension(RuntimeCamelCatalog.class);
- switch (type) {
- case "component":
- return catalog.componentJSonSchema(name);
- case "language":
- return catalog.languageJSonSchema(name);
- case "dataformat":
- return catalog.dataFormatJSonSchema(name);
- case "model":
- return catalog.modelJSonSchema(name);
- default:
- throw new IllegalArgumentException("Unknown type " + type);
+ try {
+ final String schema;
+ switch (type) {
+ case "component":
+ schema = catalog.componentJSonSchema(name);
+ break;
+ case "language":
+ schema = catalog.languageJSonSchema(name);
+ break;
+ case "dataformat":
+ schema = catalog.dataFormatJSonSchema(name);
+ break;
+ case "model":
+ schema = catalog.modelJSonSchema(name);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown type " + type);
+ }
+ return Response.ok(schema).build();
+ } catch (Exception e) {
+ return Response.serverError().entity(e.getClass().getSimpleName() + ": " + e.getMessage()).build();
}
}
diff --git a/integration-tests/core/src/test/java/org/apache/camel/quarkus/core/CoreTest.java b/integration-tests/core/src/test/java/org/apache/camel/quarkus/core/CoreTest.java
index 46fac1a..9a5a0bc 100644
--- a/integration-tests/core/src/test/java/org/apache/camel/quarkus/core/CoreTest.java
+++ b/integration-tests/core/src/test/java/org/apache/camel/quarkus/core/CoreTest.java
@@ -63,7 +63,8 @@ public class CoreTest {
@Test
public void testCatalogComponent() throws IOException {
RestAssured.when().get("/test/catalog/component/timer").then().body(not(emptyOrNullString()));
- RestAssured.when().get("/test/catalog/language/simple").then().body(emptyOrNullString());
+ RestAssured.when().get("/test/catalog/language/simple").then().statusCode(500).body(is(
+ "RuntimeException: Accessing language JSON schemas was disabled via quarkus.camel.runtime-catalog.languages = false"));
}
@Test