Sunday, December 20, 2009

Spring annotations static injection tutorial

I found this interesting code snippet to initialize static properties of a class using Spring IoC

public class UserUtils
  private static UserAccessor userAccessor;

   * Sets the rule DAO. This method should never be called except by Spring
   * @param userAccessor The user accessor to set
  @Autowired(required = true)
  public void setUserAccessor(userAccessor UserAccessor) {
    UserUtils.userAccessor = userAccessor;

No comments:

Post a Comment