Home » Tag Archives: AspectJ

Tag Archives: AspectJ

Spring Test Context Caching + AspectJ @Transactional + Ehcache pain

aspectj-logo

Are you using AspectJ @Transactionals and Spring? Do you have multiple SessionFactory’s maybe one for an embedded database for unit testing and one for the real database for integration testing? Are you getting one of these exceptions? org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.service.UnknownServiceException: Unknown service requested or java.lang.NullPointerException at net.sf.ehcache.Cache.isKeyInCache(Cache.java:3068) at org.hibernate.cache.ehcache.internal.regions.EhcacheDataRegion.contains(EhcacheDataRegion.java:223) Then you ...

Read More »

Java: Exception translation with AspectJ

aspectj-logo

Within this blog post I describe how you can use AspectJ to automatically translate one type of exception to another. The problem Sometimes we are in situations where we have to convert an exception (often thrown by a third-party library) to another type of exception. Assume you are using a persistence framework like hibernate and you do not want to ...

Read More »

Project Student: Simplifying Code With AOP

aspectj-logo

This is part of Project Student. Many people strongly believe that methods should fit within your editor window (say, 20 lines), and some people believe that methods should be even smaller than that. The idea is that a method should do one thing and only one thing. If it does more than that it should be broken apart into multiple ...

Read More »

Integrate AspectJ with NetBeans Platform Development

aspectj-logo

Are you developing your project using the NetBeans Platform? Are you willing to use AspectJ to use AOP? You do not know how to integrate the AspectJ compiler into the builds of NetBeans? If your answer is yes, this post is for you. I decided to write this technical post because I have been struggling some time before to find ...

Read More »

Auditing a Spring MVC Webapp with AspectJ. Part 2

spring-interview-questions-answers

Now, this is the blog you want to read if you’re interested in creating a Spring MVC Webapp that uses Aspect Oriented Programming (AOP) in the form of Aspectj’s @Aspect and @Before annotations to audit a user’s visit to a screen. As I said in my last blog auditing a user’s visits to a screen is one of those few ...

Read More »

Auditing a Spring MVC Webapp with AspectJ. Part 1

aspectj-logo

If you’re like me, then you’ll have those kinds of programming days where everything seems to go incredibly well. You write the code and the tests and it just works. And then and there are those other kinds of days, the really bad ones, where you know that everything you’ve written is as right as it can be and the ...

Read More »

Getting rid of null parameters with a simple spring aspect

aspectj-logo

What is the most hated and at the same time the most popular exception in the world? I bet it’s the NullPointerException. NullPointerException can mean anything, from simple “ups, I didn’t think that can be null” to hours and days of debugging of third-party libraries (try using Dozer for complicated transformations, I dare you). The funny thing is, it’s trivial ...

Read More »

Clean code with aspects

aspectj-logo

In my previous post I’ve described the alphabet conversion, and I’ve mentioned that we used AspectJ to resolve that task, but i did not mention how AspectJ works and what are aspects generaly. So in the next few lines i will explain: what is Aspect Oriented Programming and why we need it what is AspectJ using AspectJ with Spring (configuring ...

Read More »

Spring – Adding AOP support

aspectj-logo

I heard a story about one senior (and quite highly paid) softwaree engineer. He was given task to log every method in every controller in project he was working on. Engineer rewrote all controller methods, so from code like this: @RequestMapping(method = RequestMethod.GET) public String showEmployees(Model model) { List<Employee> employees = employeeDao.list(); model.addAttribute('employees', employees); return 'employees/list'; } he made following ...

Read More »

A Simple Introduction to AOP

aspectj-logo

Why use AOP, a simple way to answer this question is to show an implementation of a cross cutting concern without using AOP. Consider a simple service and it’s implementation:                 public interface InventoryService { public Inventory create(Inventory inventory); public List<inventory> list(); public Inventory findByVin(String vin); public Inventory update(Inventory inventory); public boolean delete(Long ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close