0

I have an @InterceptorBinding with member value like this:

@Target({ElementType.METHOD, ElementType.TYPE})
@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
public @interface Transactional {
    boolean value() default true;
}

and an @Interceptor :

@Interceptor
@Transactional
public class TransactionInterceptor {

    @Inject
    private EntityManager em;

    @AroundInvoke
    public Object runInTransaction(InvocationContext invocationContext) throws Exception {

    // here i want get the @Transactional's member value

I'm using it like this:

@Transactional(true)
    public String insertDatatypes(String s1) {

        //some logic
        ...

My question is :

Is it possible to get the value true used in @Transactional(true) in my TransactionInterceptor class ?

Thanks for your help

Makoto
  • 104,088
  • 27
  • 192
  • 230
Hen
  • 253
  • 1
  • 2
  • 16

1 Answers1

0

I could get the member value like this

boolean trans = invocationContext.getMethod().getAnnotation(Transactional.class).value();
Hen
  • 253
  • 1
  • 2
  • 16