Java annotations and meta-objects
Annotations are meta-meta-objects which can be used to explain other meta-objects. Meta-objects are sessions, areas and techniques. Asking an item for its meta-object (e.g. anObj.getClass()) is known as more self examination. The more self examination can go further and we can ask a meta-object what are its annotations (e.g. aClass.getAnnotations). Introspection and annotations are part of what is known as representation and meta-programming.
An annotation needs to be considered in one way or another to be useful. Annotations can be considered at development-time by the IDE or the compiler or at run-time by a structure.
Annotation handling is a very highly effective procedure and can be used in a lot of different ways:
- To explain restrictions or use of an element: e.g. @Deprecated, @Override, or @Not Null
- to explain the "nature" of a feature, e.g. @Entity, @TestCase, @WebService
- to explain the actions of an element: @Statefull, @Transaction
- to explain how to procedure the element: @Column, @XmlElement
- In all situations, an annotation is used to explain the factor and explain its significance.
- Prior to JDK5, details that is now indicated with annotations required to be saved somewhere else, and XML details were regularly used. But it is more practical to use annotations because they will are part of the Coffee rule itself, and are hence much simpler to control than XML.
Usage of annotations:
- Documentation, e.g. XDoclet
- Compilation
- IDE
- Testing structure, e.g. JUnit
- IoC package e.g. as Spring
- Serialization, e.g. XML
- Aspect-oriented growth (AOP), e.g. Springtime AOP
- Application web servers, e.g. EJB package, Web Service
- Object-relational applying (ORM), e.g. Hibernate, JPA
Our CRB Tech provides Java course in Pune.