IBM WebSphere Adapters User Manual page 197

Version 6 release 2
Table of Contents

Advertisement

import com.ibm.websphere.ffdc.FFDCSupport;
public aspect Example_3 extends FFDCSupport {
protected pointcut ffdcScope () :
within(com.foo.*)
&& !within(com.foo.Goo);
}
In Figure 3 aspect Example_3 has the same effect as Example_1 except it excludes FFDC for class com.foo.Goo by
using the && and ! operators to form a pointcut expression.
Figure 9. Add FFDC to all classes in the com.foo package excluding com.foo.Goo
import com.ibm.websphere.ffdc.FFDCSupport;
public aspect Example_3 extends FFDCSupport {
protected pointcut ffdcScope () :
within(com.foo.*)
&& !withincode(* com.foo.Goo.aMethod(..));
}
In Figure 4, aspect Example_4 is also similar to Example_1, however FFDC is excluded from a particular method on
line 30 using the withincode() PCD.
Figure 10. Add FFDC to the com.foo package but exclude aMethod
import com.ibm.websphere.ffdc.FFDCSupport;
public aspect Example_4 extends FFDCSupport {
protected pointcut ffdcScope () :
within(com.foo.*)
&& !args(ClassNotFoundException);
}
In Figure 5 aspect Example_5 illustrates how to account for a programming by exception, where certain exceptions are
not considered to be a failure and should not be reported. In the example, the handling of ClassNotFoundException
will not be reported to FFDC. The args() PCD on line 39 selects a join points based on contextual information in this
case the exception passed to the handler join point.
Figure 11. Add FFDC to the com.foo package but exclude catch blocks for ClassNotFoundException handling
If you use the FFDCSupport aspect, you can ensure a consistent FFDC policy for
your application by adding declare warning or error advice to your aspects While this
capability is not explicitly provided by the FFDCSupport aspect, you can leverage
the use of AspectJ and follow a standard pattern of enforcing a policy
implemented using an aspect with compiler warnings or errors.
In Figure 6, aspect Example_6 illustrates how to prevent direct use of the FFDC API
or undesired dumping of exception messages and stack traces to the console. The
declare warning statements on lines 51 and 57 instruct the AspectJ compiler to
issue warnings during weaving if join points are matched by the accompanying
pointcuts on lines 48 and 54 respectively.
The statements are only evaluated during compilation and have no impact on the
runtime.
WebSphere Adapter development overview
191

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Websphere adapter toolkit

Table of Contents