Search code examples
javaspringseam

Spring Equivalent of @Factory Annotation of Seam


we recently converted our project from JBoss seam to using Spring and JSF. Our controller needs to initialize some properties. Right now were simply using the constructor to call the initialization methods. Seam has @Factory annotation decorated to a method which is called whenever the accessed property/field is null. Does Spring have an equivalent annotation? Thanks a lot.


Solution

  • No, but Spring supports the JSR-250 lifecycle annotations @PostConstruct / @PreDestroy, which you can use for housekeeping when your bean starts up.

    In fact there are at least three mechanisms for bean lifecycle management, and their interaction and precedence is explained in the chapter "Combining lifecycle mechanisms"