This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have written a custom annotation which i have included below
I wrote a separate class while uses the above annotation. This class uses two more annotations defined by me, but i have not included them since they have the same structure as the above one except that they are for methods and instance variables.
I have also written a main Class described below
What happens is that my Main class calls the Handler class which handles the annotation in the AnnotationUser class. I have included the handler class below
My concern is this, I have called the Handler class to handle the annotations used by the AnnotationUser from my Main. The point to note here is this: My handler class has been hardcoded with the Class name that i must check for annotations. I may look it up from a xml property file but i believe it negates the entire use of annotations.What i mean is, i am working on a big project and i have defined custom annotations to be used by my team members. How to automate the handling of those custom annotations that are in my source code(without the program calling the handler and the handler knowing beforehand the classes which uses the annotations)?Is it possible to add these Custom Annotations and their Handlers(defined by me) to the Compiler so that when i compile i dont have to specifically call the handler , rather the compiler will check the files for annotations and call the appropriate annotationhandler(Ex:suppresswarning annotation).
Again sorry for the big thread, just wanted to make myself clear.
One technique I've seen is that at application startup time the entire contents of the classpath are scanned -every single class- and checked whether they do or do not have one of the relevant annotations. That has some obvious overhead, but for a long-running server application an additional 10 seconds at startup (or whatever it turns out to be) may be negligible.
The process can be short-circuited by checking *where* a class lives; for example, if it's part of the JRE installation, then there's no need to check it for your annotations.