Home » Tag Archives: Annotations

Tag Archives: Annotations

Make agents, not frameworks

java-logo

Ever since their introduction, Java annotations have become an integral part of the APIs of larger application frameworks. Good examples for such APIs are those of Spring or Hibernate where adding a few lines of annotation code implements quite complex program logic. And while one can argue about the drawbacks of these particular APIs, most developers would agree that this ...

Read More »

How To Process Java Annotations

java-logo

One of the cool new features of Java 8 is the support for lambda expressions. Lambda expressions lean heavily on the FunctionalInterface annotation. In this post, we’ll look at annotations and how to process them so you can implement your own cool features. Annotations Annotations were added in Java 5. The Java language comes with some predefined annotations, but you ...

Read More »

Java Annotations Tutorial – The ULTIMATE Guide (PDF Download)

java-logo

EDITORIAL NOTE: Annotations in Java are a major feature and every Java developer should know how to utilize them. We have provided an abundance of tutorials here at Java Code Geeks, like Creating Your Own Java Annotations, Java Annotations Tutorial with Custom Annotation and Java Annotations: Explored & Explained. We also featured articles on annotations used in various libraries, including ...

Read More »

Processing Java Annotations Using Reflection

java-logo

In my previous article covering Java Annotations, I outlined a recent use case and provided you with some examples of custom annotations and how they might be used. In this article, I’m going to take that a step further and give you a few examples of custom annotations and how you would process these custom annotations using the Java Reflection API. ...

Read More »

Creating Your Own Java Annotations

java-logo

If you’ve been programming in Java and using any one of the popular frameworks like Spring and Hibernate, you should be very familiar with using annotations. When working with an existing framework, its annotations typically suffice. But, have you ever found a need to create your own annotations? Not too long ago, I found a reason to create my own annotations for a ...

Read More »

Use Java annotation deprecated the right way

java-logo

There is hardly anything more infuriating that seeing a method @Deprecated without a proper documentation. I feel lost. Should I still use the method? Probably that is not the intention of the developer, that is why he/she added the deprecation annotation. Should I use something else? So…. What are the rules using @Deprecated? Rule #1: do Javadoc how not to ...

Read More »

Java Annotations Tutorial with Custom Annotation

java-logo

Java Annotations provide information about the code and they have no direct effect on the code they annotate. In this tutorial, we will learn about Java annotations, how to write custom annotation, annotations usage and how to parse annotations using reflection. Annotations are introduced in Java 1.5 and now it’s heavily used in Java frameworks like Hibernate, Jersey, Spring. Annotation ...

Read More »

Java Annotations – Retention

java-logo

Consider a Java annotation: public @interface AnAnnotaton { } A class with this annotation applied on it: @AnAnnotaton class AnAnnotatedClass{ } And a test which checks if this annotation is present on a class: import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import java.lang.annotation.Annotation; import org.junit.Test; public class AnAnnotationTest { @Test public void testAnAnnotation() throws Exception { AnAnnotatedClass anAnnotatedClass = new AnAnnotatedClass(); ...

Read More »

Java Annotations: Explored & Explained

java-logo

One of the many wonderful features of Java 5 SE is the introduction of the Annotations construct. Annotations are tags that we can insert into our program source code for some tool to process it and make sense out of it. Annotations processing tools generally use Reflection API (of Java 5 SE) to process the code at source level on ...

Read More »

Make your Spring Security @Secured annotations more DRY

spring-interview-questions-answers

Recently a user on the Grails User mailing list wanted to know how to reduce repetition when defining @Secured annotations. The rules for specifying attributes in Java annotations are pretty restrictive, so I couldn’t see a direct way to do what he was asking. Using Groovy doesn’t really help here since for the most part annotations in a Groovy class ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.