Do you remember 6/7 years ago. EJBs were the big thing and with them came deployment descriptor written in XML. Then Webapp with their web.xml, and then Enterprise applications with their application.xml. XML was everywhere, XML was cool. Imagine, you can write your Java code, deploy it and after just twist bits and pieces in your XML files. XML, XML… Then we had SAX, DOM, JAXB, Castor, XSL, XSLT, Schemas, DTD… God, life became so flexible. Too flexible ? Of course ! XML has taken over our lives, we all hate XML now. We hate it so much that we started using xDoclet to get rid of it.
But now, thanks to Java 5, we are really getting rid of XML and giving up all this XML flexible into more rigid annotations. But it‘s so much better : code and annotations are at the same place, on the same class, on the same method. Much better, easier to read. You see, annotations are so cool that we use them for persistence (Hibernate, JPA…), components (EJB 3), unit testing (JUnit 4), XML (with JAXB 2)… and so on. Yes, I tell you, annotations are great !
And there is no way that in 6/7 years we will end up coding this :
@Entity @Name('componentName') @Inheritance @Scope(ScopeType.CONVERSATION) @Logger('loggerName') @TransactionAttribute(NEVER) @Remote({examples.Animal.class}) @ExcludeDefaultInterceptors @NamedQuery(name='findAllAnimals') class Animal extends Creature ( @Id @SequenceGenerator(name='ANIMAL_SEQ', allocationSize=25) @GeneratedValue(strategy=SEQUENCE, generator='ANIM_SEQ') @Column(name='ANIM_ID') private String id @AssociationOverride @Enumerated private Owner owner @Deprecated @AroundInvoke @Version static void deprecatedMethod() (...) @Override @JoinTable Hay getPreferredFood() (...) @Intercept(InterceptionType.ALWAYS) @Ignore void intercepts (...) @SuppressWarnings('deprecation') @In(required=false) @ExcludeClassInterceptors @PreDestroy void useDeprecatedMethod() {...} )