Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Questo contenuto non è disponibile nella lingua selezionata.
46.4. Using Apache CXF extensions
Overview Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Apache CXF provides an extension to the standard JAX-WS injection mechanism that allows developers to replace a sequence of injection annotations with a single annotation. The single annotation is place on a bean containing fields for the data that is extracted using the annotation. For example, if a resource method is expecting a request URI to include three query parameters called
id
, type
, and size
, it could use a single @QueryParam
annotation to inject all of the parameters into a bean with corresponding fields.
Note
Consider using the
@BeanParam
annotation instead (available since JAX-RS 2.0). The standardized @BeanParam
approach is more flexible than the proprietary Apache CXF extension, and is thus the recommended alternative. For details, see Section 46.2.6, “Injecting Parameters into a Java Bean”.
Supported injection annotations Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
This extension does not support all of the injection parameters. It only supports the following ones:
@PathParam
@QueryParam
@MatrixParam
@FormParam
Syntax Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To indicate that an annotation is going to use serial injection into a bean, you need to do two things:
- Specify the annotation's parameter as an empty string. For example
@PathParam("")
specifies that a sequence of URI template variables are to be serialized into a bean. - Ensure that the annotated parameter is a bean with fields that match the values being injected.
Example Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Example 46.11, “Injecting query parameters into a bean” shows an example of injecting a number of Query parameters into a bean. The resource method expect the request URI to include two query parameters:
type
and id
. Their values are injected into the corresponding fields of the Monster
bean.
Example 46.11. Injecting query parameters into a bean