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.Este conteúdo não está disponível no idioma selecionado.
56.3. Method Aliases
Overview Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
Often it can be useful to define additional names (aliases) for a given method, in addition to the standard method name that appears in the Java API. A particularly common case is where you allow a property name (such as
widget
) to be used as an alias for an accessor method (such as getWidget
or setWidget
).
Syntax Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The
aliases
element can be defined with one or more alias
child elements, as follows:
Where
MethodPattern
is a regular expression (java.util.regex
syntax) for matching method names from the Java API, and the pattern typically includes capturing groups. The Alias
is the replacement expression (for use in a URI), which can use the text from the preceding capturing groups (for example, specified as $1
, $2
, or $3
for the text from the first, second, or third capturing group).
Scope Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
As shown in the following extract, the
aliases
element can optionally appear as a child of the apis
element and/or as a child of api
elements:
You can define the
aliases
element at the following scopes:
- As a child of an
api
element—thealiases
mappings apply only to the API class specified by theapi
element. - As a child of the
apis
element—thealiases
mappings apply to all API classes by default, but can be overridden at theapi
level.
Example Copiar o linkLink copiado para a área de transferência!
Copiar o linkLink copiado para a área de transferência!
The following example shows how to generate aliases for the common get/set bean method pattern:
With the preceding alias definition, you could use
widget
as an alias for either of the methods getWidget
or setWidget
. Note the use of a capturing group, (.+)
, to capture the latter part of the method name (for example, Widget
).