Does somebody know how to create a "shortcut" for a couple of annotations in CDI?
You know, something called meta-annotations in Spring world:
@Singleton
@Transactional(value = TxType.REQUIRED, dontRollbackOn = SomeException.class)
@SomeOtherAnnotations
public @interface MyService {
// ...
}
@MyService
public class OrderService {
// ...
}
The goal is obvious: just to don't have to specify the same setup in every class. As far as I know, it's not possible in CDI, but does somebody know if EJB 3.2 supports something similar?
CDI has the concept of stereotypes that you can use in your example:
@Singleton
@Transactional(value = TxType.REQUIRED, dontRollbackOn = SomeException.class)
@SomeOtherAnnotations
@Stereotype
@Target(TYPE)
@Retention(RUNTIME)
public @interface MyService {}