diff --git a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.java b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.groovy similarity index 62% rename from camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.java rename to camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.groovy index 90c73cfdc..7d409c55c 100644 --- a/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.java +++ b/camel-k-loader-groovy/src/main/groovy/org/apache/camel/k/loader/groovy/dsl/Components.groovy @@ -14,33 +14,33 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.groovy.dsl; +package org.apache.camel.k.loader.groovy.dsl -import org.apache.camel.CamelContext; -import org.apache.camel.Component; +import org.apache.camel.CamelContext +import org.apache.camel.Component -public class Components { - private CamelContext context; +class Components { + private final CamelContext context - public Components(CamelContext context) { - this.context = context; + Components(CamelContext context) { + this.context = context } - public Component get(String scheme) { - return context.getComponent(scheme, true); + Component get(String scheme) { + return context.getComponent(scheme, true) } - public Component put(String scheme, Component instance) { - context.addComponent(scheme, instance); + Component put(String scheme, Component instance) { + context.addComponent(scheme, instance) return instance; } - public Component make(String scheme, String type) { - final Class clazz = context.getClassResolver().resolveClass(type); - final Component instance = (Component)context.getInjector().newInstance(clazz); + Component make(String scheme, String type) { + final Class clazz = context.getClassResolver().resolveClass(type) + final Component instance = (Component)context.getInjector().newInstance(clazz) - context.addComponent(scheme, instance); + context.addComponent(scheme, instance) return instance; } diff --git a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptSourceLoader.java b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptSourceLoader.java index d8de8e4e4..790a69cfa 100644 --- a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptSourceLoader.java +++ b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/JavaScriptSourceLoader.java @@ -61,8 +61,9 @@ private static void doLoad(Reader reader, EndpointRouteBuilder builder) { // // Expose IntegrationConfiguration methods to global scope. // - context.eval(LANGUAGE_ID, "" - + "Object.setPrototypeOf(globalThis, new Proxy(Object.prototype, {" + context.eval( + LANGUAGE_ID, + "Object.setPrototypeOf(globalThis, new Proxy(Object.prototype, {" + " has(target, key) {" + " return key in __dsl || key in target;" + " }," diff --git a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/Components.java b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/Components.java index c6a462b17..84a5610b7 100644 --- a/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/Components.java +++ b/camel-k-loader-js/src/main/java/org/apache/camel/k/loader/js/dsl/Components.java @@ -20,7 +20,7 @@ import org.apache.camel.Component; public class Components { - private CamelContext context; + private final CamelContext context; public Components(CamelContext context) { this.context = context; diff --git a/camel-k-loader-xml/src/main/java/org/apache/camel/k/loader/xml/XmlSourceLoader.java b/camel-k-loader-xml/src/main/java/org/apache/camel/k/loader/xml/XmlSourceLoader.java index a2d3f8f6b..963c4bc75 100644 --- a/camel-k-loader-xml/src/main/java/org/apache/camel/k/loader/xml/XmlSourceLoader.java +++ b/camel-k-loader-xml/src/main/java/org/apache/camel/k/loader/xml/XmlSourceLoader.java @@ -58,7 +58,7 @@ public void configure() throws Exception { LOGGER.debug("Loaded {} routes from {}", definitions.getRoutes().size(), source); setRouteCollection(definitions); } - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException ignored) { // ignore } catch (XmlPullParserException e) { LOGGER.debug("Unable to load RoutesDefinition: {}", e.getMessage()); @@ -73,7 +73,7 @@ public void configure() throws Exception { LOGGER.debug("Loaded {} rests from {}", definitions.getRests().size(), source); setRestCollection(definitions); } - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException ignored) { // ignore } catch (XmlPullParserException e) { LOGGER.debug("Unable to load RestsDefinition: {}", e.getMessage()); diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java index 08a39c697..5e63d6143 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java @@ -39,6 +39,10 @@ public StepParserException(String message, String... properties) { this.properties = Arrays.asList(properties); } + public String getProcessor() { + return processor; + } + public List getProperties() { return properties; } diff --git a/camel-k-main/camel-k-runtime-main/pom.xml b/camel-k-main/camel-k-runtime-main/pom.xml index ad8438fd2..8b29cacd3 100644 --- a/camel-k-main/camel-k-runtime-main/pom.xml +++ b/camel-k-main/camel-k-runtime-main/pom.xml @@ -148,6 +148,11 @@ camel-k-runtime-knative test + + org.apache.camel.k + camel-knative-test + test + diff --git a/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationRuntime.java b/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationRuntime.java index fc673770c..02551d887 100644 --- a/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationRuntime.java +++ b/camel-k-main/camel-k-runtime-main/src/main/java/org/apache/camel/k/main/ApplicationRuntime.java @@ -149,6 +149,7 @@ public void afterConfigure(BaseMainSupport main) { @Override public void configure(CamelContext context) { + // no-op } @Override diff --git a/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java b/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java index 59681e641..872de352b 100644 --- a/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java +++ b/camel-k-main/camel-k-runtime-main/src/test/java/org/apache/camel/k/main/RuntimeTest.java @@ -23,6 +23,7 @@ import org.apache.camel.component.knative.KnativeComponent; import org.apache.camel.component.knative.spi.Knative; import org.apache.camel.component.knative.spi.KnativeEnvironment; +import org.apache.camel.component.knative.test.KnativeEnvironmentSupport; import org.apache.camel.k.Runtime; import org.apache.camel.k.http.PlatformHttpServiceContextCustomizer; import org.apache.camel.k.listener.ContextConfigurer; @@ -115,7 +116,7 @@ public void testLoadJavaSource() throws Exception { public void testLoadJavaSourceWrap() throws Exception { KnativeComponent component = new KnativeComponent(); component.setEnvironment(KnativeEnvironment.on( - KnativeEnvironment.endpoint(Knative.EndpointKind.sink, "sink", "localhost", AvailablePortFinder.getNextAvailable()) + KnativeEnvironmentSupport.endpoint(Knative.EndpointKind.sink, "sink", "localhost", AvailablePortFinder.getNextAvailable()) )); PlatformHttpServiceContextCustomizer phsc = new PlatformHttpServiceContextCustomizer(); diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/deployment/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/deployment/Application.java index 43f74bba2..279dcb1b8 100644 --- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/deployment/Application.java +++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-knative/src/main/java/org/apache/camel/k/quarkus/knative/deployment/Application.java @@ -16,6 +16,7 @@ */ package org.apache.camel.k.quarkus.knative.deployment; +import java.util.Locale; import java.util.Map; import javax.enterprise.context.ApplicationScoped; @@ -64,7 +65,7 @@ public RouteBuilder routes() { @Override public void configure() throws Exception { from("knative:endpoint/from") - .transform().body(String.class, b -> b.toUpperCase()); + .transform().body(String.class, b -> b.toUpperCase(Locale.US)); } }; } diff --git a/camel-k-quarkus/camel-k-runtime-quarkus/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/DeploymentProcessor.java b/camel-k-quarkus/camel-k-runtime-quarkus/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/DeploymentProcessor.java index 3136a69f9..787f1cc78 100644 --- a/camel-k-quarkus/camel-k-runtime-quarkus/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/DeploymentProcessor.java +++ b/camel-k-quarkus/camel-k-runtime-quarkus/deployment/src/main/java/org/apache/camel/k/quarkus/deployment/DeploymentProcessor.java @@ -26,8 +26,6 @@ import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import org.apache.camel.k.Runtime; import org.apache.camel.k.quarkus.ApplicationRecorder; -import org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination; -import org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem; import org.apache.camel.quarkus.main.CamelMainApplication; import org.apache.camel.quarkus.main.deployment.spi.CamelMainListenerBuildItem; import org.apache.camel.spi.HasId; diff --git a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationListenerAdapter.java b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationListenerAdapter.java index 21b932108..9c155035e 100644 --- a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationListenerAdapter.java +++ b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationListenerAdapter.java @@ -65,6 +65,7 @@ public void afterConfigure(BaseMainSupport main) { @Override public void configure(CamelContext context) { + // no-op } @Override @@ -103,20 +104,6 @@ private static void invokeListeners(List listeners, Runtime ru }); } - private static Runtime on(CamelContext context) { - return new Runtime() { - @Override - public CamelContext getCamelContext() { - return context; - } - - @Override - public void stop() throws Exception { - Quarkus.asyncExit(); - } - }; - } - private static Runtime on(BaseMainSupport main) { return new Runtime() { @Override diff --git a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRuntimeConfigSourceProvider.java b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRuntimeConfigSourceProvider.java index 7cbb9e8ce..302e0c805 100644 --- a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRuntimeConfigSourceProvider.java +++ b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationRuntimeConfigSourceProvider.java @@ -23,12 +23,8 @@ import org.apache.camel.k.support.PropertiesSupport; import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.spi.ConfigSourceProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class ApplicationRuntimeConfigSourceProvider implements ConfigSourceProvider { - private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationRuntimeConfigSourceProvider.class); - @Override public Iterable getConfigSources(ClassLoader forClassLoader) { final Properties applicationProperties = PropertiesSupport.loadProperties(); diff --git a/camel-k-runtime-bom/pom.xml b/camel-k-runtime-bom/pom.xml index bf665cc6b..760b9a5e2 100644 --- a/camel-k-runtime-bom/pom.xml +++ b/camel-k-runtime-bom/pom.xml @@ -129,6 +129,11 @@ camel-knative-http ${project.version} + + org.apache.camel.k + camel-knative-test + ${project.version} + org.apache.camel.k camel-k-maven-plugin diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/CompositeClassloader.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/CompositeClassloader.java index 07192755c..638752160 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/CompositeClassloader.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/CompositeClassloader.java @@ -23,6 +23,7 @@ public class CompositeClassloader extends ClassLoader { private final List loaders = new CopyOnWriteArrayList<>(); public CompositeClassloader() { + // no parent } public CompositeClassloader(ClassLoader parent) { @@ -38,8 +39,8 @@ public Class loadClass(String name) throws ClassNotFoundException { for (ClassLoader loader: loaders) { try { return loader.loadClass(name); - } catch (ClassNotFoundException e) { - // ignore + } catch (ClassNotFoundException ignored) { + // ignored } } diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/Sources.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/Sources.java index 976d65206..8cd0615d3 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/Sources.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/Sources.java @@ -67,7 +67,7 @@ public InMemory(String name, String language, String loader, byte[] content) { this.language = language; this.loader = loader; this.interceptors = Collections.emptyList(); - this.content = content; + this.content = Arrays.copyOf(content, content.length); } public InMemory(String name, String language, String loader, List interceptors, byte[] content) { @@ -75,7 +75,7 @@ public InMemory(String name, String language, String loader, List interc this.language = language; this.loader = loader; this.interceptors = new ArrayList<>(interceptors); - this.content = content; + this.content = Arrays.copyOf(content, content.length); } @Override @@ -113,7 +113,7 @@ private static final class URI implements Source { private final String name; private final String language; private final String loader; - private final List interceptors; + private final String interceptors; private final boolean compressed; private URI(String uri) throws Exception { @@ -125,12 +125,8 @@ private URI(String uri) throws Exception { final String query = StringSupport.substringAfter(uri, "?"); final Map params = URISupport.parseQuery(query); - final String languageName = (String) params.get("language"); - final String compression = (String) params.get("compression"); - final String loader = (String) params.get("loader"); - final String interceptors = (String) params.get("interceptors"); - String language = languageName; + String language = (String) params.get("language"); if (ObjectHelper.isEmpty(language)) { language = StringSupport.substringAfterLast(location, ":"); language = StringSupport.substringAfterLast(language, "."); @@ -152,9 +148,9 @@ private URI(String uri) throws Exception { this.location = location; this.name = name; this.language = language; - this.loader = loader; - this.interceptors = interceptors != null ? Arrays.asList(interceptors.split(",", -1)) : Collections.emptyList(); - this.compressed = Boolean.parseBoolean(compression); + this.loader = (String) params.get("loader"); + this.interceptors = (String) params.get("interceptors"); + this.compressed = Boolean.parseBoolean((String) params.get("compression")); } @Override @@ -174,7 +170,7 @@ public Optional getLoader() { @Override public List getInterceptors() { - return interceptors; + return interceptors != null ? Arrays.asList(interceptors.split(",", -1)) : Collections.emptyList(); } @Override diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java index c701621e8..c74b5b86d 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java @@ -53,7 +53,7 @@ protected void accept(Runtime runtime) { load(runtime, routes.split(",", -1)); } - protected void load(Runtime runtime, String[] routes) { + protected void load(Runtime runtime, String... routes) { for (String route: routes) { if (ObjectHelper.isEmpty(route)) { continue; diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java index e66c5b16f..067d5f01e 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/KubernetesPropertiesFunction.java @@ -21,6 +21,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Locale; import org.apache.camel.spi.PropertiesFunction; import org.apache.camel.util.StringHelper; @@ -54,7 +55,7 @@ public String apply(String remainder) { return defaultValue; } - Path file = this.root.resolve(name.toLowerCase()).resolve(property); + Path file = this.root.resolve(name.toLowerCase(Locale.US)).resolve(property); if (Files.exists(file) && !Files.isDirectory(file)) { try { return Files.readString(file, StandardCharsets.UTF_8); diff --git a/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java b/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java index e97eaeebf..2eb29d46a 100644 --- a/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java +++ b/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java @@ -73,6 +73,7 @@ public Runtime getRuntime() { @Override public void beforeLoad(SourceLoader loader, Source source) { + // no-op } @Override @@ -111,7 +112,7 @@ public Optional configuration() { }; } - private static boolean shouldBeOverridden(String uri, String[] components) { + private static boolean shouldBeOverridden(String uri, String... components) { if (uri == null) { return false; } 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 d753c0eec..2a532b36e 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 @@ -29,9 +29,6 @@ @Customizer("platform-http") public class PlatformHttpServiceContextCustomizer extends VertxPlatformHttpServerConfiguration implements ContextCustomizer { - public PlatformHttpServiceContextCustomizer() { - } - @Override public int getOrder() { return Ordered.HIGHEST; diff --git a/camel-k-runtime-knative/pom.xml b/camel-k-runtime-knative/pom.xml index 6a27cd811..5d7a48275 100644 --- a/camel-k-runtime-knative/pom.xml +++ b/camel-k-runtime-knative/pom.xml @@ -65,6 +65,11 @@ camel-k-test test + + org.apache.camel.k + camel-knative-test + test + org.apache.camel.k diff --git a/camel-k-runtime-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceLoaderInterceptor.java b/camel-k-runtime-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceLoaderInterceptor.java index ef303b84b..160399c9e 100644 --- a/camel-k-runtime-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceLoaderInterceptor.java +++ b/camel-k-runtime-knative/src/main/java/org/apache/camel/k/loader/knative/KnativeSourceLoaderInterceptor.java @@ -36,6 +36,7 @@ public class KnativeSourceLoaderInterceptor implements SourceLoader.Interceptor @Override public void beforeLoad(SourceLoader loader, Source source) { + // no-op } @Override diff --git a/camel-k-runtime-knative/src/test/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoaderTest.java b/camel-k-runtime-knative/src/test/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoaderTest.java index 513005eba..4a6e49c2e 100644 --- a/camel-k-runtime-knative/src/test/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoaderTest.java +++ b/camel-k-runtime-knative/src/test/java/org/apache/camel/k/loader/knative/KnativeSourceRoutesLoaderTest.java @@ -18,10 +18,7 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; -import java.util.Map; -import java.util.Properties; import java.util.UUID; import java.util.stream.Stream; @@ -30,10 +27,9 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.knative.KnativeComponent; import org.apache.camel.component.knative.KnativeConstants; -import org.apache.camel.component.knative.spi.CloudEvent; -import org.apache.camel.component.knative.spi.CloudEvents; import org.apache.camel.component.knative.spi.Knative; import org.apache.camel.component.knative.spi.KnativeEnvironment; +import org.apache.camel.component.knative.test.KnativeEnvironmentSupport; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.k.Runtime; @@ -77,7 +73,7 @@ public void testWrapLoader(String uri) throws Exception { KnativeComponent component = new KnativeComponent(); component.setEnvironment(KnativeEnvironment.on( - KnativeEnvironment.endpoint(Knative.EndpointKind.sink, "sink", "localhost", runtime.port) + KnativeEnvironmentSupport.endpoint(Knative.EndpointKind.sink, "sink", "localhost", runtime.port) )); CamelContext context = runtime.getCamelContext(); diff --git a/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/KnativeEnvironment.java b/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/KnativeEnvironment.java index cfca7dca3..1703fda73 100644 --- a/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/KnativeEnvironment.java +++ b/camel-knative/camel-knative-api/src/main/java/org/apache/camel/component/knative/spi/KnativeEnvironment.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.knative.spi; +import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; @@ -63,13 +64,13 @@ public Stream lookup(Knative.Type type, String name) { // // ************************ - public static KnativeEnvironment mandatoryLoadFromSerializedString(CamelContext context, String configuration) throws Exception { + public static KnativeEnvironment mandatoryLoadFromSerializedString(CamelContext context, String configuration) throws IOException { try (Reader reader = new StringReader(configuration)) { return Knative.MAPPER.readValue(reader, KnativeEnvironment.class); } } - public static KnativeEnvironment mandatoryLoadFromResource(CamelContext context, String path) throws Exception { + public static KnativeEnvironment mandatoryLoadFromResource(CamelContext context, String path) throws IOException { try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, path)) { // // read the knative environment from a file formatted as json, i.e. : @@ -99,84 +100,6 @@ public static KnativeEnvironment mandatoryLoadFromResource(CamelContext context, } } - public static KnativeServiceDefinition endpoint(Knative.EndpointKind endpointKind, String name, String host, int port) { - return serviceBuilder(Knative.Type.endpoint, name) - .withHost(host) - .withPort(port) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) - .build(); - } - - public static KnativeServiceDefinition endpoint(Knative.EndpointKind endpointKind, String name, String host, int port, Map metadata) { - return serviceBuilder(Knative.Type.endpoint, name) - .withHost(host) - .withPort(port) - .withMeta(metadata) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) - .build(); - } - - public static KnativeServiceDefinition sourceEndpoint(String name, Map metadata) { - return serviceBuilder(Knative.Type.endpoint, name) - .withMeta(metadata) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source.name()) - .build(); - } - - public static KnativeServiceDefinition channel(Knative.EndpointKind endpointKind, String name, String host, int port) { - return serviceBuilder(Knative.Type.channel, name) - .withHost(host) - .withPort(port) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) - .build(); - } - - public static KnativeServiceDefinition channel(Knative.EndpointKind endpointKind, String name, String host, int port, Map metadata) { - return serviceBuilder(Knative.Type.channel, name) - .withHost(host) - .withPort(port) - .withMeta(metadata) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) - .build(); - } - - public static KnativeServiceDefinition sourceChannel(String name, Map metadata) { - return serviceBuilder(Knative.Type.channel, name) - .withMeta(metadata) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source) - .build(); - } - - public static KnativeServiceDefinition event(Knative.EndpointKind endpointKind, String name, String host, int port) { - return serviceBuilder(Knative.Type.event, name) - .withHost(host) - .withPort(port) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) - .build(); - } - - public static KnativeServiceDefinition sourceEvent(String name) { - return serviceBuilder(Knative.Type.event, name) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source) - .build(); - } - - public static KnativeServiceDefinition sourceEvent(String name, Map metadata) { - return serviceBuilder(Knative.Type.event, name) - .withMeta(metadata) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source) - .build(); - } - - public static KnativeServiceDefinition event(Knative.EndpointKind endpointKind, String name, String host, int port, Map metadata) { - return serviceBuilder(Knative.Type.event, name) - .withHost(host) - .withPort(port) - .withMeta(metadata) - .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) - .build(); - } - public static KnativeEnvironment on(KnativeServiceDefinition... definitions) { return new KnativeEnvironment(Arrays.asList(definitions)); } diff --git a/camel-knative/camel-knative-http/pom.xml b/camel-knative/camel-knative-http/pom.xml index 098c30367..801d74c54 100644 --- a/camel-knative/camel-knative-http/pom.xml +++ b/camel-knative/camel-knative-http/pom.xml @@ -76,6 +76,11 @@ camel-knative test + + org.apache.camel.k + camel-knative-test + test + org.apache.camel diff --git a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java index ca23300a7..f76d1c83d 100644 --- a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java +++ b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpProducer.java @@ -183,7 +183,7 @@ private static String computeUrl(KnativeEnvironment.KnativeServiceDefinition def int port = definition.getPortOrDefault(KnativeHttpTransport.DEFAULT_PORT); String path = definition.getPathOrDefault(KnativeHttpTransport.DEFAULT_PATH); - if (!path.startsWith("/")) { + if (path.charAt(0) != '/') { path = "/" + path; } diff --git a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpSupport.java b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpSupport.java index 67bb64f48..83995a925 100644 --- a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpSupport.java +++ b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpSupport.java @@ -56,7 +56,7 @@ public static Predicate createFilter(KnativeEnvironment.Knati .filter(e -> e.getKey().startsWith(Knative.KNATIVE_FILTER_PREFIX)) .collect(Collectors.toMap( e -> e.getKey().substring(Knative.KNATIVE_FILTER_PREFIX.length()), - e -> e.getValue() + Map.Entry::getValue )); return v -> { @@ -66,8 +66,6 @@ public static Predicate createFilter(KnativeEnvironment.Knati for (Map.Entry entry : filters.entrySet()) { final List values = v.headers().getAll(entry.getKey()); - final String ref = entry.getValue(); - if (values.isEmpty()) { return false; } @@ -80,7 +78,7 @@ public static Predicate createFilter(KnativeEnvironment.Knati val = val.trim(); } - boolean matches = Objects.equals(ref, val) || val.matches(ref); + boolean matches = Objects.equals(entry.getValue(), val) || val.matches(entry.getValue()); if (!matches) { return false; } diff --git a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpTransport.java b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpTransport.java index a9b061324..fc5100484 100644 --- a/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpTransport.java +++ b/camel-knative/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpTransport.java @@ -37,9 +37,6 @@ public class KnativeHttpTransport extends ServiceSupport implements CamelContext private WebClientOptions vertxHttpClientOptions; private CamelContext camelContext; - public KnativeHttpTransport() { - } - public VertxPlatformHttpRouter getRouter() { return router; } @@ -81,6 +78,7 @@ protected void doStart() throws Exception { @Override protected void doStop() throws Exception { + // no-op } // ***************************** diff --git a/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java b/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java index 63e18cb32..b61418f64 100644 --- a/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java +++ b/camel-knative/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpTest.java @@ -58,12 +58,12 @@ import static io.restassured.config.EncoderConfig.encoderConfig; import static org.apache.camel.component.knative.http.KnativeHttpTestSupport.configureKnativeComponent; import static org.apache.camel.component.knative.http.KnativeHttpTestSupport.httpAttribute; -import static org.apache.camel.component.knative.spi.KnativeEnvironment.channel; -import static org.apache.camel.component.knative.spi.KnativeEnvironment.endpoint; -import static org.apache.camel.component.knative.spi.KnativeEnvironment.event; -import static org.apache.camel.component.knative.spi.KnativeEnvironment.sourceChannel; -import static org.apache.camel.component.knative.spi.KnativeEnvironment.sourceEndpoint; -import static org.apache.camel.component.knative.spi.KnativeEnvironment.sourceEvent; +import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.channel; +import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.endpoint; +import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.event; +import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.sourceChannel; +import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.sourceEndpoint; +import static org.apache.camel.component.knative.test.KnativeEnvironmentSupport.sourceEvent; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.emptyOrNullString; import static org.hamcrest.Matchers.is; diff --git a/camel-knative/camel-knative-test/pom.xml b/camel-knative/camel-knative-test/pom.xml new file mode 100644 index 000000000..5d70accdf --- /dev/null +++ b/camel-knative/camel-knative-test/pom.xml @@ -0,0 +1,39 @@ + + + + + org.apache.camel.k + camel-knative-parent + 1.5.1-SNAPSHOT + + 4.0.0 + + camel-knative-test + + + + + org.apache.camel.k + camel-knative-api + + + + + diff --git a/camel-knative/camel-knative-test/src/main/java/org/apache/camel/component/knative/test/KnativeEnvironmentSupport.java b/camel-knative/camel-knative-test/src/main/java/org/apache/camel/component/knative/test/KnativeEnvironmentSupport.java new file mode 100644 index 000000000..e775b9d0e --- /dev/null +++ b/camel-knative/camel-knative-test/src/main/java/org/apache/camel/component/knative/test/KnativeEnvironmentSupport.java @@ -0,0 +1,105 @@ +/* + * 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.knative.test; + +import java.util.Map; + +import org.apache.camel.component.knative.spi.Knative; +import org.apache.camel.component.knative.spi.KnativeEnvironment; + +public final class KnativeEnvironmentSupport { + private KnativeEnvironmentSupport() { + } + + public static KnativeEnvironment.KnativeServiceDefinition endpoint(Knative.EndpointKind endpointKind, String name, String host, int port) { + return KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, name) + .withHost(host) + .withPort(port) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition endpoint(Knative.EndpointKind endpointKind, String name, String host, int port, Map metadata) { + return KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, name) + .withHost(host) + .withPort(port) + .withMeta(metadata) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition sourceEndpoint(String name, Map metadata) { + return KnativeEnvironment.serviceBuilder(Knative.Type.endpoint, name) + .withMeta(metadata) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source.name()) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition channel(Knative.EndpointKind endpointKind, String name, String host, int port) { + return KnativeEnvironment.serviceBuilder(Knative.Type.channel, name) + .withHost(host) + .withPort(port) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition channel(Knative.EndpointKind endpointKind, String name, String host, int port, Map metadata) { + return KnativeEnvironment.serviceBuilder(Knative.Type.channel, name) + .withHost(host) + .withPort(port) + .withMeta(metadata) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition sourceChannel(String name, Map metadata) { + return KnativeEnvironment.serviceBuilder(Knative.Type.channel, name) + .withMeta(metadata) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition event(Knative.EndpointKind endpointKind, String name, String host, int port) { + return KnativeEnvironment.serviceBuilder(Knative.Type.event, name) + .withHost(host) + .withPort(port) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition sourceEvent(String name) { + return KnativeEnvironment.serviceBuilder(Knative.Type.event, name) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition sourceEvent(String name, Map metadata) { + return KnativeEnvironment.serviceBuilder(Knative.Type.event, name) + .withMeta(metadata) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, Knative.EndpointKind.source) + .build(); + } + + public static KnativeEnvironment.KnativeServiceDefinition event(Knative.EndpointKind endpointKind, String name, String host, int port, Map metadata) { + return KnativeEnvironment.serviceBuilder(Knative.Type.event, name) + .withHost(host) + .withPort(port) + .withMeta(metadata) + .withMeta(Knative.CAMEL_ENDPOINT_KIND, endpointKind) + .build(); + } +} diff --git a/camel-knative/camel-knative/pom.xml b/camel-knative/camel-knative/pom.xml index d68e9ae9e..29f2bdd99 100644 --- a/camel-knative/camel-knative/pom.xml +++ b/camel-knative/camel-knative/pom.xml @@ -74,6 +74,11 @@ camel-k-test test + + org.apache.camel.k + camel-knative-test + test + diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java index ee5f168c5..d863be56b 100644 --- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java +++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java @@ -52,7 +52,7 @@ public class KnativeComponent extends DefaultComponent { @Metadata private Map transportOptions; - private boolean managedTransport = true; + private boolean managedTransport; public KnativeComponent() { this(null); @@ -168,6 +168,12 @@ protected void doInit() throws Exception { .getFactoryFinder(Knative.KNATIVE_TRANSPORT_RESOURCE_PATH) .newInstance(protocol.name(), KnativeTransport.class) .orElseThrow(() -> new RuntimeException("Error creating knative transport for protocol: " + protocol.name())); + + if (transportOptions != null) { + setProperties(transport, new HashMap<>(transportOptions)); + } + + this.managedTransport = true; } } diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java index 0e2b235a3..30547ba9e 100644 --- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java +++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java @@ -50,9 +50,6 @@ public class KnativeConfiguration implements Cloneable { @UriParam(label = "consumer,advanced", defaultValue = "true") private Boolean reply; - public KnativeConfiguration() { - } - // ************************ // // Properties diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java index 3de79290d..b846cc880 100644 --- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java +++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java @@ -219,15 +219,16 @@ private Stream servicesDefinitions( private Predicate serviceFilter(Knative.EndpointKind endpointKind) { return s -> { final String type = s.getMetadata(Knative.CAMEL_ENDPOINT_KIND); - final String apiv = s.getMetadata(Knative.KNATIVE_API_VERSION); - final String kind = s.getMetadata(Knative.KNATIVE_KIND); - if (!Objects.equals(endpointKind.name(), type)) { return false; } + + final String apiv = s.getMetadata(Knative.KNATIVE_API_VERSION); if (configuration.getApiVersion() != null && !Objects.equals(apiv, configuration.getApiVersion())) { return false; } + + final String kind = s.getMetadata(Knative.KNATIVE_KIND); if (configuration.getKind() != null && !Objects.equals(kind, configuration.getKind())) { return false; } diff --git a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventProcessors.java b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventProcessors.java index 96e891d2f..fe13c02c4 100644 --- a/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventProcessors.java +++ b/camel-knative/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventProcessors.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.knative.ce; +import java.util.Locale; import java.util.Map; import java.util.Objects; @@ -83,7 +84,7 @@ protected void decodeStructuredContent(Exchange exchange, Map co // Map every remaining field as it is (extensions). // content.forEach((key, val) -> { - message.setHeader(key.toLowerCase(), val); + message.setHeader(key.toLowerCase(Locale.US), val); }); } @@ -114,7 +115,7 @@ protected void decodeStructuredContent(Exchange exchange, Map co // Map every remaining field as it is (extensions). // content.forEach((key, val) -> { - message.setHeader(key.toLowerCase(), val); + message.setHeader(key.toLowerCase(Locale.US), val); }); } }), @@ -141,7 +142,7 @@ protected void decodeStructuredContent(Exchange exchange, Map co // Map every remaining field as it is (extensions). // content.forEach((key, val) -> { - message.setHeader(key.toLowerCase(), val); + message.setHeader(key.toLowerCase(Locale.US), val); }); } }); diff --git a/camel-knative/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java b/camel-knative/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java index ac6ed7acb..74272c5c0 100644 --- a/camel-knative/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java +++ b/camel-knative/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java @@ -19,6 +19,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.component.knative.spi.Knative; import org.apache.camel.component.knative.spi.KnativeEnvironment; +import org.apache.camel.component.knative.test.KnativeEnvironmentSupport; import org.apache.camel.impl.DefaultCamelContext; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -67,8 +68,8 @@ void testLoadEnvironment() throws Exception { component.setEnvironment(env); component.setTransport(new KnativeTransportNoop()); - context.getRegistry().bind("ereg", KnativeEnvironment.endpoint(Knative.EndpointKind.source, "ereg", null, -1)); - context.getRegistry().bind("creg", KnativeEnvironment.channel(Knative.EndpointKind.source, "creg", null, -1)); + context.getRegistry().bind("ereg", KnativeEnvironmentSupport.endpoint(Knative.EndpointKind.source, "ereg", null, -1)); + context.getRegistry().bind("creg", KnativeEnvironmentSupport.channel(Knative.EndpointKind.source, "creg", null, -1)); context.addComponent("knative", component); // diff --git a/camel-knative/pom.xml b/camel-knative/pom.xml index 62b7d1024..e5b405c72 100644 --- a/camel-knative/pom.xml +++ b/camel-knative/pom.xml @@ -31,6 +31,7 @@ camel-knative-api + camel-knative-test camel-knative camel-knative-http diff --git a/pom.xml b/pom.xml index ccacb1ab7..1f3d3d065 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,7 @@ 1.4.1 3.2.0 3.9.0 + 3.13.0 @@ -228,8 +229,67 @@ + + org.apache.maven.plugins + maven-pmd-plugin + ${maven-pmd-plugin.version} + + + org.codehaus.mojo + versions-maven-plugin + ${versions-maven-plugin.version} + + + org.commonjava.maven.plugins + directory-maven-plugin + ${directory-maven-plugin.version} + + + com.mycila + license-maven-plugin + ${mycila-license.version} + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + + true + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + + org.commonjava.maven.plugins + directory-maven-plugin + + + directories + + highest-basedir + + initialize + + camel-k.project.root + + + + + @@ -337,6 +397,11 @@ camel-knative-http ${project.version} + + org.apache.camel.k + camel-knative-test + ${project.version} + @@ -621,27 +686,9 @@ initialize versions:display-dependency-updates - - org.commonjava.maven.plugins - directory-maven-plugin - ${directory-maven-plugin.version} - - - directories - - highest-basedir - - initialize - - camel-k.project.root - - - - org.codehaus.mojo versions-maven-plugin - ${versions-maven-plugin.version} file:///${camel-k.project.root}/.maven-versions-rules.xml @@ -694,12 +741,10 @@ true org.apache.maven.plugins maven-deploy-plugin - ${maven-deploy-plugin.version} org.apache.maven.plugins maven-source-plugin - ${maven-source-plugin.version} attach-sources @@ -712,7 +757,6 @@ org.apache.maven.plugins maven-javadoc-plugin - ${maven-javadoc-plugin.version} attach-javadocs @@ -730,7 +774,6 @@ org.apache.maven.plugins maven-gpg-plugin - ${maven-gpg-plugin.version} ${gpg.passphrase} ${gpg.useagent} @@ -763,7 +806,6 @@ com.mycila license-maven-plugin - ${mycila-license.version}
header.txt
@@ -817,6 +859,37 @@
+ + pmd + + + + org.apache.maven.plugins + maven-pmd-plugin + + + + check + + + + + + file:///${camel-k.project.root}/tooling/pmd-ruleset.xml + + false + true + true + false + + ${project.basedir}/src/generated + ${project.build.directory}/generated-sources + + + + + + docker diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java index 7a37ec8b9..a6d323331 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java @@ -17,16 +17,14 @@ package org.apache.camel.k.tooling.maven; import java.io.IOException; -import java.io.InputStream; import java.io.Writer; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Comparator; -import java.util.Properties; +import java.util.Locale; import java.util.ServiceLoader; -import java.util.function.Consumer; import java.util.stream.StreamSupport; import com.fasterxml.jackson.annotation.JsonInclude; @@ -44,6 +42,7 @@ import org.apache.camel.k.tooling.maven.model.crd.CamelCatalogSpec; import org.apache.camel.k.tooling.maven.model.crd.RuntimeSpec; import org.apache.camel.k.tooling.maven.model.k8s.ObjectMeta; +import org.apache.camel.k.tooling.maven.support.MavenSupport; import org.apache.camel.quarkus.core.FastCamelContext; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -94,26 +93,23 @@ public void execute() throws MojoExecutionException, MojoFailureException { } final org.apache.camel.catalog.CamelCatalog catalog = new DefaultCamelCatalog(); - final String runtimeVersion = getVersion(getClass(), "/META-INF/maven/org.apache.camel.k/camel-k-maven-plugin/pom.properties"); - final String catalogName = String.format("camel-catalog-%s-%s", runtimeVersion.toLowerCase(), runtime); + final String runtimeVersion = MavenSupport.getVersion(getClass(), "/META-INF/maven/org.apache.camel.k/camel-k-maven-plugin/pom.properties"); + final String catalogName = String.format("camel-catalog-%s-%s", runtimeVersion.toLowerCase(Locale.US), runtime); try { - ServiceLoader processors = ServiceLoader.load(CatalogProcessor.class); - Comparator comparator = Comparator.comparingInt(CatalogProcessor::getOrder); - RuntimeSpec.Builder runtimeSpec = new RuntimeSpec.Builder() .version(runtimeVersion) .provider(runtime); - getVersion( + MavenSupport.getVersion( AbstractCamelContext.class, "org.apache.camel", "camel-base", version -> runtimeSpec.putMetadata("camel.version", version)); - getVersion( + MavenSupport.getVersion( FastCamelContext.class, "io.quarkus", "quarkus-core", version -> runtimeSpec.putMetadata("quarkus.version", version)); - getVersion( + MavenSupport.getVersion( QuarkusRuntimeProvider.class, "org.apache.camel.quarkus", "camel-quarkus-catalog", version -> runtimeSpec.putMetadata("camel-quarkus.version", version)); @@ -188,11 +184,11 @@ public void execute() throws MojoExecutionException, MojoFailureException { CamelCatalogSpec.Builder catalogSpec = new CamelCatalogSpec.Builder() .runtime(runtimeSpec.build()); - StreamSupport.stream(processors.spliterator(), false).sorted(comparator).filter(p -> p.accepts(catalog)).forEach(p -> { - getLog().info("Executing processor: " + p.getClass().getName()); - p.process(project, catalog, catalogSpec); - }); + StreamSupport.stream(ServiceLoader.load(CatalogProcessor.class).spliterator(), false) + .sorted(Comparator.comparingInt(CatalogProcessor::getOrder)) + .filter(p -> p.accepts(catalog)) + .forEach(p -> p.process(project, catalog, catalogSpec)); ObjectMeta.Builder metadata = new ObjectMeta.Builder() .name(catalogName) @@ -250,54 +246,4 @@ public void execute() throws MojoExecutionException, MojoFailureException { throw new MojoExecutionException("Exception while generating catalog", e); } } - - private static void getVersion(Class clazz, String path, Consumer consumer) { - consumer.accept(getVersion(clazz, path)); - } - - private static void getVersion(Class clazz, String groupId, String artifactId, Consumer consumer) { - getVersion( - clazz, - String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId), - consumer); - } - - private static synchronized String getVersion(Class clazz, String groupId, String artifactId) { - return getVersion( - clazz, - String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId)); - } - - private static synchronized String getVersion(Class clazz, String path) { - String version = null; - - // try to load from maven properties first - try (InputStream is = clazz.getResourceAsStream(path)) { - if (is != null) { - Properties p = new Properties(); - p.load(is); - version = p.getProperty("version", ""); - } - } catch (Exception e) { - // ignore - } - - // fallback to using Java API - if (version == null) { - Package aPackage = clazz.getPackage(); - if (aPackage != null) { - version = aPackage.getImplementationVersion(); - if (version == null) { - version = aPackage.getSpecificationVersion(); - } - } - } - - if (version == null) { - // we could not compute the version so use a blank - throw new IllegalStateException("Unable to determine runtime version"); - } - - return version; - } } diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java index 67d6bae26..82eb546a7 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java @@ -47,11 +47,6 @@ threadSafe = true, requiresProject = false) class GenerateRestXML extends AbstractMojo { - private static final String[] YAML_EXTENSIONS = { - "yaml", - "yml" - }; - @Parameter(property = "openapi.spec") private String inputFile; @Parameter(property = "dsl.out") @@ -102,10 +97,8 @@ public void execute() throws MojoExecutionException { final CamelContext context = new DefaultCamelContext(); final String dsl = RestDslXmlGenerator.toXml(document).generate(context); - try { + try (writer) { writer.write(dsl); - } finally { - writer.close(); } } catch (Exception e) { throw new MojoExecutionException("Exception while generating rest xml", e); diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java index 947a08ca1..b71c8c710 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java @@ -73,7 +73,7 @@ public void execute() throws MojoFailureException { .build() .writeTo(Paths.get(output)); } catch (IOException e) { - throw new MojoFailureException(e.getMessage()); + throw new MojoFailureException(e.getMessage(), e); } } @@ -181,12 +181,10 @@ public final TypeSpec generateResolver() { .forEach( i -> { AnnotationValue id = i.classAnnotation(YAML_STEP_PARSER_ANNOTATION).value("id"); - if (id != null) { - if (ids.add(id.asString())) { - mb.beginControlFlow("case $S:", id.asString()); - mb.addStatement("return new $L()", i.name().toString()); - mb.endControlFlow(); - } + if (id != null && ids.add(id.asString())) { + mb.beginControlFlow("case $S:", id.asString()); + mb.addStatement("return new $L()", i.name().toString()); + mb.endControlFlow(); } AnnotationValue aliases = i.classAnnotation(YAML_STEP_PARSER_ANNOTATION).value("aliases"); @@ -209,31 +207,35 @@ public final TypeSpec generateResolver() { AnnotationInstance meta = i.classAnnotation(METADATA_ANNOTATION); AnnotationInstance root = i.classAnnotation(XML_ROOT_ELEMENT_ANNOTATION_CLASS); - if (meta != null && root != null) { - AnnotationValue name = root.value("name"); - AnnotationValue label = meta.value("label"); - - if (name != null && label != null) { - if (bannedDefinitions != null) { - for (String bannedDefinition: bannedDefinitions) { - if (AntPathMatcher.INSTANCE.match(bannedDefinition.replace('.', '/'), i.name().toString('/'))) { - getLog().debug("Skipping definition: " + i.name().toString()); - return; - } - } - } + if (meta == null || root == null) { + return; + } + + AnnotationValue name = root.value("name"); + AnnotationValue label = meta.value("label"); - Set labels = Set.of(label.asString().split(",", -1)); - if (labels.contains("eip")) { - String id = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name.asString()); - if (ids.add(id)) { - mb.beginControlFlow("case $S:", id); - mb.addStatement("return new org.apache.camel.k.loader.yaml.parser.TypedProcessorStepParser($L.class)", i.name().toString()); - mb.endControlFlow(); - } + if (name == null || label == null) { + return; + } + + if (bannedDefinitions != null) { + for (String bannedDefinition: bannedDefinitions) { + if (AntPathMatcher.INSTANCE.match(bannedDefinition.replace('.', '/'), i.name().toString('/'))) { + getLog().debug("Skipping definition: " + i.name().toString()); + return; } } } + + Set labels = Set.of(label.asString().split(",", -1)); + if (labels.contains("eip")) { + String id = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name.asString()); + if (ids.add(id)) { + mb.beginControlFlow("case $S:", id); + mb.addStatement("return new org.apache.camel.k.loader.yaml.parser.TypedProcessorStepParser($L.class)", i.name().toString()); + mb.endControlFlow(); + } + } } ); diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlParserSupportClasses.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlParserSupportClasses.java index 5a3570ce1..20afba111 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlParserSupportClasses.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlParserSupportClasses.java @@ -66,7 +66,7 @@ public void execute() throws MojoFailureException { .build() .writeTo(Paths.get(output)); } catch (IOException e) { - throw new MojoFailureException(e.getMessage()); + throw new MojoFailureException(e.getMessage(), e); } } diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSchema.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSchema.java index dab3fcd7f..25857adb6 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSchema.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSchema.java @@ -203,39 +203,43 @@ public void execute() throws MojoFailureException { AnnotationInstance meta = i.classAnnotation(METADATA_ANNOTATION); AnnotationInstance xmlRoot = i.classAnnotation(XML_ROOT_ELEMENT_ANNOTATION_CLASS); - if (meta != null && xmlRoot != null) { - AnnotationValue name = xmlRoot.value("name"); - AnnotationValue label = meta.value("label"); - - if (name != null && label != null) { - if (bannedDefinitions != null) { - for (String bannedDefinition: bannedDefinitions) { - if (AntPathMatcher.INSTANCE.match(bannedDefinition.replace('.', '/'), i.name().toString('/'))) { - getLog().debug("Skipping definition: " + i.name().toString()); - return; - } - } - } - - Set labels = Set.of(label.asString().split(",", -1)); - if (labels.contains("eip")) { - String stepId = StringHelper.camelCaseToDash(name.asString()); - if (!ids.add(stepId)) { - return; - } + if (meta == null || xmlRoot == null) { + return; + } - processType(definitions.with(i.name().toString()), i); + AnnotationValue name = xmlRoot.value("name"); + AnnotationValue label = meta.value("label"); - ObjectNode stepNode = definitions.with("step"); - stepNode.put("type", "object"); - stepNode.put("maxProperties", 1); + if (name == null || label == null) { + return; + } - stepNode.with("properties") - .putObject(stepId) - .put("$ref", "#/items/definitions/" + i.name().toString()); + if (bannedDefinitions != null) { + for (String bannedDefinition: bannedDefinitions) { + if (AntPathMatcher.INSTANCE.match(bannedDefinition.replace('.', '/'), i.name().toString('/'))) { + getLog().debug("Skipping definition: " + i.name().toString()); + return; } } } + + Set labels = Set.of(label.asString().split(",", -1)); + if (labels.contains("eip")) { + String stepId = StringHelper.camelCaseToDash(name.asString()); + if (!ids.add(stepId)) { + return; + } + + processType(definitions.with(i.name().toString()), i); + + ObjectNode stepNode = definitions.with("step"); + stepNode.put("type", "object"); + stepNode.put("maxProperties", 1); + + stepNode.with("properties") + .putObject(stepId) + .put("$ref", "#/items/definitions/" + i.name().toString()); + } } ); @@ -246,7 +250,7 @@ public void execute() throws MojoFailureException { mapper.writerWithDefaultPrettyPrinter().writeValue(outputFile, root); } catch (IOException e) { - throw new MojoFailureException(e.getMessage()); + throw new MojoFailureException(e.getMessage(), e); } } @@ -449,9 +453,6 @@ protected static boolean implementsInterface(ClassInfo type, DotName interfaceNa } protected void setJsonSchemaType(ObjectNode node, Type type) { - String javaType = type.name().toString(); - ClassInfo typeClass = view.get().getClassByName(type.name()); - if (type.kind() == Type.Kind.PARAMETERIZED_TYPE) { ParameterizedType parameterized = type.asParameterizedType(); @@ -474,11 +475,13 @@ protected void setJsonSchemaType(ObjectNode node, Type type) { } } + final ClassInfo typeClass = view.get().getClassByName(type.name()); if (typeClass != null && typeClass.classAnnotation(YAML_NODE_DEFINITION_ANNOTATION) != null) { node.put("$ref", "#/items/definitions/" + type.name().toString()); return; } + final String javaType = type.name().toString(); switch (javaType) { /* * boolean Z @@ -541,7 +544,7 @@ protected void setJsonSchemaType(ObjectNode node, Type type) { throw new IllegalStateException("Unknown java_type: " + javaType + " on node: " + node); } } catch (ClassNotFoundException e) { - throw new IllegalStateException("Unknown java_type: " + javaType + " on node: " + node); + throw new IllegalStateException("Unknown java_type: " + javaType + " on node: " + node, e); } } } diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java index 929f7725e..c55429162 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java @@ -64,7 +64,7 @@ public void setJavaType(String javaType) { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Container { - private CatalogComponentDefinition delegate; + private final CatalogComponentDefinition delegate; @JsonCreator public Container( diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java index 1ade47c4c..824e32172 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java @@ -43,7 +43,7 @@ public void setJavaType(String javaType) { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Container { - private CatalogDataFormatDefinition delegate; + private final CatalogDataFormatDefinition delegate; @JsonCreator public Container( diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java index d2d0f204b..74d4459fa 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java @@ -43,7 +43,7 @@ public void setJavaType(String javaType) { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Container { - private CatalogLanguageDefinition delegate; + private final CatalogLanguageDefinition delegate; @JsonCreator public Container( diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java index 360908f1c..07d67be5f 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor3x.java @@ -269,7 +269,7 @@ private static void processLoaders(CamelCatalog catalog, CamelCatalogSpec.Builde ); } } - private static void processComponents(org.apache.camel.catalog.CamelCatalog catalog, Map artifacts) { + private static void processComponents(CamelCatalog catalog, Map artifacts) { for (String name : catalog.findComponentNames()) { String json = catalog.componentJSonSchema(name); CatalogComponentDefinition definition = CatalogSupport.unmarshallComponent(json); @@ -292,7 +292,7 @@ private static void processComponents(org.apache.camel.catalog.CamelCatalog cata } } - private static void processLanguages(org.apache.camel.catalog.CamelCatalog catalog, Map artifacts) { + private static void processLanguages(CamelCatalog catalog, Map artifacts) { for (String name : catalog.findLanguageNames()) { String json = catalog.languageJSonSchema(name); CatalogLanguageDefinition definition = CatalogSupport.unmarshallLanguage(json); @@ -307,7 +307,7 @@ private static void processLanguages(org.apache.camel.catalog.CamelCatalog catal } } - private static void processDataFormats(org.apache.camel.catalog.CamelCatalog catalog, Map artifacts) { + private static void processDataFormats(CamelCatalog catalog, Map artifacts) { for (String name : catalog.findDataFormatNames()) { String json = catalog.dataFormatJSonSchema(name); CatalogDataFormatDefinition definition = CatalogSupport.unmarshallDataFormat(json); diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java index 0cf167ad5..95cb82709 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/support/MavenSupport.java @@ -17,10 +17,13 @@ package org.apache.camel.k.tooling.maven.support; import java.io.File; +import java.io.InputStream; import java.net.URL; import java.net.URLClassLoader; import java.util.ArrayList; import java.util.List; +import java.util.Properties; +import java.util.function.Consumer; import org.apache.maven.project.MavenProject; @@ -44,4 +47,61 @@ public static ClassLoader getClassLoader(MavenProject project) { return IndexerSupport.class.getClassLoader(); } } + + public static String getVersion(Class clazz, String path) { + String version = null; + + // try to load from maven properties first + try (InputStream is = clazz.getResourceAsStream(path)) { + if (is != null) { + Properties p = new Properties(); + p.load(is); + version = p.getProperty("version", ""); + } + } catch (Exception ignored) { + } + + // fallback to using Java API + if (version == null) { + Package aPackage = clazz.getPackage(); + if (aPackage != null) { + version = getVersion(aPackage); + } + } + + if (version == null) { + // we could not compute the version so use a blank + throw new IllegalStateException("Unable to determine runtime version"); + } + + return version; + } + + public static String getVersion(Package pkg) { + String version = pkg.getImplementationVersion(); + if (version == null) { + version = pkg.getSpecificationVersion(); + } + + return version; + } + + public static void getVersion(Class clazz, String path, Consumer consumer) { + consumer.accept( + MavenSupport.getVersion(clazz, path) + ); + } + + public static void getVersion(Class clazz, String groupId, String artifactId, Consumer consumer) { + getVersion( + clazz, + String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId), + consumer); + } + + public static String getVersion(Class clazz, String groupId, String artifactId) { + return MavenSupport.getVersion( + clazz, + String.format("/META-INF/maven/%s/%s/pom.properties", groupId, artifactId)); + } } diff --git a/tooling/pmd-ruleset.xml b/tooling/pmd-ruleset.xml new file mode 100644 index 000000000..a20fd356c --- /dev/null +++ b/tooling/pmd-ruleset.xml @@ -0,0 +1,711 @@ + + + + PMD Rules that govern static code analysis for Camel K Runtime + + 1 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 1 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 5 + + + 4 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 4 + + + 4 + + + 4 + + + 5 + + + + + + 3 + + + 4 + + + 3 + + + 5 + + + + + + 5 + + + 3 + + + 3 + + + 3 + + + 5 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 4 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 4 + + + 3 + + + 5 + + + 3 + + + 3 + + + 3 + + + 4 + + + 1 + + + 3 + + + 3 + + + 4 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 4 + + + 3 + + + 4 + + + + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 5 + + + + + + 4 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 5 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 4 + + + 4 + + + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 5 + + + 3 + + + 3 + + + 3 + + + 4 + + + 4 + + + 3 + + + 5 + + + 4 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 4 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 1 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 5 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + 5 + + + + + + 3 + + + 3 + + + 4 + + + 3 + + + 3 + + + 3 + + + 4 + + + 4 + + + 3 + + + 3 + + + 3 + + + 3 + + + 5 + + + + + + 3 + + + 3 + + + 3 + +