tag:blogger.com,1999:blog-8719681132976995460.post2727415925141284360..comments2023-10-01T12:56:56.563+02:00Comments on Write less, do more!: Breaking the Spring by exampleNewionhttp://www.blogger.com/profile/11572139137150312052noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8719681132976995460.post-4241209655819974422013-02-17T13:49:19.188+01:002013-02-17T13:49:19.188+01:00I agree with Tomasz that bugs as well as improveme...I agree with Tomasz that bugs as well as improvements should be reported. This is the idea of open source ;)<br /><br />I cannot agree with a statement that frameworks shouldn't hide "too much magic". Frameworks are high level abstraction over some low level concepts, or just provide features which make no sense to implement over and over the same way. It is the role of a frameowrk to hide magic. The problem is when the framework is trying to do too much things. In such case framework should be split into independent modules (and Spring is somewhat modularized).<br /><br />Second thing is picking the right tool for the right problem. If you need only a subset of functionalities that Spring provides, why use Spring in first place? Why not go with something lightweight like Guice?<br /><br />Finally annotation based and xml-less configuration is relatively new in Spring (comparing to other features), so it could have bugs. It isn't also used as much, as developers seems to be using Spring in traditional way. I'm sure that Spring team will appreciate any bug reports and suggestions how to improve their framework.MichaĆ Ormanhttps://www.blogger.com/profile/11679905076687412829noreply@blogger.comtag:blogger.com,1999:blog-8719681132976995460.post-44086588760224879872013-02-13T21:13:57.680+01:002013-02-13T21:13:57.680+01:00Thanks.
>> Ad. 2.: @Primary is documented t...Thanks.<br /><br />>> Ad. 2.: @Primary is documented to only reflect autowiring. getBean() simply ignores it.<br /><br />Ok, so it's not a bug, it's a feature :)<br /><br />>> Ad. 3.: Spring does not keep reference to prototype scoped beans.<br /><br />Ok, so exception should be thrown during Spring initialization if prototype scoped event listener has been detected.<br /><br />>> Ad. 5.: [...] you can use cron expression to express simple interval [...]<br /><br />And I did it. Fortunatelly I didn't have to create cron expression for 92 min interval: http://www.vim-fu.com/90-minute-cron-job/<br /><br /><br />Sure, detected bugs should be reported. But more often than not its not a bug, its a feature :)Newionhttps://www.blogger.com/profile/11572139137150312052noreply@blogger.comtag:blogger.com,1999:blog-8719681132976995460.post-60014134261582256372013-02-13T16:21:28.622+01:002013-02-13T16:21:28.622+01:00Great article and thorough observations! However i...Great article and thorough observations! However if you believe something is a bug or needs an improvement, just report it. And few technical comments of mine:<br /><br />Ad. 1.: That looks like a bug. On the other hand you shouldn't put any heavyweight initialization into constructor. Are lifecycle callbacks called as well (I guess they are...)?<br /><br />Ad. 2.: @Primary is documented to only reflect autowiring. getBean() simply ignores it. You still have two instances in your context and this is what Spring says.<br /><br />Ad. 3.: Spring does not keep reference to prototype scoped beans. That's why destroy callback is not called for them (this is documented).<br /><br />Ad. 5.: indeed, that's unfortunate. As a workaround you can use cron expression to express simple interval - but that seems like an overkill.<br /><br />Ad. 6.: ...how @Transactional plays with different types of proxies and this: http://blog.ethlo.com/2013/01/30/spring-defaultkeygenerator-gotcha.htmlTomasz Nurkiewiczhttps://www.blogger.com/profile/05938011050162061962noreply@blogger.com