Skip to content

Injectable parameter types

Esta Nagy edited this page Jul 2, 2020 · 3 revisions

Functions, Suppliers and Predicates

Functions, Suppliers and Predicates rely on the implementation(s) of FunctionRegistry to instantiate them based on the definitions in the YML configuration file. These types had very strict rules (or limitations even) in the first versions but these limitations are more relaxed now and certainly this is not the end of the road for these.

In these cases we need to differentiate between two cases: annotated and non-annotated. Please find more details of these below.

When annotated

As of version v1.2.x the following input parameter types were available for injection for the parameters annotated with the new annotation types introduced by this release. These new annotations provide better nullability support, more compact and more descriptive way of marking parameter types, and flexible, automatic name resolution.

  1. String
  2. Collection < String >
  1. Map < String, String >
  2. Collection < Map < String, String > >
  1. Map < String, RawConfigParam >
  2. Collection < Map < String, RawConfigParam > >

These annotations became deprecated with the release of v1.2.x but are in theory suitable to support all of the options above. Complete removal of this annotation can be expected in the v1.3.x release.

Any type: Functions, Suppliers, Predicates, Rules

Non-annotated parameters injecting Spring beans

As one of the new features introduced in v1.2.x we can now mark classes later used as Spring beans as @Injectable. This annotation needs to be placed on the class of which the bean will be an instance of (not the interface, but the class implementing it instead). The annotation itself defines which type we should look for when a parameter is evaluated before injection. In case multiple beans of the same class would be present in the context, provided that Spring knows about the fact that they are injected (the bean counts as injected with @Injectable as well, then we will look for a parameter named the same way as the bean name or annotated with either @Qualifier or @Named to specify the bean name.

The currently supported injectable beans are the following.

  1. FunctionRegistryImpl
  2. JsonMapperImpl
  3. DefaultHttpClient
  4. HttpConfig
  5. SchemaStoreConfig
  6. RunConfig