TechnoBuzz

A Techno Blog, mainly about Java

The Spring Stack 2008 – Part1

Spring 2.0 introduced support for various annotations for configuration purposes, such as:

  • @Transactional – The @Transactional annotation may be placed before an interface definition, a method on an interface, a class definition, or a public method on a class. However, please note that the mere presence of the @Transactional annotation is not enough to actually turn on the transactional behavior.
  • @Required – used to mark a property as being ‘required-to-be-set’ (i.e. an annotated (setter) method of a class must be configured to be dependency injected with a value)
  • @PersistenceContext – annotated on EntityManager instances are not thread safe
  • @PersistenceUnit – annotated on EntityManagerFactory instances are thread-safe

Thus, to use annotations for the transactions for my purposes, I do the following:

  1. Put an tag tx:annotation-driven in the config file (i.e applicationContext.xml)
  2. Put @Transactional annotation in the services class implementation that contains operations on the entity manager

Spring 2.5 introduces support for a complete set of configuration annotations:

  • @Autowired in combination with support for the JSR-250 annotations @Resource
  • @PostConstruct
  • @PreDestroy
Advertisements

July 16, 2008 Posted by | Uncategorized | 1 Comment