I presented a talk on Java Annotations to the Columbia, Maryland Java Users Group on 1/19/2010.
This page contains links to a video recording of the talk and the source code that I wrote during the talk.
I hope you find it informative, entertaining and useful!
Java Annotations by Scott Stanchfield is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Feel free to watch the videos and point friends to them, but you cannot use them as part of any commercial product nor can you create derivative works. Follow the link above to see the complete license text.
Part 1 - Introduction
Introduction to Java Annotations (what they are and why you would use them).
Creating annotations that are kept in the generated class files but not loaded in the VM at runtime.
Example of annotating methods with a custom @Test annotation to run in a test runner similar to junit.
Part 4 - Runtime Annotations 2
Example of annotating methods to be used as actions that are triggered from buttons in a user interface.
Part 5 - Code Generation 1
Writing an annotation processor that runs at compile time to generate an RMI interface from a standard interface.
Part 6 - Code Generation 2
Using an annotation processor to generate JavaBean boilerplate code.
Here is the sample code I wrote during the lecture. Note that this code is not intended for production use.
All sample code is licensed under the Eclipse Public License, version 1.0.
See http://www.eclipse.org/legal/epl-v10.html for details.