@Documented @Retention(value=RUNTIME) @Target(value={METHOD,TYPE,ANNOTATION_TYPE}) public @interface Parallel
A hint annotation that can be added to Bean definitions or Executable methods to indicate that they can be initialized in
parallel with the application context.
This allows optimized startup time by allowing beans that have slow initialization paths to startup and without impacting the overall startup time of the application.
Note that beans and methods that are processed in parallel (unlike Context scoped beans) will not initially fail the startup of the ApplicationContext
as they may be initialized after the ApplicationContext has started and cannot participate in StartupEvent processing. If a parallel bean fails to startup it will by default stop the ApplicationContext with an error unless shutdownOnError() set to to false.
Adding Parallel to methods is most useful when used in conjunction with a ExecutableMethodProcessor. Be aware however, that the processor in this case should be thread safe as could be executed in parallel for different methods.
NOTE: The use of Parallel generally only makes sense when combined with non Prototype scopes such as Singleton and Context
Context,
Executable,
ExecutableMethodProcessor| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
shutdownOnError
The default behaviour is to shutdown the context if an error occurs on initialization.
|