tag:blogger.com,1999:blog-35155095.post116042876683902276..comments2007-10-15T17:01:10.214-05:00Comments on Java Thoughts and Other Stuff: Annotations versus Configuration (More lightweight...Jeff Chttp://www.blogger.com/profile/00865412847796927368noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-35155095.post-2175025702903435172007-10-15T17:01:00.000-05:002007-10-15T17:01:00.000-05:00Working on a Hibernate/Spring project right now. G...Working on a Hibernate/Spring project right now. Got spring cfg in XML and Hib in Annotations.Recently started becoming concerned with the fact that my domain objects's now know something about their persist store (tables/cols etc) and the imports now directly reference hibernate classes for the annotations.This seems kinda ugly when in some environments I'm using I don't want them peristed to/johnlonnoreply@blogger.comtag:blogger.com,1999:blog-35155095.post-1160494864458239192006-10-10T10:41:00.000-05:002006-10-10T10:41:00.000-05:00OK, so perhaps I should have asked, done intellige...OK, so perhaps I should have asked, done intelligently do annotations have to break IOC ;)The way Stripes does it is that you annotate a member (presumably of the interface type) with @SpringBean. The annotation takes an optional bean name (not type), e.g. @SpringBean("mySpecialBean"). The wiring process then looks for a bean by that name in the context. If the name isn't specified it infers Timhttp://jroller.com/page/tfennenoreply@blogger.comtag:blogger.com,1999:blog-35155095.post-1160493125281704482006-10-10T10:12:00.000-05:002006-10-10T10:12:00.000-05:00Here's how IOC would break dependency:You create a...Here's how IOC would break dependency:You create a class. It depends on IFoo.You write into your annotation that FooImpl should be set as the dependency.The runtime should have figured out which instance you needed - at compile time you're only relying on the type, not the concrete instance. It would be especially hard to annotate a class written using the Strategy pattern - how do you annotateIcemanhttp://www.blogger.com/profile/07193759050963768511noreply@blogger.comtag:blogger.com,1999:blog-35155095.post-1160491857941798202006-10-10T09:50:00.000-05:002006-10-10T09:50:00.000-05:00I've used annotations to simplify development, and...I've used annotations to simplify development, and I find it of great use.However, i've also worked on projects where the only difference between one implementation and the other was the Hibernate configuration, so there really is some value in externalizing the config.Of course, 95% of the time it isn't the case.Brian Kapelluschhttp://www.blogger.com/profile/05893703740724637700noreply@blogger.comtag:blogger.com,1999:blog-35155095.post-1160488834698896052006-10-10T09:00:00.000-05:002006-10-10T09:00:00.000-05:00i second Tim. i dont think annotations breaks spri...i second Tim. i dont think annotations breaks spring IOC mechanism at all, in fact it makes it much easier to maintain. Check stripes Spring usage for a change please.nameless_1http://www.blogger.com/profile/07225476124525448066noreply@blogger.comtag:blogger.com,1999:blog-35155095.post-1160448111852325442006-10-09T21:41:00.000-05:002006-10-09T21:41:00.000-05:00Iceman: why would annotations break the idea of IO...Iceman: why would annotations break the idea of IOC? Here's my take.You create a class. It has a dependency. That dependency needs to be satisfied before the class can be used. You can either rely on it being wired up in an XML file, or you can annotate the property as being a dependency that needs to be injected (e.g. @Dependency).I'm not a big Spring user, and I can totally understand why Timhttp://jroller.com/page/tfennenoreply@blogger.comtag:blogger.com,1999:blog-35155095.post-1160434445998868282006-10-09T17:54:00.000-05:002006-10-09T17:54:00.000-05:00I'd say there are good uses and bad uses for annot...I'd say there are good uses and bad uses for annotations.Annotations would entirely break the idea of IOC (inversion of control) that Spring is built on, so don't hold your breath there - the Spring XML file defines the way beans are used, explicitly without the beans' knowledge, so we should never see annotations that define how a bean will be used - or by definition the bean will no longer be Icemanhttp://www.blogger.com/profile/07193759050963768511noreply@blogger.com