The Artima Developer Community
Sponsored Link

Java Buzz Forum
Something I don't get about annotations...

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Chris Winters

Posts: 931
Nickname: cwinters
Registered: Jul, 2003

Daytime: Java hacker; nighttime: Perl hacker; sleeptime: some of both.
Something I don't get about annotations... Posted: Jul 5, 2005 11:56 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Chris Winters.
Original Post: Something I don't get about annotations...
Feed Title: cwinters.com
Feed URL: http://www.cwinters.com/search/registrar.php?domain=jroller.com®istrar=sedopark
Feed Description: Chris Winters on Java, programming and technology, usually in that order.
Latest Java Buzz Posts
Latest Java Buzz Posts by Chris Winters
Latest Posts From cwinters.com

Advertisement

I'm just now doing some development under Java 5, a year after it was released. Some of the features like generics + the modified for loop are pretty useful at making code less verbose, something java has always needed. (The angle brackets seem ugly now, but I suspect I'll get used to them like all new syntax.)

Annotations are touted as reducing much of the configuration complexity that seems to follow java apps around, usually in XML files. So instead of a rule declared in some XML file somewhere on your classpath specified in some factory you can instead annotate your class and methods with what was in the XML file But it seems that you're not able to replicate the dynamic runtime nature of that XML file. And that nature is a big part of why you use external configuration!

For instance, one of the examples authors use when describing annotations is security (see JavaWorld article). The example is useful for illustrating what you can do with annotations because everyone understands security. But it seems misleading because in the real world you'll want to load your security roles and policies from somewhere else (database, LDAP server, etc.), and it doesn't appear that you can apply data loaded at runtime to annotations. The alternative is to define in your app general roles ("admin") and then apply your specific roles loaded at runtime to the general roles from the anntations. But then you've added another layer of abstraction and have the potential for dissonance between the two -- what if the annotation role is not granular enough for later application stages?

To fix that you can just go into the source, modify the annotation and recompile, right? Easy enough, but that seems like a big problem when you're trying to create distributable components. Transactions, another often-used annotation example, have a similar problem -- I'd thought one of the benefits of EJB and Spring declarative transactions is that most code doesn't have to know about transactions, you can apply them after the fact. But with annotations we seem to be reversing this trend.

Don't get me wrong, I think annotations are very useful. But they seem more useful in making the development/build process easier -- like generating deployment descriptors, or gluing tests to your application -- than in making runtime deployment simpler.

(I mention seems throughout because I've only read a few articles/docs about annotations, and I could be completely wrong...)

Read: Something I don't get about annotations...

Topic: An Irish host that does all this? Previous Topic   Next Topic Topic: Expect better

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use