Oliver Drotbohm Archive About Tags

5 (or 3) aspects you probably haven't thought about

June 11th, 2008

Alef Arendsen started by giving a short introduction into basic AOP concepts. After that he presented a sample project using Hibernate and JDBC data access together. He construted a business case where the Hibernate property of delaying actual data insert to the database until transaction commit. The solution to the problem would be to flush the hibernate session appropriately. But what means appropriately in this case? Who is responsible to execute the flush? Alef constructed an aspect that watches JdbcTemplate operations and executes the flush accordingly.

The next example was about retrieving localized data. Localized in the sense, that Alef wanted to access all car parts available in a given area. He introduced a view localizing the data into the database and let Hibernate work against that view. Finally he let the current area to retrieve the data for be propagated. This was realized applying an advice to transaction begin time to write the session state area context into the database. To prevent duplicate propagation Alef introduced the AspectJ cflow concept allowing to define pointcuts in the context of anoher pointcut. This means you can describe a pointcut to match a transactional method and only get it fired on the first transactional method even if it triggers other transactional methods that would fire the advice again otherwise. The neat thing about this advice application was, that the filter logic is kept in the database. The aspect itself is only the controller for the actually transparent logic.

Alefs last example was first failure capturing adressing the need to trigger logic on the first occurrence of an exception avoiding to handle the exception twice. Once again he made heavy use of cflow ponitcut definitions. Alef also used a custom aspect instatiation model - instance per pointcut call in this case.

This was a really awesome talk as it showed up the enormous power of AOP and the things you actually can achieve with it.

blog comments powered by Disqus