gpt4 book ai didi

java - 是否可以在没有 RoundTimeout 注解的情况下拦截超时方法?

转载 作者:太空宇宙 更新时间:2023-11-04 10:01:45 24 4
gpt4 key购买 nike

我的公司当前正在使用旧的 javaee jar (5.2.0),它不包含 aroundTimeOut 类。 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>

关于java - 是否可以在没有 RoundTimeout 注解的情况下拦截超时方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53372949/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com