简体   繁体   中英

Interceptor is not invoking and not visible (in logs, during deployments nothing see)

I have a classes:

import javax.inject.Inject;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;

public class AccessReportInterceptor {
    private Logger log = Logger.getLogger(AccessReportInterceptor.class);    

    @Inject
    private AccessReportManager accessReportManager;

    @AroundInvoke
    public Object intercept(InvocationContext context) throws Exception {
        log.info("invoked");
        return context.proceed();
    }
}

@Stateless
@Remote(ActionTypeHandlerRemote.class)
public class ActionTypeHandler implements ActionTypeHandlerRemote{
 @EJB protected DataManager dataManager;
 @Interceptors({AccessReportInterceptor.class})
    private void persistNewUser(User newUser){
        logger.info("Persisting new user: " + newUser.getLogin());
        logger.info("For : " + newUser.getName());
        newUser.setCreateTime(new Date());
        dataManager.persist(newUser);
    }

    @Interceptors({AccessReportInterceptor.class})
    private void mergeUser(User user){
        logger.info("Merging user with id: " + user.getLogin());
        user.setCreateTime(new Date());
        dataManager.merge(user);
    }
}

And when i invoked method persistNewUser or mergeUser then should (before invoke this methods) be started interceptor.

It seems that it ignores the Interceptor.

Why this not working ? What I am doing wrong?

请公开您的方法,私有方法将不会被拦截。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM