Configuration
Quarkus CXF exposes a large number of configuration options. Each extension documents its options at the bottom of its reference page.
The configuration options can be set in application.properties
file or via environment variables - see
Quarkus configuration reference for details.
Declarative vs. programmatic configuration
The declarative configuration set via application.properties
or via environment variables typically causes
creation and/or configuration of some CXF objects,
such as org.apache.cxf.ext.logging.LoggingFeature
, org.apache.cxf.metrics.MetricsFeature
, org.apache.cxf.configuration.jsse.TLSClientParameters
or similar.
Unless explicitly stated in the documentation, the whole life cycle of those objects is controlled by Quarkus CXF.
To prevent non-deterministic behavior, you should not mutate those objects even if they are accessible via public API of CXF.
If you need more flexibility, you should avoid configuring the given feature declaratively and rather switch to purely programmatic approach.
Bean references
Several configuration options of Quarkus CXF allow referring to beans present in Quarkus CDI container. Features and interceptors are typical examples of those.
There are two ways how to set a bean reference in the configuration: by type or by bean name.
Bean reference by type
Here is an example:
# bean reference by type
quarkus.cxf.endpoint."/hello".features = org.apache.cxf.ext.logging.LoggingFeature
When using a reference by type name, the resolution proceeds as follows:
-
Fist the bean is looked up in Quarkus CDI container by type.
-
If the bean is available, it is used.
-
If multiple beans assignable to the given type, then an exception is thrown.
-
If no matching bean is available, then the class is loaded and an attempt is performed to instantiate it using its default constructor.
Bean reference by bean name
Here is an example:
# bean reference by bean name
quarkus.cxf.endpoint."/fruit".features = #myCustomLoggingFeature
When using a reference by bean name, then unsurprisingly, the bean is looked up in Quarkus CDI container by name.
A named bean called myCustomLoggingFeature
can be defined as follows:
import org.apache.cxf.ext.logging.LoggingFeature;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
class Producers {
@Produces
@ApplicationScoped
@Named("myCustomLoggingFeature")
LoggingFeature myCustomLoggingFeature() {
LoggingFeature loggingFeature = new LoggingFeature();
loggingFeature.setPrettyLogging(true);
return loggingFeature;
}
}