It might happen, you need something to be done the second the class get loaded in (by the Class Loader).
Especially in large applications this can be quite the struggle. However there are multiple approaches to implement start-up logic in any of your classes.
What is your favorable approach to this?
- Would it be initialize it once using initializers?
- Do you prefer using a certain library/framework for this (f.e. @PostConstruct for Spring Beans)?
- Or do you have a complete other approach to this?
(Personally I prefer to have one-time start-up logic in static initializers/Bean initializers. And multi-time start-up logic in class constructors)