public class VarargsBeanRegistrationAotProcessor extends java.lang.Object implements BeanRegistrationAotProcessor
Gathers a variable-argument constructor argument into the array it feeds, ahead of time.
A bean declared through the plugin DSL passes its arguments positionally, and a constructor
that ends in a variable-argument parameter is called the way the language allows: one value where
the parameter is an array, or a collection where it is an array of that element type. Building the
bean, Spring adapts the argument to the parameter. Reading the definition to generate code for it,
Spring does not: it looks the argument up by the parameter's type, and a lone String does
not answer to String[].
The argument is then missed and resolved as a dependency instead, and an array of a type nobody publishes as a bean resolves to an empty array rather than failing. So the bean is built, and built wrong: a datastore that maps no classes, or a servlet registration with no URL mapping, which then falls back to mapping everything. Nothing is logged, and the bean that goes wrong is rarely the one that reports it -- the first symptom is a page that 404s or a domain class that says it is not one.
Gathering the argument into an array here means the generator writes out new String[]
{"*.gsp"}, which the lookup does find. Only an argument that is already usable as the array is
left alone, and an argument that would need its elements converted is left to the resolution that
exists today rather than guessed at here.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public BeanRegistrationAotContribution |
processAheadOfTime(RegisteredBean registeredBean) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |