は最後に、前の回答と私の個人的な研究に基づいて、私はfolowingソリューションを保持しました。
public class FaultBarrierInterceptor {
@AroundInvoke
public Object intercept(final InvocationContext invocationContext) throws Exception {
try {
return invocationContext.proceed();
} catch (final RuntimeException e) {
final Logger logger = Logger.getLogger(invocationContext.getMethod().getDeclaringClass());
logger.error("A fault occured during service invocation:" +
"\n-METHOD: " + invocationContext.getMethod() +
"\n-PARAMS: " + Arrays.toString(invocationContext.getParameters()), e);
throw new TechnicalException();
}
}}
スロー技術的例外はないEJBExceptionを拡張し、原因のRuntimeException公開しません:私はすべてにこのインターセプタを使用
public class TechnicalException extends EJBException {}
を
私は、サーバーの障害を管理するための専用のインターセプターを作成しました公共サービス:
@Stateless
@Interceptors({FaultBarrierInterceptor.class})
public class ShoppingCardServicesBean implements ShoppingCardServices { ...
これは実装ですFault Barrier patternのn。
実行時例外はすべてキャッチされ、ログに記録され、TechnicalExceptionを使用して(内部の詳細なしで)クライアントに障害が通知されます。チェックされた例外は無視されます。
RuntimeException処理は集中管理され、ビジネスメソッドから分離されています。