-
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.
kamelets: load templates at build time
- Loading branch information
1 parent
4b8aef4
commit 74c3646
Showing
15 changed files
with
446 additions
and
2 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
15 changes: 15 additions & 0 deletions
15
.../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,15 @@ | ||
package org.apache.camel.quarkus.component.kamelet.deployment; | ||
|
||
import java.io.InputStream; | ||
import java.util.Optional; | ||
|
||
import org.apache.camel.Ordered; | ||
|
||
public interface KameletResolver extends Ordered { | ||
Optional<InputStream> resolve(String id) throws Exception; | ||
|
||
@Override | ||
default int getOrder() { | ||
return Ordered.LOWEST; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../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,20 @@ | ||
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 int 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,20 @@ | ||
=== Pre-load Kamelets at build-time | ||
|
||
This extension allow to pre-load a set of Kamelets at build time through the following two options. The kamelet to pre-load can be listed using the `quarkus.camel.kamelet.names` property. | ||
|
||
=== Using the Kamelet Catalog | ||
|
||
//TODO: does not yet exist | ||
|
||
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 either need to copy them on your project in the classpath location defined by the `quarkus.camel.kamelet.location` property, or you can add the `camel-quarkus-kamelets-catalog` artifact to your `pom.xml`: | ||
|
||
[source,xml] | ||
---- | ||
<dependency> | ||
<groupId>org.apache.camel.quarkus</groupId> | ||
<artifactId>camel-quarkus-kamelets-catalog</artifactId> | ||
</dependency> | ||
---- | ||
|
||
This artifact makes all the kamelets available in the catalog available to Camel Quarkus for build time processing, the artefact is not part of the runtime classpath. |
37 changes: 37 additions & 0 deletions
37
...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,37 @@ | ||
/* | ||
* 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 names to pre-load at build time. | ||
* | ||
* <p/> | ||
* Each individual name is used to set the related {@link org.apache.camel.model.RouteTemplateDefinition} id. | ||
* TODO: find a better name for this configuration option | ||
*/ | ||
@ConfigItem | ||
public Optional<List<String>> names; | ||
} |
42 changes: 42 additions & 0 deletions
42
...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,42 @@ | ||
/* | ||
* 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 org.apache.camel.CamelContext; | ||
import org.apache.camel.model.Model; | ||
import org.apache.camel.model.RouteTemplateDefinition; | ||
import org.apache.camel.quarkus.core.CamelContextCustomizer; | ||
|
||
@Recorder | ||
public class KameletRecorder { | ||
public RuntimeValue<CamelContextCustomizer> createTemplateLoaderCustomizer(List<RouteTemplateDefinition> definitions) { | ||
return new RuntimeValue<>(new CamelContextCustomizer() { | ||
@Override | ||
public void customize(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
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
Oops, something went wrong.