📄 exceptionhandlingintegrator.aj
字号:
package exception;
/**
* This example subaspect of the ExceptionHandling aspect
* demonstrates the two methods that must be implemented to
* integrate the operation of the aspect into a particular
* application.
*
* @author Barry Ruzek
*/
public aspect ExceptionHandlingIntegrator extends ExceptionHandling {
/**
* Since applications have different structures and
* requirements, the ExceptionHandling aspect calls this
* method to find out if an object that is about to handle a
* FaultException is a designated Fault Barrier or not. This
* example uses a simple test that allows the example to
* compile without errors in your environment. It checks the
* name of the class against the name of the application
* fault barrier class. Your implementation will probably be
* more sophisticated, perhaps using an "instanceof" test
* against the Class object for the fault barrier. Or maybe
* your application needs more than one fault barrier
* because of its thread model, etc. This is the place to
* test for them.
*
* @param exceptionHandler
* The object that contains the catch block that
* is about to handle a FaultException.
* @return True if the exceptionHandler is a Fault Barrier
* and should be allowed to catch the
* FaultException, otherwise, false.
*/
boolean isFaultBarrier(Object exceptionHandler) {
return exceptionHandler.getClass().getName().equals(
"your.faultbarrier.class.name");
}
/**
* Applications record diagnostics in different ways, so
* this method is needed to integrate the ExceptionHandling
* aspect with the application's particular way of
* recording. The ExceptionHandling aspect calls this method
* when a FaultException is thrown.
* <p>
* This example sends the diagnostic to the system console
* (mainly to ensure that the example will compile without
* errors in your environment). You will most likely want to
* replace that with a call to your logging subsystem or
* something similar for your application.
*
* @param diagnostics
* The multi-line string produced by the
* ExceptionHandling aspect, containing the
* diagnostic information for the fault.
*/
void recordFaultDiagnostics(String diagnostics) {
System.out.println(diagnostics);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -