FFDC processing overview
Instead of explicitly instrumenting catch blocks by calling FFDC directly, either
manually or by using a tool, you can write a simple aspect using the AspectJ
language, which encapsulates the FFDC policy for your code.
The
FFDCSupport
aspect is abstract. Like an abstract class,
FFDCSupport
cannot be
instantiated and defers some of its implementation to a sub-aspect. It follows the
standard library aspect pattern of declaring an abstract pointcut for which you
must declare a concrete implementation. This concrete implementation of the
pointcut can use the simple AspectJ scoping pointcut designators (PCD) such as
within()
and
withincode()
to determine the packages, classes and methods to be
included in the FFDC policy.
FFDC programming examples
The following examples assume a certain familiarity with the AspectJ language
(see http://eclipse.org/aspectj/). In most cases a user of the FFDCSupport aspect
will require knowledge of only a small subset of the AspectJ syntax. In particular
they should know how to define a concrete aspect by extending an abstract one
and how to declare a concrete pointcut typically using simple scoping primitive
pointcuts.
Figure 1 illustrates the simple aspect
Example_1
that adds FFDC to all classes in
the com.foo package. The example illustrates the following processing:
1.
On line 1, the
FFDCSupport
aspect is imported
2.
On line 3, the
FFDCSupport
aspect is extended and made concrete in a similar
way to a Java class.
3.
On line 5, the inherited abstract pointcut
ffdcScope()
\ is made concrete.
This is done using the
within()
pointcut designator (PCD) and “*” wildcard
that results in FFDC for all classes in the com.foo package. For example,
com.foo.Bar.
import com.ibm.websphere.ffdc.FFDCSupport;
public aspect Example_1 extends FFDCSupport {
protected pointcut ffdcScope () :
within(com.foo.*);
}
Figure 7. Add FFDC to the com.foo package
import com.ibm.websphere.ffdc.FFDCSupport;
public aspect Example_2 extends FFDCSupport {
protected pointcut ffdcScope () :
within(com.foo..*);
}
Figure 2 illustrates aspect
Example_2
, which differs from
Example_1
. Notice line 13, where the wildcard includes
″
double dots
″
(..) in the within() PCD, which means the includes all classes in the com.foo package and sub-packages.
For example, com.foo.impl.Bar.
Figure 8. Add FFDC to com.foo package and all sub-packages
190
WebSphere Adapters: WebSphere Adapter Toolkit User Guide
Summary of Contents for WebSphere Adapters
Page 2: ......
Page 6: ...iv WebSphere Adapters WebSphere Adapter Toolkit User Guide...
Page 220: ...214 WebSphere Adapters WebSphere Adapter Toolkit User Guide...
Page 224: ...218 WebSphere Adapters WebSphere Adapter Toolkit User Guide...
Page 225: ......
Page 226: ...Printed in USA...