This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes annotation problem. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "annotation problem." Watch "annotation problem." New topic
Author

annotation problem.

ankur trapasiya
Ranch Hand

Joined: Sep 24, 2010
Posts: 160

Hello all..

I am assigned a task to develop a custom annotation for database connectivity



Now at a very basic level i have created one annotation but it is not fulfilling my this requirement..can anyone guide me how to develop this type of annotation? I surfed and come to know that to inject an entity like in built annotations we have to use reflections. is it so ?

and there is no tutorial available for this kind of annotation also..
some expert please guide me regarding this ..


Thanks in advance............


OCPJP(83%)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

http://download.oracle.com/javase/tutorial/reflect/index.html

I don't know if that's been updated to handle annotations though.
If not, then there are a few methods you need to learn after reading it:
- isAnnotationPresent checks if a specific annotation is present
- getAnnotation returns a specific annotation (or null if not present).

In your case, once you have a java.lang.reflect.Field for field "con" you get its annotation like this:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: annotation problem.
 
Similar Threads
JDBC book suggestions
How To Connect JSP with MySQL
Custom Annotation :: inject object at runtime
two way communication using sip servlet
bulk mail and bulk sms