Skip to content

Commit

Permalink
Fix #1066 Remove the need for registering RestBindingJaxbDataFormatFa…
Browse files Browse the repository at this point in the history
…ctory service
  • Loading branch information
ppalaga committed Jun 10, 2020
1 parent 1ad0ef2 commit a3c95fc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
import org.apache.camel.quarkus.core.deployment.util.CamelSupport;
import org.apache.camel.quarkus.core.deployment.util.PathFilter;
import org.apache.camel.quarkus.support.common.CamelCapabilities;
import org.apache.camel.spi.FactoryFinder;
import org.apache.camel.spi.RestBindingJaxbDataFormatFactory;
import org.apache.camel.spi.TypeConverterLoader;
import org.apache.camel.spi.TypeConverterRegistry;
import org.jboss.jandex.ClassInfo;
Expand Down Expand Up @@ -191,14 +189,6 @@ void coreServicePatterns(BuildProducer<CamelServicePatternBuildItem> services) {
"META-INF/services/org/apache/camel/dataformat/*",
"META-INF/services/org/apache/camel/send-dynamic/*"));

// TODO: this can be removed and the RestBindingJaxbDataFormatFactory can be discovered
// and instantiated when camel is on the classpath with a camel context customizer
// when https://github.com/apache/camel-quarkus/issues/984 will be implemented
services.produce(new CamelServicePatternBuildItem(
CamelServiceDestination.DISCOVERY,
true,
FactoryFinder.DEFAULT_PATH + RestBindingJaxbDataFormatFactory.FACTORY));

services.produce(new CamelServicePatternBuildItem(
CamelServiceDestination.DISCOVERY,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

import com.sun.xml.bind.v2.runtime.output.FastInfosetStreamWriterOutput;
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 io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import org.apache.camel.quarkus.component.jaxb.JaxbRecorder;
import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;

class JaxbProcessor {

Expand All @@ -35,4 +39,10 @@ RuntimeInitializedClassBuildItem fastInfosetStreamWriterOutput() {
return new RuntimeInitializedClassBuildItem(FastInfosetStreamWriterOutput.class.getCanonicalName());
}

@BuildStep
@Record(value = ExecutionTime.STATIC_INIT)
CamelContextCustomizerBuildItem contextCustomizer(JaxbRecorder recorder) {
return new CamelContextCustomizerBuildItem(recorder.newRestBindingJaxbDataFormatFactoryContextCustomizer());
}

}
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.
*/
package org.apache.camel.quarkus.component.jaxb;

import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.converter.jaxb.JaxbRestBindingJaxbDataFormatFactory;
import org.apache.camel.quarkus.core.CamelContextCustomizer;

@Recorder
public class JaxbRecorder {
public RuntimeValue<CamelContextCustomizer> newRestBindingJaxbDataFormatFactoryContextCustomizer() {
JaxbRestBindingJaxbDataFormatFactory factory = new JaxbRestBindingJaxbDataFormatFactory();
return new RuntimeValue<>(
context -> context.adapt(ExtendedCamelContext.class).setRestBindingJaxbDataFormatFactory(factory));
}

}

0 comments on commit a3c95fc

Please sign in to comment.