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

Fix #1066 Remove the need for registering RestBindingJaxbDataFormatFa… #1331

Merged
merged 1 commit into from
Jun 10, 2020
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 @@ -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));
}

}