|

Spring series, part 6: Spring 4 and Generics-based Injection Matching

Up until Spring 4 generics played no major role when it came to resolving injected bean dependencies. Suppose there are multiple beans of the same type implementing a generic interface. In a pre-Spring 4 world, any attempt to resolve such a bean by type would inevitably lead to a NonUniqueBeanDefinition exception, unless additional hints were…

|

Tomcat – java.lang.InternalError: name is too long to represent

I’ve got the aforementioned exception  when I was trying to load a jsp page on Tomcat 6 running in a debug mode. Turns out the problem occurs when a jsp page grows big. It’s a known JVM issue described by bugs 39089 and 6294277. Here is how to solve it without touching the jsp. Open conf/web.xml In your…

| |

JUnitParams – parameterized unit tests

Less unit test code doesn’t necessarily result into poor coverage. I’ve recently entered the paradigm of parameterized tests when refactoring a larger test suite. I ended up writing significantly less code without compromising on the extent. In fact, adding a few corner cases was almost a no-brainer. In this post I’d like to share my…

|

Spring series, part 5: @Component vs @Bean

In this post, I will look into the distinction between a component and a bean. Even though both of them refer to Spring managed beans, each serves a different purpose. @Component and its specializations (@Controller, @Service and @Repository) allow for auto-detection using classpath scanning. @Bean on the other hand can only be used to explicitly…