Skip to content

Commit

Permalink
Create an extension fot camel-k-runtime-master apache#470
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Sep 16, 2020
1 parent 0631726 commit c88c8b0
Show file tree
Hide file tree
Showing 19 changed files with 598 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ jobs:
with:
version: ${{ matrix.java }}
- name: Build on ${{ matrix.java }}
if: contains( github.event.pull_request.labels.*.name, 'depends-on/camel/master') == 'false' && contains( github.event.pull_request.labels.*.name, 'depends-on/quarkus/master') == 'false'
run: |
./mvnw -V -B -ntp clean install
build-native:
Expand All @@ -112,6 +111,7 @@ jobs:
native-image-project:
- :camel-k-quarkus-itests-core
- :camel-k-quarkus-itests-cron
- :camel-k-quarkus-itests-master
- :camel-k-quarkus-itests-kamelet
- :camel-k-quarkus-itests-knative
- :camel-k-quarkus-itests-loader-xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import org.apache.camel.k.Constants;
import org.apache.camel.k.ContextCustomizer;
import org.apache.camel.k.SourceDefinition;
import org.apache.camel.k.core.quarkus.RuntimeRecorder;
import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
Expand Down Expand Up @@ -57,9 +58,17 @@ List<CamelServicePatternBuildItem> servicePatterns() {
}

@BuildStep
List<ReflectiveClassBuildItem> registerClasses() {
return List.of(
new ReflectiveClassBuildItem(true, false, SourceDefinition.class)
List<ReflectiveClassBuildItem> registerClasses(CombinedIndexBuildItem index) {
return List.of(
new ReflectiveClassBuildItem(
true,
false,
SourceDefinition.class),
new ReflectiveClassBuildItem(
true,
false,
getAllKnownImplementors(index.getIndex(), ContextCustomizer.class, ci -> ci.name().toString())
.toArray(String[]::new))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,62 +35,62 @@ private DeploymentSupport() {
public static Iterable<ClassInfo> getAllKnownImplementors(IndexView view, String name) {
return view.getAllKnownImplementors(DotName.createSimple(name));
}
public static <T> Iterable<T> getAllKnownImplementors(IndexView view, String name, Function<ClassInfo, T> mapper) {
return stream(getAllKnownImplementors(view, name)).map(mapper).collect(Collectors.toList());
public static <T> Stream<T> getAllKnownImplementors(IndexView view, String name, Function<ClassInfo, T> mapper) {
return stream(getAllKnownImplementors(view, name)).map(mapper);
}


public static Iterable<ClassInfo> getAllKnownImplementors(IndexView view, Class<?> type) {
return view.getAllKnownImplementors(DotName.createSimple(type.getName()));
}
public static <T> Iterable<T> getAllKnownImplementors(IndexView view, Class<?> type, Function<ClassInfo, T> mapper) {
return stream(getAllKnownImplementors(view, type)).map(mapper).collect(Collectors.toList());
public static <T> Stream<T> getAllKnownImplementors(IndexView view, Class<?> type, Function<ClassInfo, T> mapper) {
return stream(getAllKnownImplementors(view, type)).map(mapper);
}


public static Iterable<ClassInfo> getAllKnownImplementors(IndexView view, DotName type) {
return view.getAllKnownImplementors(type);
}
public static <T> Iterable<T> getAllKnownImplementors(IndexView view, DotName type, Function<ClassInfo, T> mapper) {
return stream(getAllKnownImplementors(view, type)).map(mapper).collect(Collectors.toList());
public static <T> Stream<T> getAllKnownImplementors(IndexView view, DotName type, Function<ClassInfo, T> mapper) {
return stream(getAllKnownImplementors(view, type)).map(mapper);
}


public static Iterable<ClassInfo> getAllKnownSubclasses(IndexView view, String name) {
return view.getAllKnownSubclasses(DotName.createSimple(name));
}
public static <T> Iterable<T> getAllKnownSubclasses(IndexView view, String name, Function<ClassInfo, T> mapper) {
return stream(getAllKnownSubclasses(view, name)).map(mapper).collect(Collectors.toList());
public static <T> Stream<T> getAllKnownSubclasses(IndexView view, String name, Function<ClassInfo, T> mapper) {
return stream(getAllKnownSubclasses(view, name)).map(mapper);
}


public static Iterable<ClassInfo> getAllKnownSubclasses(IndexView view, Class<?> type) {
return view.getAllKnownSubclasses(DotName.createSimple(type.getName()));
}
public static <T> Iterable<T> getAllKnownSubclasses(IndexView view, Class<?> type, Function<ClassInfo, T> mapper) {
return stream(getAllKnownSubclasses(view, type)).map(mapper).collect(Collectors.toList());
public static <T> Stream<T> getAllKnownSubclasses(IndexView view, Class<?> type, Function<ClassInfo, T> mapper) {
return stream(getAllKnownSubclasses(view, type)).map(mapper);
}

public static Iterable<ClassInfo> getAllKnownSubclasses(IndexView view, DotName type) {
return view.getAllKnownSubclasses(type);
}
public static <T> Iterable<T> getAllKnownSubclasses(IndexView view, DotName type, Function<ClassInfo, T> mapper) {
return stream(getAllKnownSubclasses(view, type)).map(mapper).collect(Collectors.toList());
public static <T> Stream<T> getAllKnownSubclasses(IndexView view, DotName type, Function<ClassInfo, T> mapper) {
return stream(getAllKnownSubclasses(view, type)).map(mapper);
}


public static Iterable<ClassInfo> getAnnotated(IndexView view, String name) {
return getAnnotated(view, DotName.createSimple(name));
}
public static <T> Iterable<T> getAnnotated(IndexView view, String name, Function<ClassInfo, T> mapper) {
return stream(getAnnotated(view, name)).map(mapper).collect(Collectors.toList());
public static <T> Stream<T> getAnnotated(IndexView view, String name, Function<ClassInfo, T> mapper) {
return stream(getAnnotated(view, name)).map(mapper);
}

public static Iterable<ClassInfo> getAnnotated(IndexView view, Class<?> type) {
return getAnnotated(view, DotName.createSimple(type.getName()));
}
public static <T> Iterable<T> getAnnotated(IndexView view, Class<?> type, Function<ClassInfo, T> mapper) {
return stream(getAnnotated(view, type)).map(mapper).collect(Collectors.toList());
public static <T> Stream<T> getAnnotated(IndexView view, Class<?> type, Function<ClassInfo, T> mapper) {
return stream(getAnnotated(view, type)).map(mapper);
}

public static Iterable<ClassInfo> getAnnotated(IndexView view, DotName type) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-itests</artifactId>
<version>1.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>camel-k-quarkus-itests-master</artifactId>

<dependencies>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-runtime-quarkus</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-master</artifactId>
</dependency>

<!-- quarkus dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin-version}</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>test.http.port.jvm</portName>
<portName>test.http.port.native</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<quarkus.http.test-port>${test.http.port.jvm}</quarkus.http.test-port>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
<quarkus.native.additional-build-args>--language:js</quarkus.native.additional-build-args>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<quarkus.http.test-port>${test.http.port.native}</quarkus.http.test-port>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.k.quarkus.master;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonObject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.apache.camel.CamelContext;
import org.apache.camel.component.kubernetes.cluster.KubernetesClusterService;

@Path("/test")
@ApplicationScoped
public class Application {
@Inject
CamelContext context;

@GET
@Path("/inspect")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject findCronInterceptor() {
KubernetesClusterService service = context.hasService(KubernetesClusterService.class);

return Json.createObjectBuilder()
.add("cluster-service", service != null ? service.getClass().getName() : "")
.add("cluster-service-cm", service != null ? service.getConfigMapName() : "")

.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

#
# Quarkus
#
quarkus.log.console.enable = true
quarkus.banner.enabled = false

#
# Quarkus :: Camel
#
quarkus.camel.routes-discovery.enabled = false

#
# Camel K
#
camel.k.customizer.master.enabled = true
camel.k.customizer.master.config-map-name = camel-k-cm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.k.quarkus.master;

import io.quarkus.test.junit.NativeImageTest;

@NativeImageTest
public class MasterIT extends MasterTest {
}
Loading

0 comments on commit c88c8b0

Please sign in to comment.