Wednesday, December 21, 2016

Annotations

ANNOTATIONS

---------------------------------------------------------------------------------------------------------------------
In JAVA application to provide description or METADATA, JDK5.0 version has provided a new feature called as "Annotation".

Q). In JAVA application, to provide description we have comments then what is the requirement to use Annotation?
------------------------------------------------------------------------------------------------------------------
Ans.
-----
In JAVA Application if we provide description along with comments then "Lexical Analysis" phase will remove comments and description from JAVA program here the provided comments are not available upto .class files and upto RUNTIME of our application.

As per the requirement, if we want to bring metadata or description upto .java file or .class file and upto RUNTIME of the application, we have to use "Annotation".
---------------------------------------------------------

Q). In JAVA Application to provide metadata at RUNTIME of Application, we already have "xml" document then what is the requirement to use Annotation?
-----------------------------------------------------------------------------------------------------------------------
Ans.
-------
In JAVA application, if we use xml documents to provide metadata at RUNTIME, Then we will get following problems:
1. we must know xml techonology.
2. Every time we have to check whether xml docments are located properly or not.
3. Every time we have to check whether xml documents are formatted properly or not.
4. Every time we have to check whether we are using right parsing mechanism or not.

To overcome the above problems, we need java alternative that is "Annotation".

Note: In JAVA/J2EE application, Annotation are the best replacement for xml documents.

List of Technologies based on xml & Annotations.

XML Based Tech    Annotation Based Tech[XML is optional]

-----------------                   --------------------------------------
Upto JDK1.4 -----------------> JDK5.0 And above
JDBC3.0 ----------------------> JDBC4.0
Servlets2.5 --------------------> Servlets3.x
Struts1.x ----------------------> Struts2.x
JSF1.x -------------------------> JSF2.x
Spring2.x ----------------------> Spring3.x
EJBs2.x ------------------------> EJBs3.x

No comments:

Post a Comment