Donnerstag, 18. September 2014

Why Spring makes me sick #16

In a project I have to work on, there is amongst others a definition of a simple bean of class testDoubles.MemoryLogClient.

So I was expecting that if I retrieved that bean from the Spring application context, that it is of type testDoubles.MemoryLogClient.

But Spring actually replaces the bean by a proxy (the retrieved bean is of type com.sun.proxy.$Proxy) and to make things worse, overrides the toString() method so that it reports type testDoubles.MemoryLogClient.
I.e. in my debug logs I see that the object reports to be of the correct type, but an assignment to a variable of the same type fails with a ClassCastException.

Yet another way Spring makes a developers life really hard...

Oh, by the way, the IMHO simplest solution is to extract an interface (in my case from testDoubles.MemoryLogClient) and assign the retrieved bean to a variable that has this interface as type.
But you will find much more complicated solutions on the interwebs (such as stackoverflow.com) that suggest to use AOP, which will convert this problem into a full blown disaster ;)

Netflix ist endlich in Österreich angekommen :)



via Instagram

September 18, 2014 at 12:47AM

Montag, 15. September 2014

Stillleben



via Instagram

September 15, 2014 at 10:44PM

Mein Zuhause für heute...



via Instagram

September 15, 2014 at 06:08PM

(Video)



Bild anklicken um das Video zu sehen!

via Instagram

September 15, 2014 at 02:59PM

demotiviert im Motivationsseminar - irgendetwas läuft hier schief...


Seminar in Burgenland



via Instagram

September 15, 2014 at 08:55AM

Sonntag, 14. September 2014

Mittwoch, 10. September 2014

Samstag, 6. September 2014

Genußmeile



via Instagram

September 06, 2014 at 05:50PM

Dienstag, 2. September 2014