This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch rest-jmx in repository https://gitbox.apache.org/repos/asf/camel.git
commit f90e3979dd70be2ea166310897e10d87a1899fc8 Author: Claus Ibsen <[email protected]> AuthorDate: Sun Nov 30 11:29:45 2025 +0100 CAMEL-22742: camel-core - Rest DSL contract first should have jmx statistics --- .../platform/http/DefaultPlatformHttpConsumer.java | 15 ++++++++------- .../platform/http/spi/PlatformHttpConsumerAware.java | 6 ++++-- .../camel/component/rest/openapi/RestOpenApiEndpoint.java | 7 +++---- .../main/java/org/apache/camel/spi/RestConfiguration.java | 2 -- .../java/org/apache/camel/model/rest/RestDefinition.java | 4 +--- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/DefaultPlatformHttpConsumer.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/DefaultPlatformHttpConsumer.java index 3ae64ed12418..3b02916f5b00 100644 --- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/DefaultPlatformHttpConsumer.java +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/DefaultPlatformHttpConsumer.java @@ -31,7 +31,7 @@ public class DefaultPlatformHttpConsumer extends DefaultConsumer private PlatformHttpConsumer platformHttpConsumer; private boolean register = true; - private AfterPropertiesConfigured restOpenApiProcessor; + private AfterPropertiesConfigured afterConfiguredListener; public DefaultPlatformHttpConsumer(Endpoint endpoint, Processor processor) { super(endpoint, processor); @@ -65,8 +65,8 @@ public class DefaultPlatformHttpConsumer extends DefaultConsumer } @Override - public void registerOpenApiProcessor(AfterPropertiesConfigured processor) { - this.restOpenApiProcessor = processor; + public void registerAfterConfigured(AfterPropertiesConfigured processor) { + this.afterConfiguredListener = processor; } @Override @@ -77,14 +77,15 @@ public class DefaultPlatformHttpConsumer extends DefaultConsumer ServiceHelper.initService(platformHttpConsumer); - // signal to camel-rest-openapi that the platform-http consumer now has been configured - // and that rest-dsl can continue to initialize and start so it's ready when this consumer is started - if (restOpenApiProcessor != null) { - restOpenApiProcessor.afterPropertiesConfigured(getEndpoint().getCamelContext()); + // signal that the platform-http consumer now has been configured + // (rest-dsl can continue to initialize and start so it's ready when this consumer is started) + if (afterConfiguredListener != null) { + afterConfiguredListener.afterPropertiesConfigured(getEndpoint().getCamelContext()); } } protected void configurePlatformHttpConsumer(PlatformHttpConsumer platformHttpConsumer) { + // noop } @Override diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpConsumerAware.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpConsumerAware.java index cfaa2ec91b1a..c88348332d7a 100644 --- a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpConsumerAware.java +++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpConsumerAware.java @@ -29,8 +29,10 @@ public interface PlatformHttpConsumerAware { PlatformHttpConsumer getPlatformHttpConsumer(); /** - * Special when using camel-rest-openapi for contract-first Rest DSL. + * Registers a listener that is called after the {@link PlatformHttpConsumer} has set options from properties. + * <p/> + * For example used by camel-rest-openapi */ - void registerOpenApiProcessor(AfterPropertiesConfigured processor); + void registerAfterConfigured(AfterPropertiesConfigured processor); } diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java index e258e66b6af9..d5bad5e27235 100644 --- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java +++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java @@ -222,7 +222,7 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { // use an advice to call the processor that is responsible for routing to the route that matches the // operation id, and also do validation of the incoming request - // any camel route is just a dummy facade that is not in use + // the camel route is invoked AFTER the rest-dsl is complete if (processor instanceof InternalProcessor ip) { // remove existing rest binding advice because RestOpenApiProcessorAdvice has its own binding RestBindingAdvice advice = ip.getAdvice(RestBindingAdvice.class); @@ -235,12 +235,12 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { Consumer consumer = createConsumerFor(path, openApiProcessor, processor); openApiProcessor.setConsumer(consumer); if (consumer instanceof PlatformHttpConsumerAware phca) { - phca.registerOpenApiProcessor(openApiProcessor); + phca.registerAfterConfigured(openApiProcessor); } return consumer; } - protected Consumer createConsumerFor(String basePath, RestOpenApiProcessor openApiProcessor, Processor processor) + private Consumer createConsumerFor(String basePath, RestOpenApiProcessor openApiProcessor, Processor processor) throws Exception { RestOpenApiConsumerFactory factory = null; String cname = null; @@ -539,7 +539,6 @@ public final class RestOpenApiEndpoint extends DefaultEndpoint { return new RestOpenApiProducer(endpoint.createProducer(), hasHost, requestValidator); } - @Deprecated String determineBasePath(final OpenAPI openapi) { if (isNotEmpty(basePath)) { return basePath; diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestConfiguration.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestConfiguration.java index 65b2021d28e2..413e9538f346 100644 --- a/core/camel-api/src/main/java/org/apache/camel/spi/RestConfiguration.java +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestConfiguration.java @@ -34,8 +34,6 @@ public class RestConfiguration { public static final String DEFAULT_REST_CONFIGURATION_ID = "rest-configuration"; - public static final String CONTRACT_FIRST_PROCESSOR_REF = "camel-contract-first-openapi-"; - public enum RestBindingMode { auto, off, diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/rest/RestDefinition.java index 6ae96d49ba56..ee8e1d7bc827 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/rest/RestDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/rest/RestDefinition.java @@ -38,7 +38,6 @@ import org.apache.camel.Endpoint; import org.apache.camel.RuntimeCamelException; import org.apache.camel.builder.EndpointProducerBuilder; import org.apache.camel.model.OptionalIdentifiedDefinition; -import org.apache.camel.model.ProcessDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.StopDefinition; import org.apache.camel.model.ToDefinition; @@ -49,7 +48,6 @@ import org.apache.camel.spi.Resource; import org.apache.camel.spi.ResourceAware; import org.apache.camel.spi.RestConfiguration; import org.apache.camel.support.CamelContextHelper; -import org.apache.camel.support.processor.DelegateProcessor; import org.apache.camel.util.FileUtil; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.StringHelper; @@ -1047,7 +1045,7 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition> if (openApi.getRouteId() != null) { route.routeId(parseText(camelContext, openApi.getRouteId())); } - // add dummy empty stop (not in use) + // the route must have an output so use a dummy stop route.getOutputs().add(new StopDefinition()); // local configuration can override global
