Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Improve service filter and related methods #351

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.camel.quarkus.core.CamelMainRecorder;
import org.apache.camel.quarkus.core.CamelProducers;
import org.apache.camel.quarkus.core.CamelRecorder;
import org.apache.camel.quarkus.core.CamelServiceFilter;
import org.apache.camel.quarkus.core.CoreAttachmentsRecorder;
import org.apache.camel.quarkus.core.Flags;
import org.apache.camel.quarkus.core.UploadAttacher;
Expand All @@ -66,7 +67,7 @@ void beans(BuildProducer<AdditionalBeanBuildItem> beanProducer) {
@BuildStep
void coreServiceFilter(BuildProducer<CamelServiceFilterBuildItem> filterBuildItems) {
filterBuildItems.produce(
new CamelServiceFilterBuildItem(si -> si.path.endsWith("META-INF/services/org/apache/camel/properties-component-factory"))
new CamelServiceFilterBuildItem(CamelServiceFilter.forService("properties-component-factory"))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,41 @@

@FunctionalInterface
public interface CamelServiceFilter extends Predicate<CamelServiceInfo> {
String CAMEL_SERVICE_BASE_PATH = "META-INF/services/org/apache/camel";

static CamelServiceFilter forPathEndingWith(String path) {
return serviceInfo -> serviceInfo.path.endsWith(path);
}

static CamelServiceFilter forService(String name) {
return forPathEndingWith(CAMEL_SERVICE_BASE_PATH + "/" + name);
}

static CamelServiceFilter forComponent(String name) {
return forPathEndingWith(CAMEL_SERVICE_BASE_PATH + "/component/" + name);
}

static CamelServiceFilter forLanguage(String name) {
return forPathEndingWith(CAMEL_SERVICE_BASE_PATH + "/language/" + name);
}

static CamelServiceFilter forDataFormat(String name) {
return forPathEndingWith(CAMEL_SERVICE_BASE_PATH + "/dataformat/" + name);
}

static CamelServiceFilter forName(String name) {
return serviceInfo -> serviceInfo.name.equals(name);
}

static CamelServiceFilter forNameMatching(String regex) {
return serviceInfo -> serviceInfo.name.matches(regex);
}

static CamelServiceFilter forType(String type) {
return serviceInfo -> serviceInfo.type.equals(type);
}

static CamelServiceFilter forTypeMathing(String regex) {
return serviceInfo -> serviceInfo.type.matches(regex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.List;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
Expand All @@ -33,6 +32,7 @@
import org.apache.camel.quarkus.component.platform.http.runtime.PlatformHttpHandlers;
import org.apache.camel.quarkus.component.platform.http.runtime.PlatformHttpRecorder;
import org.apache.camel.quarkus.component.platform.http.runtime.QuarkusPlatformHttpEngine;
import org.apache.camel.quarkus.core.CamelServiceFilter;
import org.apache.camel.quarkus.core.deployment.CamelRuntimeBeanBuildItem;
import org.apache.camel.quarkus.core.deployment.CamelServiceFilterBuildItem;
import org.apache.camel.quarkus.core.deployment.UploadAttacherBuildItem;
Expand All @@ -51,10 +51,8 @@ FeatureBuildItem feature() {
* we can safely prevent camel-quarkus-core to instantiate a default instance.
*/
@BuildStep
void serviceFilter(BuildProducer<CamelServiceFilterBuildItem> filterBuildItems) {
filterBuildItems.produce(
new CamelServiceFilterBuildItem(si -> si.path.endsWith("META-INF/services/org/apache/camel/component/platform-http"))
);
CamelServiceFilterBuildItem serviceFilter() {
return new CamelServiceFilterBuildItem(CamelServiceFilter.forComponent("platform-http"));
}

@Record(ExecutionTime.RUNTIME_INIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package org.apache.camel.quarkus.reactive.executor.deployment;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.vertx.deployment.VertxBuildItem;
import org.apache.camel.quarkus.core.CamelServiceFilter;
import org.apache.camel.quarkus.core.Flags;
import org.apache.camel.quarkus.core.deployment.CamelReactiveExecutorBuildItem;
import org.apache.camel.quarkus.core.deployment.CamelServiceFilterBuildItem;
Expand All @@ -32,10 +32,8 @@ public class BuildProcessor {
* we can safely prevent camel-quarkus-core to instantiate a default instance.
*/
@BuildStep
void serviceFilter(BuildProducer<CamelServiceFilterBuildItem> filterBuildItems) {
filterBuildItems.produce(
new CamelServiceFilterBuildItem(si -> si.path.endsWith("META-INF/services/org/apache/camel/reactive-executor"))
);
CamelServiceFilterBuildItem serviceFilter() {
return new CamelServiceFilterBuildItem(CamelServiceFilter.forService("reactive-executor"));
}

@Record(value = ExecutionTime.RUNTIME_INIT, optional = true)
Expand Down