Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Camel to 4.1.0 #5415

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ asciidoc:
requires: "'util=camel-website-util,quarkus=xref:js/quarkus.js'"

# Project versions
camel-version: 4.0.1 # replace ${camel.version}
camel-docs-version: 4.0.x # replace ${camel.docs.components.version}
camel-version: 4.1.0 # replace ${camel.version}
camel-docs-version: 4.1.x # replace ${camel.docs.components.version}
quarkus-version: 3.4.1 # replace ${quarkus.version}
graalvm-version: 23.0.1 # replace ${graalvm.version}
graalvm-docs-version: jdk17
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/examples/components/azure-servicebus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ cqJvmSince: 2.8.0
cqNativeSince: n/a
cqCamelPartName: azure-servicebus
cqCamelPartTitle: Azure ServiceBus
cqCamelPartDescription: Send and receive messages to/from Azure Event Bus.
cqCamelPartDescription: Send and receive messages to/from Azure Service Bus.
cqExtensionPageTitle: Azure ServiceBus
2 changes: 2 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/tika.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ can be changed only via `application.properties`.
While you can use any of the available https://tika.apache.org/1.24.1/formats.html[Tika parsers] in JVM mode,
only some of those are supported in native mode - see the https://quarkiverse.github.io/quarkiverse-docs/quarkus-tika/dev/index.html[Quarkus Tika guide].

PDF and ODF parsers can not be used both in JVM mode or in the native mode. Pdf extension is suggested for purposes of pdf consumption to avoid a version conflict between Camel and Quarkus-tika extension involving PdfBox dependency.

Use of the Tika parser without any configuration will initialize all available parsers. Unfortunately as some of them
don't work in the native mode, the whole execution will fail.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.Set;
Expand All @@ -43,6 +44,14 @@ public void addClassLoader(ClassLoader classLoader) {
classLoaders.add(classLoader);
}

@Override
public Set<ClassLoader> getClassLoaders() {
if (classLoaders == null) {
return Collections.emptySet();
}
return Collections.unmodifiableSet(classLoaders);
}

@Override
public Class<?> resolveClass(String name) {
Class<?> result = loadClass(name, applicationContextClassLoader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.camel.quarkus.core;

import java.util.List;

import org.apache.camel.CamelContext;
import org.apache.camel.NamedNode;
import org.apache.camel.spi.ModelToXMLDumper;
Expand All @@ -27,9 +29,15 @@ public String dumpModelAsXml(CamelContext context, NamedNode definition) throws
}

@Override
public String dumpModelAsXml(CamelContext context, NamedNode definition, boolean resolvePlaceholders)
public String dumpModelAsXml(CamelContext context, NamedNode definition, boolean resolvePlaceholders, boolean generatedIds)
throws Exception {
throw new UnsupportedOperationException(
"Please add a dependency to camel-quarkus-xml-jaxb or camel-quarkus-xml-io-dsl");
}

@Override
public String dumpBeansAsXml(CamelContext context, List<Object> beans) throws Exception {
throw new UnsupportedOperationException(
"Please add a dependency to camel-quarkus-xml-jaxb or camel-quarkus-xml-io-dsl");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,28 @@
*/
package org.apache.camel.quarkus.core;

import java.util.List;

import org.apache.camel.CamelContext;
import org.apache.camel.NamedNode;
import org.apache.camel.spi.ModelToYAMLDumper;

public class DisabledModelToYAMLDumper implements ModelToYAMLDumper {

@Override
public String dumpModelAsYaml(CamelContext context, NamedNode definition) throws Exception {
public String dumpBeansAsYaml(CamelContext context, List<Object> beans) throws Exception {
throw new UnsupportedOperationException("Please add a dependency to camel-quarkus-yaml-io");
}

@Override
public String dumpModelAsYaml(CamelContext context, NamedNode definition) throws Exception {
throw new UnsupportedOperationException(
"Please add a dependency to camel-quarkus-yaml-io");
}

@Override
public String dumpModelAsYaml(CamelContext context, NamedNode definition, boolean resolvePlaceholders,
boolean uriAsParameters) throws Exception {
boolean uriAsParameters, boolean generatedIds) throws Exception {
throw new UnsupportedOperationException(
"Please add a dependency to camel-quarkus-yaml-io");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public <T> T newInstance(Class<T> type, boolean postProcessBean) {
return delegate.newInstance(type, postProcessBean);
}

@SuppressWarnings("unchecked")
@Override
public <T> T newInstance(Class<T> type, Class<?> factoryClass, String factoryMethod) {
if (mustBeReplaced(type)) {
return (T) delegate.newInstance(DryModeComponent.class);
}
return delegate.newInstance(type, factoryClass, factoryMethod);
}

@Override
public boolean supportsAutoWiring() {
return delegate.supportsAutoWiring();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ public Collection<Resource> findRouteResourcesFromDirectory(CamelContext camelCo
return Collections.emptyList();
}

@Override
public boolean isIgnoreLoadingError() {
return false;
}

@Override
public void setIgnoreLoadingError(boolean ignoreLoadingError) {
// Noop
}

@Override
public List<RoutesBuilder> collectRoutesFromRegistry(CamelContext camelContext, String excludePattern,
String includePattern) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.model.RouteTemplateDefinition;
import org.apache.camel.quarkus.component.kamelet.EmptyKameletResource;
import org.apache.camel.quarkus.component.kamelet.KameletConfiguration;
import org.apache.camel.quarkus.component.kamelet.KameletRecorder;
import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
Expand Down Expand Up @@ -119,6 +120,19 @@ CamelContextCustomizerBuildItem configureTemplates(
}
}

return new CamelContextCustomizerBuildItem(recorder.createTemplateLoaderCustomizer(definitions));
// TODO: Improve / remove this https://github.com/apache/camel-quarkus/issues/5230
// Use Quarkus recorder serialization friendly EmptyKameletResource instead of the default Resource.
// The resource will get reevaluated at runtime and replaced if it exists
definitions.forEach(definition -> {
Resource originalResource = definition.getResource();
EmptyKameletResource resource = new EmptyKameletResource();
resource.setScheme(originalResource.getScheme());
resource.setLocation(originalResource.getLocation());
resource.setExists(originalResource.exists());
definition.setResource(resource);
});

return new CamelContextCustomizerBuildItem(
recorder.createTemplateLoaderCustomizer(definitions));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* 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.component.kamelet;

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;

import org.apache.camel.spi.Resource;

/**
* TODO: Improve / remove this https://github.com/apache/camel-quarkus/issues/5230
* Quarkus build time & serialization friendly implementation for Kamelet resources. This gets replaced at runtime
* when the resource is reevaluated.
*/
public final class EmptyKameletResource implements Resource {
private String scheme;
private String location;
private boolean exists;

@Override
public String getScheme() {
return scheme;
}

public void setScheme(String scheme) {
this.scheme = scheme;
}

@Override
public String getLocation() {
return this.location;
}

public void setLocation(String location) {
this.location = location;
}

@Override
public boolean exists() {
return exists;
}

public void setExists(boolean exists) {
this.exists = exists;
}

@Override
public InputStream getInputStream() throws IOException {
return InputStream.nullInputStream();
}

@Override
public String toString() {
String prefix = scheme + ":";
if (location.startsWith(prefix)) {
return "Resource[" + location + "]";
} else {
return "Resource[" + prefix + location + "]";
}
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Resource that = (Resource) o;
return scheme.equals(that.getScheme()) && location.equals(that.getLocation());
}

@Override
public int hashCode() {
return Objects.hash(scheme, location);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,40 @@
import org.apache.camel.model.Model;
import org.apache.camel.model.RouteTemplateDefinition;
import org.apache.camel.spi.CamelContextCustomizer;
import org.apache.camel.spi.Resource;
import org.apache.camel.spi.ResourceLoader;
import org.apache.camel.support.PluginHelper;
import org.apache.camel.util.ObjectHelper;
import org.jboss.logging.Logger;

@Recorder
public class KameletRecorder {
private static final Logger LOG = Logger.getLogger(KameletRecorder.class);

public RuntimeValue<CamelContextCustomizer> createTemplateLoaderCustomizer(
@RelaxedValidation List<RouteTemplateDefinition> definitions) {

return new RuntimeValue<>(new CamelContextCustomizer() {
@Override
public void configure(CamelContext context) {
try {
// TODO: Improve / remove this: https://github.com/apache/camel-quarkus/issues/5230
ResourceLoader resourceLoader = PluginHelper.getResourceLoader(context);
for (RouteTemplateDefinition definition : definitions) {
Resource originalResource = definition.getResource();
String location = originalResource.getLocation();
if (originalResource instanceof EmptyKameletResource && !ObjectHelper.isNotEmpty(location)) {
Resource resource = resourceLoader.resolveResource(location);
if (resource != null) {
definition.setResource(resource);
} else {
if (LOG.isDebugEnabled()) {
LOG.debugf("Failed resolving Kamelet resource %s. Resource dumping will be disabled.",
definition.getId());
}
}
}
}
context.getCamelContextExtension().getContextPlugin(Model.class).addRouteTemplateDefinitions(definitions);
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down
10 changes: 10 additions & 0 deletions extensions/nats/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-nats</artifactId>
</dependency>
<dependency>
<groupId>net.i2p.crypto</groupId>
<artifactId>eddsa</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Loading
Loading