This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/master by this push: new b5c2f78 Workaround for the platform http not be able to handle matchOnUriPrefix b5c2f78 is described below commit b5c2f78b6155b7919e0fbc6a866b2fdd3d64ef3a Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Wed Apr 1 18:38:44 2020 +0200 Workaround for the platform http not be able to handle matchOnUriPrefix --- .../http/PlatformHttpServiceContextCustomizer.java | 18 +++- .../data/application.properties | 39 +++++++++ .../camel-k-runtime-example-api/data/rests.xml | 17 ++++ .../camel-k-runtime-example-api/data/routes.groovy | 25 ++++++ examples/camel-k-runtime-example-api/pom.xml | 97 ++++++++++++++++++++++ examples/pom.xml | 1 + 6 files changed, 196 insertions(+), 1 deletion(-) diff --git a/camel-k-runtime-http/src/main/java/org/apache/camel/k/http/PlatformHttpServiceContextCustomizer.java b/camel-k-runtime-http/src/main/java/org/apache/camel/k/http/PlatformHttpServiceContextCustomizer.java index cc100ae..f46139e 100644 --- a/camel-k-runtime-http/src/main/java/org/apache/camel/k/http/PlatformHttpServiceContextCustomizer.java +++ b/camel-k-runtime-http/src/main/java/org/apache/camel/k/http/PlatformHttpServiceContextCustomizer.java @@ -16,7 +16,10 @@ */ package org.apache.camel.k.http; +import java.util.Map; + import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; import org.apache.camel.Ordered; import org.apache.camel.component.platform.http.PlatformHttpComponent; import org.apache.camel.component.platform.http.PlatformHttpConstants; @@ -42,7 +45,20 @@ public class PlatformHttpServiceContextCustomizer extends PlatformHttpServiceCon } // add the platform-http component - PlatformHttpComponent component = new PlatformHttpComponent(); + PlatformHttpComponent component = new PlatformHttpComponent() { + @Override + protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { + // remove matchOnUriPrefix as it will be fixed by camel 3.2 but will cause the context + // to fail as the property cannot be bound to the enpoint. + // + // TODO: remove once migrating to camel 3.2 + parameters.remove("matchOnUriPrefix"); + + // let the original component to create the endpoint + return super.createEndpoint(uri, remaining, parameters); + } + }; + component.setEngine(new RuntimePlatformHttpEngine()); camelContext.addComponent(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, component); diff --git a/examples/camel-k-runtime-example-api/data/application.properties b/examples/camel-k-runtime-example-api/data/application.properties new file mode 100644 index 0000000..bf3307d --- /dev/null +++ b/examples/camel-k-runtime-example-api/data/application.properties @@ -0,0 +1,39 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# Logging +# +logging.level.org.apache.camel.k = DEBUG + +# +# camel - main +# +camel.main.name = camel-k +camel.main.stream-caching-enabled = true +camel.main.stream-caching-spool-directory = ${java.io.tmpdir}/camel-k + +# +# camel - main +# +camel.context.rest-configuration.api-context-path=/api-doc + +# +# Camel K +# +customizer.platform-http.enabled = true +customizer.platform-http.bind-port = 8080 diff --git a/examples/camel-k-runtime-example-api/data/rests.xml b/examples/camel-k-runtime-example-api/data/rests.xml new file mode 100644 index 0000000..6b2e573 --- /dev/null +++ b/examples/camel-k-runtime-example-api/data/rests.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?><rests xmlns="http://camel.apache.org/schema/spring"> + <rest> + <get id="list" produces="application/json" uri="/"> + <to uri="direct:list"/> + </get> + <get id="get" produces="application/octet-stream" uri="/{name}"> + <to uri="direct:get"/> + </get> + <put consumes="application/octet-stream" id="create" uri="/{name}"> + <param description="The object content" name="body" required="true" type="body"/> + <to uri="direct:create"/> + </put> + <delete id="delete" uri="/{name}"> + <to uri="direct:delete"/> + </delete> + </rest> +</rests> \ No newline at end of file diff --git a/examples/camel-k-runtime-example-api/data/routes.groovy b/examples/camel-k-runtime-example-api/data/routes.groovy new file mode 100644 index 0000000..c92ef67 --- /dev/null +++ b/examples/camel-k-runtime-example-api/data/routes.groovy @@ -0,0 +1,25 @@ +/* + * 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. + */ + +from('direct:list') + .log('list') +from('direct:get') + .log('list') +from('direct:create') + .log('list') +from('direct:delete') + .log('list') diff --git a/examples/camel-k-runtime-example-api/pom.xml b/examples/camel-k-runtime-example-api/pom.xml new file mode 100644 index 0000000..65058ba --- /dev/null +++ b/examples/camel-k-runtime-example-api/pom.xml @@ -0,0 +1,97 @@ +<?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/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-examples</artifactId> + <version>1.3.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-k-runtime-example-api</artifactId> + + <dependencies> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-main</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-loader-groovy</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-loader-xml</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-http</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-log</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-rest</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-openapi-java</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-direct</artifactId> + </dependency> + </dependencies> + + <build> + <defaultGoal>exec:java</defaultGoal> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>${exec-maven-plugin.version}</version> + <executions> + <execution> + <goals> + <goal>java</goal> + </goals> + </execution> + </executions> + <configuration> + <mainClass>org.apache.camel.k.main.Application</mainClass> + <classpathScope>runtime</classpathScope> + <systemProperties> + <systemProperty> + <key>camel.k.conf</key> + <value>${project.basedir}/data/application.properties</value> + </systemProperty> + <systemProperty> + <key>camel.k.routes</key> + <value>file:${project.basedir}/data/rests.xml,file:${project.basedir}/data/routes.groovy</value> + </systemProperty> + </systemProperties> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/examples/pom.xml b/examples/pom.xml index 59615a4..e2b5c89 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -33,6 +33,7 @@ </properties> <modules> + <module>camel-k-runtime-example-api</module> <module>camel-k-runtime-example-rest</module> <module>camel-k-runtime-example-groovy</module> <module>camel-k-runtime-example-yaml</module>