-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #2733 : Native support for kamelet.yaml discovery.
- Loading branch information
Showing
15 changed files
with
441 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
.../src/main/java/org/apache/camel/quarkus/component/kamelet/deployment/KameletResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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.deployment; | ||
|
||
import java.util.Optional; | ||
|
||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.Ordered; | ||
import org.apache.camel.spi.Resource; | ||
|
||
public interface KameletResolver extends Ordered { | ||
Optional<Resource> resolve(String id, CamelContext context) throws Exception; | ||
|
||
@Override | ||
default int getOrder() { | ||
return Ordered.LOWEST; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../java/org/apache/camel/quarkus/component/kamelet/deployment/KameletResolverBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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.deployment; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* Build item used by kamelet providers to plug their own way of resolving kamelets giving a name. This could be | ||
* leveraged by a future camel-quarkus-kamelet-catalog extension to resolve kamelets as they may have a different naming | ||
* structure or location in the classpath. | ||
*/ | ||
public final class KameletResolverBuildItem extends MultiBuildItem { | ||
private final KameletResolver resolver; | ||
|
||
public KameletResolverBuildItem(KameletResolver resolver) { | ||
this.resolver = resolver; | ||
} | ||
|
||
public KameletResolver getResolver() { | ||
return this.resolver; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
=== Pre-load Kamelets at build-time | ||
|
||
This extension allows to pre-load a set of Kamelets at build time using the `quarkus.camel.kamelet.identifiers` property. | ||
|
||
=== Using the Kamelet Catalog | ||
|
||
A set of pre-made Kamelets can be found on the https://camel.apache.org/camel-kamelets/latest[Kamelet Catalog]. | ||
To use the Kamelet from the catalog you need to copy their yaml definition (that you can find https://github.com/apache/camel-kamelets/[in the camel-kamelet repo]) on your project in the classpath. Alternatively you can add the `camel-quarkus-kamelets-catalog` artifact to your `pom.xml`: | ||
|
||
[source,xml] | ||
---- | ||
<dependency> | ||
<groupId>org.apache.camel.kamelets</groupId> | ||
<artifactId>camel-kamelets-catalog</artifactId> | ||
</dependency> | ||
---- | ||
|
||
This artifact add all the kamelets available in the catalog to your Camel Quarkus application for build time processing. If you include it with the scope `provided` the artifact should not be part of the runtime classpath, but at build time, all the kamelets listed via `quarkus.camel.kamelet.identifiers` property should be preloaded. |
35 changes: 35 additions & 0 deletions
35
...untime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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.util.List; | ||
import java.util.Optional; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(name = "camel.kamelet", phase = ConfigPhase.BUILD_TIME) | ||
public class KameletConfiguration { | ||
/** | ||
* List of kamelets identifiers to pre-load at build time. | ||
* <p> | ||
* Each individual identifier is used to set the related {@link org.apache.camel.model.RouteTemplateDefinition} id. | ||
*/ | ||
@ConfigItem | ||
public Optional<List<String>> identifiers; | ||
} |
45 changes: 45 additions & 0 deletions
45
...let/runtime/src/main/java/org/apache/camel/quarkus/component/kamelet/KameletRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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.util.List; | ||
|
||
import io.quarkus.runtime.RuntimeValue; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
import io.quarkus.runtime.annotations.RelaxedValidation; | ||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.model.Model; | ||
import org.apache.camel.model.RouteTemplateDefinition; | ||
import org.apache.camel.spi.CamelContextCustomizer; | ||
|
||
@Recorder | ||
public class KameletRecorder { | ||
public RuntimeValue<CamelContextCustomizer> createTemplateLoaderCustomizer( | ||
@RelaxedValidation List<RouteTemplateDefinition> definitions) { | ||
|
||
return new RuntimeValue<>(new CamelContextCustomizer() { | ||
@Override | ||
public void configure(CamelContext context) { | ||
try { | ||
context.getExtension(Model.class).addRouteTemplateDefinitions(definitions); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.