This is an automated email from the ASF dual-hosted git repository. davsclaus 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 13fdc4e Fix #453 Move the platform-http component to Camel (#459) 13fdc4e is described below commit 13fdc4e436aa8a563a16ea411e3ca05de326da82 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Wed Nov 27 05:16:33 2019 +0100 Fix #453 Move the platform-http component to Camel (#459) * Fix #441 Avoid subclassing the upstream XsltComponent * Fix #453 Move the platform-http component to Camel --- .../quarkus/QuarkusRuntimeProviderTest.java | 1 - .../pages/list-of-camel-quarkus-extensions.adoc | 9 +- extensions/platform-http/component/pom.xml | 94 ------------ .../platform/http/PlatformHttpComponent.java | 162 --------------------- .../platform/http/PlatformHttpConstants.java | 27 ---- .../platform/http/PlatformHttpEndpoint.java | 152 ------------------- .../http/PlatformHttpHeaderFilterStrategy.java | 55 ------- .../camel/component/platform/http/spi/Method.java | 74 ---------- .../platform/http/spi/PlatformHttpEngine.java | 37 ----- extensions/platform-http/pom.xml | 1 - extensions/platform-http/runtime/pom.xml | 4 +- extensions/readme.adoc | 9 +- .../deployment/XalanNativeImageProcessor.java | 1 + .../camel/quarkus/support/xalan/XalanSupport.java | 44 ------ .../support/xalan/XalanTransformerFactory.java | 113 ++++++++++++++ .../component/xslt/deployment/XsltProcessor.java | 4 +- .../quarkus/component/xslt/CamelXsltRecorder.java | 42 +++--- poms/bom/pom.xml | 10 +- 18 files changed, 153 insertions(+), 686 deletions(-) diff --git a/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java b/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java index 0e2c8ae..2c6b1d1 100644 --- a/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java +++ b/catalog/camel-quarkus-catalog/src/test/java/org/apache/camel/catalog/quarkus/QuarkusRuntimeProviderTest.java @@ -111,7 +111,6 @@ public class QuarkusRuntimeProviderTest { assertFalse(names.isEmpty()); assertTrue(names.contains("core-cloud")); - assertTrue(names.contains("platform-http")); assertTrue(names.contains("reactive-executor-vertx")); assertFalse(names.contains("blueprint")); diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index 8fb9c3e..0293752 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -6,7 +6,7 @@ As of Camel Quarkus {camel-quarkus-last-release} the following Camel artifacts a == Camel Components // components: START -Number of Camel components: 44 in 37 JAR artifacts (0 deprecated) +Number of Camel components: 45 in 38 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -96,6 +96,9 @@ Number of Camel components: 44 in 37 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/pdf-component.html[PDF] (camel-quarkus-pdf) + `pdf:operation` | 0.3.1 | The pdf components provides the ability to create, modify or extract content from PDF documents. +| xref:extensions/platform-http.adoc[Platform HTTP] (camel-quarkus-platform-http) + +`platform-http:path` | 0.3 | HTTP service leveraging existing runtime platform HTTP server + | link:https://camel.apache.org/components/latest/rest-component.html[REST] (camel-quarkus-rest) + `rest:method:path:uriTemplate` | 0.2 | The rest component is used for either hosting REST services (consumer) or calling external REST services (producer). @@ -204,7 +207,7 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 8 in 8 JAR artifacts (0 deprecated) +Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -214,8 +217,6 @@ Number of miscellaneous extensions: 8 in 8 JAR artifacts (0 deprecated) | (camel-quarkus-core-cloud) | 0.2 | The Camel Quarkus core cloud module -| xref:extensions/platform-http.adoc[camel-quarkus-platform-http] | 0.3 | HTTP platform component is used for integrating Camel HTTP with Quarkus HTTP layer - | (camel-quarkus-core-xml) | 0.3 | Includes implementations of Java Architecture for XML Binding (JAXB) and Java API for XML Processing (JAXP) | (camel-quarkus-hystrix) | 0.5 | Circuit Breaker EIP using Netflix Hystrix diff --git a/extensions/platform-http/component/pom.xml b/extensions/platform-http/component/pom.xml deleted file mode 100644 index 94e91b9..0000000 --- a/extensions/platform-http/component/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?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"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-platform-http-parent</artifactId> - <version>0.4.1-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>camel-quarkus-platform-http-component</artifactId> - <name>Camel Quarkus :: Platform HTTP :: Component</name> - - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-support</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>spi-annotations</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>apt</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.camel</groupId> - <artifactId>camel-package-maven-plugin</artifactId> - <version>${camel.version}</version> - <configuration> - <failFast>false</failFast> - </configuration> - <executions> - <execution> - <id>generate</id> - <goals> - <goal>prepare-components</goal> - </goals> - <phase>process-classes</phase> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.jboss.jandex</groupId> - <artifactId>jandex-maven-plugin</artifactId> - <version>${jandex-maven-plugin.version}</version> - <executions> - <execution> - <id>make-index</id> - <goals> - <goal>jandex</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java deleted file mode 100644 index cc01da7..0000000 --- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpComponent.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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.component.platform.http; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.Consumer; -import org.apache.camel.Endpoint; -import org.apache.camel.Processor; -import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.RestApiConsumerFactory; -import org.apache.camel.spi.RestConfiguration; -import org.apache.camel.spi.RestConsumerFactory; -import org.apache.camel.spi.annotations.Component; -import org.apache.camel.support.DefaultComponent; -import org.apache.camel.util.FileUtil; -import org.apache.camel.util.URISupport; - -/** - * Exposes HTTP endpoints leveraging the given platform's (SpringBoot, WildFly, Quarkus, ...) HTTP server. - */ -@Component("platform-http") -public class PlatformHttpComponent extends DefaultComponent implements RestConsumerFactory, RestApiConsumerFactory { - @Metadata(label = "advanced") - private PlatformHttpEngine engine; - - public PlatformHttpComponent() { - super(); - } - - public PlatformHttpComponent(CamelContext context) { - super(context); - } - - @Override - protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - PlatformHttpEndpoint endpoint = new PlatformHttpEndpoint(uri, remaining, this); - endpoint.setPlatformHttpEngine(engine); - - return endpoint; - } - - @Override - public Consumer createApiConsumer(CamelContext camelContext, Processor processor, String contextPath, - RestConfiguration configuration, Map<String, Object> parameters) throws Exception { - // reuse the createConsumer method we already have. The api need to use GET and match on uri prefix - return doCreateConsumer(camelContext, processor, "GET", contextPath, null, null, null, configuration, parameters, true); - } - - @Override - public Consumer createConsumer(CamelContext camelContext, Processor processor, String verb, String basePath, - String uriTemplate, - String consumes, String produces, RestConfiguration configuration, Map<String, Object> parameters) - throws Exception { - return doCreateConsumer(camelContext, processor, verb, basePath, uriTemplate, consumes, produces, configuration, - parameters, false); - } - - public PlatformHttpEngine getEngine() { - return engine; - } - - /** - * Sets the {@link PlatformHttpEngine} to use. - */ - public PlatformHttpComponent setEngine(PlatformHttpEngine engine) { - this.engine = engine; - return this; - } - - private Consumer doCreateConsumer(CamelContext camelContext, Processor processor, String verb, String basePath, - String uriTemplate, - String consumes, String produces, RestConfiguration configuration, Map<String, Object> parameters, boolean api) - throws Exception { - - String path = basePath; - if (uriTemplate != null) { - // make sure to avoid double slashes - if (uriTemplate.startsWith("/")) { - path = path + uriTemplate; - } else { - path = path + "/" + uriTemplate; - } - } - path = FileUtil.stripLeadingSeparator(path); - - // if no explicit port/host configured, then use port from rest configuration - RestConfiguration config = configuration; - if (config == null) { - config = camelContext.getRestConfiguration(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, true); - } - - Map<String, Object> map = new HashMap<>(); - // build query string, and append any endpoint configuration properties - if (config.getComponent() == null || config.getComponent().equals(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME)) { - // setup endpoint options - if (config.getEndpointProperties() != null && !config.getEndpointProperties().isEmpty()) { - map.putAll(config.getEndpointProperties()); - } - } - - boolean cors = config.isEnableCORS(); - if (cors) { - // allow HTTP Options as we want to handle CORS in rest-dsl - map.put("optionsEnabled", "true"); - } - - // do not append with context-path as the servlet path should be without context-path - - String query = URISupport.createQueryString(map); - - String url; - if (api) { - url = "platform-http:/%s?matchOnUriPrefix=true&httpMethodRestrict=%s"; - } else { - url = "platform-http:/%s?httpMethodRestrict=%s"; - } - - // must use upper case for restrict - String restrict = verb.toUpperCase(Locale.US); - if (cors) { - restrict += ",OPTIONS"; - } - // get the endpoint - url = String.format(url, path, restrict); - - if (!query.isEmpty()) { - url = url + "&" + query; - } - - PlatformHttpEndpoint endpoint = camelContext.getEndpoint(url, PlatformHttpEndpoint.class); - setProperties(camelContext, endpoint, parameters); - endpoint.setConsumes(consumes); - endpoint.setProduces(produces); - - // configure consumer properties - Consumer consumer = endpoint.createConsumer(processor); - if (config.getConsumerProperties() != null && !config.getConsumerProperties().isEmpty()) { - setProperties(camelContext, consumer, config.getConsumerProperties()); - } - - return consumer; - } -} diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConstants.java b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConstants.java deleted file mode 100644 index de5a74d..0000000 --- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpConstants.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.component.platform.http; - -public final class PlatformHttpConstants { - - public static final String PLATFORM_HTTP_COMPONENT_NAME = "platform-http"; - public static final String PLATFORM_HTTP_ENGINE_NAME = "platform-http-engine"; - - private PlatformHttpConstants() { - } - -} diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java deleted file mode 100644 index ec11c10..0000000 --- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpEndpoint.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.component.platform.http; - -import org.apache.camel.AsyncEndpoint; -import org.apache.camel.Component; -import org.apache.camel.Consumer; -import org.apache.camel.Processor; -import org.apache.camel.Producer; -import org.apache.camel.component.platform.http.spi.PlatformHttpEngine; -import org.apache.camel.spi.HeaderFilterStrategy; -import org.apache.camel.spi.HeaderFilterStrategyAware; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.UriEndpoint; -import org.apache.camel.spi.UriParam; -import org.apache.camel.spi.UriPath; -import org.apache.camel.support.DefaultEndpoint; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@UriEndpoint(/* firstVersion = "3.?.0", */ scheme = "platform-http", title = "Platform HTTP", syntax = "platform-http:path", label = "http", consumerOnly = true) -public class PlatformHttpEndpoint extends DefaultEndpoint implements AsyncEndpoint, HeaderFilterStrategyAware { - private static final Logger LOGGER = LoggerFactory.getLogger(PlatformHttpEndpoint.class); - - @UriPath - @Metadata(required = true) - private final String path; - - @UriParam(label = "consumer", description = "A comma separated list of HTTP methods to serve, e.g. GET,POST ." - + " If no methods are specified, all methods will be served.") - private String httpMethodRestrict; - - @UriParam(label = "consumer", description = "The content type this endpoint accepts as an input, such as" - + " application/xml or application/json. <code>null</code> or <code>*/*</code> mean no restriction.") - private String consumes; - - @UriParam(label = "consumer", description = "The content type this endpoint produces, such as" - + " application/xml or application/json.") - private String produces; - - @UriParam(label = "consumer,advanced", description = "A comma or whitespace separated list of file extensions." - + " Uploads having these extensions will be stored locally." - + " Null value or asterisk (*) will allow all files.") - private String fileNameExtWhitelist; - - @UriParam(label = "advanced") - private PlatformHttpEngine platformHttpEngine; - - @UriParam(label = "advanced") - private HeaderFilterStrategy headerFilterStrategy = new PlatformHttpHeaderFilterStrategy(); - - public PlatformHttpEndpoint(String uri, String remaining, Component component) { - super(uri, component); - path = remaining; - } - - @Override - public Producer createProducer() throws Exception { - throw new UnsupportedOperationException("Producer is not supported"); - } - - @Override - public Consumer createConsumer(Processor processor) throws Exception { - return platformHttpEngine.createConsumer(this, processor); - } - - @Override - public HeaderFilterStrategy getHeaderFilterStrategy() { - return headerFilterStrategy; - } - - @Override - public void setHeaderFilterStrategy(HeaderFilterStrategy headerFilterStrategy) { - this.headerFilterStrategy = headerFilterStrategy; - } - - public String getPath() { - return path; - } - - public PlatformHttpEngine getPlatformHttpEngine() { - return platformHttpEngine; - } - - public void setPlatformHttpEngine(PlatformHttpEngine platformHttpEngine) { - this.platformHttpEngine = platformHttpEngine; - } - - public String getHttpMethodRestrict() { - return httpMethodRestrict; - } - - public void setHttpMethodRestrict(String httpMethodRestrict) { - this.httpMethodRestrict = httpMethodRestrict; - } - - public String getFileNameExtWhitelist() { - return fileNameExtWhitelist; - } - - public void setFileNameExtWhitelist(String fileNameExtWhitelist) { - this.fileNameExtWhitelist = fileNameExtWhitelist; - } - - public String getConsumes() { - return consumes; - } - - public void setConsumes(String consumes) { - this.consumes = consumes; - } - - public String getProduces() { - return produces; - } - - public void setProduces(String produces) { - this.produces = produces; - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - - if (platformHttpEngine == null) { - LOGGER.debug("Lookup platform http engine from registry"); - - platformHttpEngine = getCamelContext().getRegistry() - .lookupByNameAndType(PlatformHttpConstants.PLATFORM_HTTP_ENGINE_NAME, PlatformHttpEngine.class); - - if (platformHttpEngine == null) { - throw new IllegalStateException(PlatformHttpEngine.class.getSimpleName() + " neither set on this " - + PlatformHttpEndpoint.class.getSimpleName() - + " neither found in Camel Registry."); - } - } - } -} diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpHeaderFilterStrategy.java b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpHeaderFilterStrategy.java deleted file mode 100644 index 26ac67c..0000000 --- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/PlatformHttpHeaderFilterStrategy.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.component.platform.http; - -import org.apache.camel.support.DefaultHeaderFilterStrategy; - -/** - * A copy of {@code org.apache.camel.http.common.HttpHeaderFilterStrategy}. Keep in sync or refactor - * {@code camel-http-common} not to depend on {@code javax.servlet-api} and then use the - * {@code HttpHeaderFilterStrategy} - * from there. - */ -public class PlatformHttpHeaderFilterStrategy extends DefaultHeaderFilterStrategy { - - public PlatformHttpHeaderFilterStrategy() { - initialize(); - } - - protected void initialize() { - getOutFilter().add("content-length"); - getOutFilter().add("content-type"); - getOutFilter().add("host"); - // Add the filter for the Generic Message header - // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5 - getOutFilter().add("cache-control"); - getOutFilter().add("connection"); - getOutFilter().add("date"); - getOutFilter().add("pragma"); - getOutFilter().add("trailer"); - getOutFilter().add("transfer-encoding"); - getOutFilter().add("upgrade"); - getOutFilter().add("via"); - getOutFilter().add("warning"); - - setLowerCase(true); - - // filter headers begin with "Camel" or "org.apache.camel" - // must ignore case for Http based transports - setOutFilterPattern("(?i)(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*"); - } -} diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/Method.java b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/Method.java deleted file mode 100644 index 5301bab..0000000 --- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/Method.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.component.platform.http.spi; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Locale; -import java.util.Set; -import java.util.TreeSet; - -/** - * An HTTP method. - */ -public enum Method { - GET(false), HEAD(false), POST(true), PUT(true), DELETE(false), TRACE(false), OPTIONS(false), CONNECT(false), PATCH( - true); - private static final Set<Method> ALL = Collections.unmodifiableSet(new TreeSet<>(Arrays.asList(values()))); - private final boolean canHaveBody; - - private Method(boolean canHaveBody) { - this.canHaveBody = canHaveBody; - } - - public static Set<Method> getAll() { - return ALL; - } - - /** - * @return {@code true} if HTTP requests with this {@link Method} can have a body; {@code false} otherwise - */ - public boolean canHaveBody() { - return canHaveBody; - } - - /** - * Parse the given comma separated {@code methodList} to a {@link Set} of {@link Method}s. If {@code methodList} is - * empty or {@code null} returns {@link #ALL}. - * - * @param methodList a comma separated list of HTTP method names. - * @return a {@link Set} of {@link Method}s - */ - public static Set<Method> parseList(String methodList) { - if (methodList == null) { - return ALL; - } - methodList = methodList.toUpperCase(Locale.ROOT); - String[] methods = methodList.split(","); - if (methods.length == 0) { - return ALL; - } else if (methods.length == 1) { - return Collections.singleton(Method.valueOf(methods[0])); - } else { - Set<Method> result = new TreeSet<>(); - for (String method : methods) { - result.add(Method.valueOf(method.trim())); - } - return ALL.equals(result) ? ALL : Collections.unmodifiableSet(result); - } - } -} diff --git a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpEngine.java b/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpEngine.java deleted file mode 100644 index c78d993..0000000 --- a/extensions/platform-http/component/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpEngine.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.component.platform.http.spi; - -import org.apache.camel.Consumer; -import org.apache.camel.Processor; -import org.apache.camel.component.platform.http.PlatformHttpEndpoint; - -/** - * An abstraction of an HTTP Server engine on which HTTP endpoints can be deployed. - */ -public interface PlatformHttpEngine { - - /** - * Creates a new {@link Consumer} for the given {@link PlatformHttpEndpoint}. - * - * @param platformHttpEndpoint the {@link PlatformHttpEndpoint} to creat a consumer for - * @param processor the Processor to pass to - * @return a new {@link Consumer} - */ - Consumer createConsumer(PlatformHttpEndpoint platformHttpEndpoint, Processor processor); - -} diff --git a/extensions/platform-http/pom.xml b/extensions/platform-http/pom.xml index 370648e..0eb4cf1 100644 --- a/extensions/platform-http/pom.xml +++ b/extensions/platform-http/pom.xml @@ -31,7 +31,6 @@ <packaging>pom</packaging> <modules> - <module>component</module> <module>deployment</module> <module>runtime</module> </modules> diff --git a/extensions/platform-http/runtime/pom.xml b/extensions/platform-http/runtime/pom.xml index 89c5014..f07c793 100644 --- a/extensions/platform-http/runtime/pom.xml +++ b/extensions/platform-http/runtime/pom.xml @@ -54,8 +54,8 @@ <artifactId>camel-quarkus-core</artifactId> </dependency> <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-platform-http-component</artifactId> + <groupId>org.apache.camel</groupId> + <artifactId>camel-platform-http</artifactId> </dependency> <dependency> diff --git a/extensions/readme.adoc b/extensions/readme.adoc index d11891f..12efa33 100644 --- a/extensions/readme.adoc +++ b/extensions/readme.adoc @@ -5,7 +5,7 @@ Apache Camel Quarkus supports the following Camel artifacts as Quarkus Extension == Camel Components // components: START -Number of Camel components: 44 in 37 JAR artifacts (0 deprecated) +Number of Camel components: 45 in 38 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -95,6 +95,9 @@ Number of Camel components: 44 in 37 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/pdf-component.html[PDF] (camel-quarkus-pdf) + `pdf:operation` | 0.3.1 | The pdf components provides the ability to create, modify or extract content from PDF documents. +| xref:extensions/platform-http.adoc[Platform HTTP] (camel-quarkus-platform-http) + +`platform-http:path` | 0.3 | HTTP service leveraging existing runtime platform HTTP server + | link:https://camel.apache.org/components/latest/rest-component.html[REST] (camel-quarkus-rest) + `rest:method:path:uriTemplate` | 0.2 | The rest component is used for either hosting REST services (consumer) or calling external REST services (producer). @@ -206,7 +209,7 @@ Number of Camel languages: 8 in 2 JAR artifacts (0 deprecated) == Miscellaneous Extensions // others: START -Number of miscellaneous extensions: 8 in 8 JAR artifacts (0 deprecated) +Number of miscellaneous extensions: 7 in 7 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -216,8 +219,6 @@ Number of miscellaneous extensions: 8 in 8 JAR artifacts (0 deprecated) | (camel-quarkus-core-cloud) | 0.2 | The Camel Quarkus core cloud module -| xref:extensions/platform-http.adoc[camel-quarkus-platform-http] | 0.3 | HTTP platform component is used for integrating Camel HTTP with Quarkus HTTP layer - | (camel-quarkus-core-xml) | 0.3 | Includes implementations of Java Architecture for XML Binding (JAXB) and Java API for XML Processing (JAXP) | (camel-quarkus-hystrix) | 0.5 | Circuit Breaker EIP using Netflix Hystrix diff --git a/extensions/support/xalan/deployment/src/main/java/org/apache/camel/quarkus/support/xalan/deployment/XalanNativeImageProcessor.java b/extensions/support/xalan/deployment/src/main/java/org/apache/camel/quarkus/support/xalan/deployment/XalanNativeImageProcessor.java index f814908..4081cfa 100644 --- a/extensions/support/xalan/deployment/src/main/java/org/apache/camel/quarkus/support/xalan/deployment/XalanNativeImageProcessor.java +++ b/extensions/support/xalan/deployment/src/main/java/org/apache/camel/quarkus/support/xalan/deployment/XalanNativeImageProcessor.java @@ -30,6 +30,7 @@ class XalanNativeImageProcessor { return new ReflectiveClassBuildItem( true, false, + "org.apache.camel.quarkus.support.xalan.XalanTransformerFactory", "org.apache.xalan.xsltc.dom.ObjectFactory", "org.apache.xalan.xsltc.dom.XSLTCDTMManager", "org.apache.xalan.xsltc.trax.TransformerFactoryImpl", diff --git a/extensions/support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/XalanSupport.java b/extensions/support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/XalanSupport.java deleted file mode 100644 index 3bde531..0000000 --- a/extensions/support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/XalanSupport.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.quarkus.support.xalan; - -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class XalanSupport { - private static final Logger LOGGER = LoggerFactory.getLogger(XalanSupport.class); - - private XalanSupport() { - } - - public static TransformerFactory newTransformerFactoryInstance() { - TransformerFactory factory = TransformerFactory.newInstance( - "org.apache.xalan.xsltc.trax.TransformerFactoryImpl", - Thread.currentThread().getContextClassLoader()); - - try { - factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); - } catch (TransformerException e) { - LOGGER.warn("Unsupported feature " + javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING); - } - - return factory; - } -} diff --git a/extensions/support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/XalanTransformerFactory.java b/extensions/support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/XalanTransformerFactory.java new file mode 100644 index 0000000..78dff1e --- /dev/null +++ b/extensions/support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/XalanTransformerFactory.java @@ -0,0 +1,113 @@ +/* + * 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.quarkus.support.xalan; + +import javax.xml.transform.ErrorListener; +import javax.xml.transform.Source; +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.URIResolver; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A {@link TransformerFactory} delegating to a {@link TransformerFactory} created via + * {@code TransformerFactory.newInstance("org.apache.xalan.xsltc.trax.TransformerFactoryImpl", Thread.currentThread().getContextClassLoader())} + */ +public final class XalanTransformerFactory extends TransformerFactory { + private static final Logger LOGGER = LoggerFactory.getLogger(XalanTransformerFactory.class); + + private final TransformerFactory delegate; + + public XalanTransformerFactory() { + final TransformerFactory factory = TransformerFactory.newInstance( + "org.apache.xalan.xsltc.trax.TransformerFactoryImpl", + Thread.currentThread().getContextClassLoader()); + try { + factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); + } catch (TransformerException e) { + LOGGER.warn("Unsupported TransformerFactory feature " + javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING); + } + + this.delegate = factory; + } + + @Override + public Transformer newTransformer(Source source) throws TransformerConfigurationException { + return delegate.newTransformer(source); + } + + @Override + public Transformer newTransformer() throws TransformerConfigurationException { + return delegate.newTransformer(); + } + + @Override + public Templates newTemplates(Source source) throws TransformerConfigurationException { + return delegate.newTemplates(source); + } + + @Override + public Source getAssociatedStylesheet(Source source, String media, String title, String charset) + throws TransformerConfigurationException { + return delegate.getAssociatedStylesheet(source, media, title, charset); + } + + @Override + public void setURIResolver(URIResolver resolver) { + delegate.setURIResolver(resolver); + } + + @Override + public URIResolver getURIResolver() { + return delegate.getURIResolver(); + } + + @Override + public void setFeature(String name, boolean value) throws TransformerConfigurationException { + delegate.setFeature(name, value); + } + + @Override + public boolean getFeature(String name) { + return delegate.getFeature(name); + } + + @Override + public void setAttribute(String name, Object value) { + delegate.setAttribute(name, value); + } + + @Override + public Object getAttribute(String name) { + return delegate.getAttribute(name); + } + + @Override + public void setErrorListener(ErrorListener listener) { + delegate.setErrorListener(listener); + } + + @Override + public ErrorListener getErrorListener() { + return delegate.getErrorListener(); + } +} diff --git a/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltProcessor.java b/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltProcessor.java index 8e4d1c5..3016a78 100644 --- a/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltProcessor.java +++ b/extensions/xslt/deployment/src/main/java/org/apache/camel/quarkus/component/xslt/deployment/XsltProcessor.java @@ -43,7 +43,7 @@ import org.apache.camel.quarkus.component.xslt.RuntimeUriResolver.Builder; import org.apache.camel.quarkus.core.CamelServiceFilter; import org.apache.camel.quarkus.core.deployment.CamelBeanBuildItem; import org.apache.camel.quarkus.core.deployment.CamelServiceFilterBuildItem; -import org.apache.camel.quarkus.support.xalan.XalanSupport; +import org.apache.camel.quarkus.support.xalan.XalanTransformerFactory; import org.apache.commons.lang3.StringUtils; import io.quarkus.runtime.RuntimeValue; @@ -100,7 +100,7 @@ class XsltProcessor { + "' to previously added translets " + translets); } try { - TransformerFactory tf = XalanSupport.newTransformerFactoryInstance(); + TransformerFactory tf = new XalanTransformerFactory(); tf.setAttribute("generate-translet", true); tf.setAttribute("translet-name", translet); tf.setAttribute("package-name", config.packageName); diff --git a/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltRecorder.java b/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltRecorder.java index f5f249c..b91d937 100644 --- a/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltRecorder.java +++ b/extensions/xslt/runtime/src/main/java/org/apache/camel/quarkus/component/xslt/CamelXsltRecorder.java @@ -16,21 +16,27 @@ */ package org.apache.camel.quarkus.component.xslt; -import java.util.Map; import javax.xml.transform.TransformerFactory; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.annotations.Recorder; -import org.apache.camel.Endpoint; +import org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy; import org.apache.camel.component.xslt.XsltComponent; import org.apache.camel.component.xslt.XsltEndpoint; -import org.apache.camel.quarkus.support.xalan.XalanSupport; +import org.apache.camel.quarkus.support.xalan.XalanTransformerFactory; @Recorder public class CamelXsltRecorder { public RuntimeValue<XsltComponent> createXsltComponent(CamelXsltConfig config, RuntimeValue<RuntimeUriResolver.Builder> uriResolverBuilder) { - return new RuntimeValue<>(new QuarkusXsltComponent(config, uriResolverBuilder.getValue().build())); + final RuntimeUriResolver uriResolver = uriResolverBuilder.getValue().build(); + final QuarkusTransformerFactoryConfigurationStrategy strategy = new QuarkusTransformerFactoryConfigurationStrategy( + config.packageName, uriResolver); + final XsltComponent component = new XsltComponent(); + component.setUriResolver(uriResolver); + component.setTransformerFactoryConfigurationStrategy(strategy); + component.setTransformerFactoryClass(XalanTransformerFactory.class.getName()); + return new RuntimeValue<>(component); } public RuntimeValue<RuntimeUriResolver.Builder> createRuntimeUriResolverBuilder() { @@ -42,35 +48,27 @@ public class CamelXsltRecorder { builder.getValue().entry(templateUri, transletClassName); } - static class QuarkusXsltComponent extends XsltComponent { - private final CamelXsltConfig config; + static class QuarkusTransformerFactoryConfigurationStrategy implements TransformerFactoryConfigurationStrategy { + + private final String packageName; private final RuntimeUriResolver uriResolver; - public QuarkusXsltComponent(CamelXsltConfig config, RuntimeUriResolver uriResolver) { - this.config = config; + public QuarkusTransformerFactoryConfigurationStrategy(String packageName, RuntimeUriResolver uriResolver) { this.uriResolver = uriResolver; + this.packageName = packageName; } @Override - protected void configureEndpoint( - Endpoint endpoint, - String remaining, - Map<String, Object> parameters) throws Exception { - - final XsltEndpoint xsltEndpoint = (XsltEndpoint) endpoint; - final String className = uriResolver.getTransletClassName(remaining); + public void configure(TransformerFactory tf, XsltEndpoint endpoint) { + final String className = uriResolver.getTransletClassName(endpoint.getResourceUri()); - TransformerFactory tf = XalanSupport.newTransformerFactoryInstance(); tf.setAttribute("use-classpath", true); tf.setAttribute("translet-name", className); - tf.setAttribute("package-name", this.config.packageName); + tf.setAttribute("package-name", packageName); tf.setErrorListener(new CamelXsltErrorListener()); - xsltEndpoint.setTransformerFactory(tf); - - super.configureEndpoint(endpoint, remaining, parameters); - - xsltEndpoint.setUriResolver(uriResolver); + endpoint.setTransformerFactory(tf); } + } } diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index f58bf8e..e5ea903 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -284,6 +284,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-platform-http</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-rest</artifactId> <version>${camel.version}</version> </dependency> @@ -580,11 +585,6 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-platform-http-component</artifactId> - <version>${camel-quarkus.version}</version> - </dependency> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-reactive-executor</artifactId> <version>${camel-quarkus.version}</version> </dependency>