是否可以在没有 AroundTimeout 注释的情况下拦截超时方法?

Is it possible to intercept a timeout method without AroundTimeout annotation?

我公司目前使用的是不包含 AroundTimeOut class 的旧 javaee jar (5.2.0)。 jar 不能更改,因为它会发生一些重大影响。我的经理让我拦截一个超时方法。你知道是否有办法解决这个问题?

这是我使用的方法:

@Timeout
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    @Interceptors(CorrelationIdInterceptor.class)
    public void handleTimeout(Timer timer) {

拦截器:

public class CorrelationIdInterceptor {


    private static final String CORRELATION_ID = "CORRELATION_ID";
    private static final String GET_CORRELATION_ID = "getCorrelationId";

    private static final Logger LOGGER = 
    Logger.getLogger(CorrelationIdInterceptor.class);


    @AroundInvoke
    public Object log(final InvocationContext ic) throws Exception {

        String webServiceMethodName = ic.getMethod().getName();


        if(webServiceMethodName.equalsIgnoreCase("handleTimeout")){
            webServiceMethodName="SIBOI"+":"+ webServiceMethodName;
        }

尝试在你的ejb中加入-jar.xml

    <assembly-descriptor>
      <interceptor-binding>
         <ejb-name>full.path.to.your.ejb</ejb-name>
         <interceptor-class>full.path.to.your.interceptor</interceptor-class>
         <method-name>method.in.your.ejb</method-name>
      </interceptor-binding>
   </assembly-descriptor>