This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit a99cfb96080fa4ef4826f417a4ff317c24100c28 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Fri Jun 19 09:59:24 2020 +0100 Remove redundant BeanValidatorRecorder --- .../deployment/BeanValidatorProcessor.java | 25 ------- .../bean/validator/BeanValidatorRecorder.java | 82 ---------------------- 2 files changed, 107 deletions(-) diff --git a/extensions/bean-validator/deployment/src/main/java/org/apache/camel/quarkus/component/bean/validator/deployment/BeanValidatorProcessor.java b/extensions/bean-validator/deployment/src/main/java/org/apache/camel/quarkus/component/bean/validator/deployment/BeanValidatorProcessor.java index 7547b1c..9efc9fb 100644 --- a/extensions/bean-validator/deployment/src/main/java/org/apache/camel/quarkus/component/bean/validator/deployment/BeanValidatorProcessor.java +++ b/extensions/bean-validator/deployment/src/main/java/org/apache/camel/quarkus/component/bean/validator/deployment/BeanValidatorProcessor.java @@ -17,14 +17,7 @@ package org.apache.camel.quarkus.component.bean.validator.deployment; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.ExecutionTime; -import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; -import org.apache.camel.component.bean.validator.BeanValidatorComponent; -import org.apache.camel.quarkus.component.bean.validator.BeanValidatorRecorder; -import org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeBeanBuildItem; -import org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilter; -import org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem; class BeanValidatorProcessor { @@ -34,22 +27,4 @@ class BeanValidatorProcessor { FeatureBuildItem feature() { return new FeatureBuildItem(FEATURE); } - - /* - * The bean-validator component is programmatically configured by the extension thus - * we can safely prevent camel to instantiate a default instance. - */ - @BuildStep - CamelServiceFilterBuildItem serviceFilter() { - return new CamelServiceFilterBuildItem(CamelServiceFilter.forComponent("bean-validator")); - } - - @Record(ExecutionTime.STATIC_INIT) - @BuildStep - CamelRuntimeBeanBuildItem beanValidatorComponent(BeanValidatorRecorder recorder) { - return new CamelRuntimeBeanBuildItem( - "bean-validator", - BeanValidatorComponent.class.getName(), - recorder.createBeanValidatorComponent()); - } } diff --git a/extensions/bean-validator/runtime/src/main/java/org/apache/camel/quarkus/component/bean/validator/BeanValidatorRecorder.java b/extensions/bean-validator/runtime/src/main/java/org/apache/camel/quarkus/component/bean/validator/BeanValidatorRecorder.java deleted file mode 100644 index 988c901..0000000 --- a/extensions/bean-validator/runtime/src/main/java/org/apache/camel/quarkus/component/bean/validator/BeanValidatorRecorder.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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.bean.validator; - -import java.util.Map; - -import javax.validation.ValidatorFactory; - -import io.quarkus.runtime.RuntimeValue; -import io.quarkus.runtime.annotations.Recorder; -import org.apache.camel.CamelContext; -import org.apache.camel.Component; -import org.apache.camel.Endpoint; -import org.apache.camel.Producer; -import org.apache.camel.component.bean.validator.BeanValidatorComponent; -import org.apache.camel.component.bean.validator.BeanValidatorEndpoint; -import org.apache.camel.component.bean.validator.BeanValidatorProducer; -import org.apache.camel.support.CamelContextHelper; - -@Recorder -public class BeanValidatorRecorder { - /* - * TODO: remove when rebasing on Camel > 3.0.0-RC3 as camel-main engine - * should automatically bind the ValidatorFactory set-up by Quarkus - * to the component - */ - public RuntimeValue<BeanValidatorComponent> createBeanValidatorComponent() { - return new RuntimeValue<>(new QuarkusBeanValidatorComponent()); - } - - static class QuarkusBeanValidatorComponent extends BeanValidatorComponent { - @Override - protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - BeanValidatorEndpoint endpoint = new QuarkusBeanValidatorEndpoint(uri, this); - endpoint.setLabel(remaining); - - setProperties(endpoint, parameters); - - return endpoint; - } - } - - static class QuarkusBeanValidatorEndpoint extends BeanValidatorEndpoint { - public QuarkusBeanValidatorEndpoint(String endpointUri, Component component) { - super(endpointUri, component); - } - - @Override - public Producer createProducer() throws Exception { - final CamelContext camelContext = getCamelContext(); - final BeanValidatorProducer producer = new BeanValidatorProducer(this); - final String group = getGroup(); - - if (group != null) { - producer.setGroup(camelContext.getClassResolver().resolveMandatoryClass(group)); - } - - ValidatorFactory validatorFactory = CamelContextHelper.mandatoryLookup( - camelContext, - "quarkus-hibernate-validator-factory", - ValidatorFactory.class); - - producer.setValidatorFactory(validatorFactory); - - return producer; - } - } -}