Java Annotations
I presented a talk on Java Annotations to the Columbia, Maryland Java Users Group on 1/19/2010.
This is a very deep dive into
- Annotation Concepts
- Creating annotation processors
- Using annotations at compile time and runtime
- Generating code from annotations
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!
Videos
Part 1 - Introduction
Introduction to Java Annotations (what they are and why you would use them).
Java Annotations 1 - Introduction from Scott Stanchfield on Vimeo.
## Part 2 - Classfile AnnotationsCreating annotations that are kept in the generated class files but not loaded in the VM at runtime.
Java Annotations 2 - Classfile Annotations from Scott Stanchfield on Vimeo.
## Part 3 - Runtime Annotations 1Example of annotating methods with a custom @Test annotation to run in a test runner similar to junit.
Java Annotations 3 - Runtime Annotations - Unit Tester from Scott Stanchfield on Vimeo.
Part 4 - Runtime Annotations 2
Example of annotating methods to be used as actions that are triggered from buttons in a user interface.
Java Annotations 4 - Runtime Annotations - UI Action Setup from Scott Stanchfield on Vimeo.
Part 5 - Code Generation 1
Writing an annotation processor that runs at compile time to generate an RMI interface from a standard interface.
Java Annotations 5 - Code Generation - RMI interface generation from Scott Stanchfield on Vimeo.
Part 6 - Code Generation 2
Using an annotation processor to generate JavaBean boilerplate code.
Java Annotations 6 - Code generation - JavaBean boilerplate generation from Scott Stanchfield on Vimeo.
Video License
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.
Sample Code
Here is the sample code I wrote during the lecture. Note that this code is not intended for production use.
Software License
All sample code is licensed under the Eclipse Public License, version 1.0.
See http://www.eclipse.org/legal/epl-v10.html for details.
Duke, the Java mascot, provided by Sun Microsystems under the New BSD license.