Announcement Announcement Module
Collapse
No announcement yet.
Can a custom shortcut annotation pass values to a "parent" annotation? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can a custom shortcut annotation pass values to a "parent" annotation?

    I'd like to implement a custom shortcut annotation (as described in the documentation), that passes a parameter ("seconds") to a "parent" annotation ("@Transactional").

    Code:
    // TransactionTimeout.java
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.METHOD)
    @Transactional(timeout=???) // is it possible to somehow get the value of seconds() in there?
    public @interface TransactionTimeout {
        int seconds() default 10;
    }
    
    // TransactionalService.java
    public class TransactionalService {
     
       @TransactionTimeout(seconds=5)
       public void setSomething(String name) { ... }
     
       @TransactionTimeout(seconds=20)
       public void doSomething() { ... }
    }
    Is this possible at all?

    Thanks,
    Dan
Working...
X