Java Reference
In-Depth Information
public void setAuditOn(boolean auditOn) {
this.auditOn = auditOn;
A lot is going on in this class. This class implements the Spring AOP class
MethodInterceptor to provide around advice. The key here is the invoke method. This
method is called before and after the invocation of the target business method that you
want to audit. The audit trail operation happens in the finally block. The property
auditOn can be used to globally stop the audit trail.
If the audit trail flag is set to true , then an event code is determined by the invoke
method. Here, for simplicity, I have assumed that coarse-grained session facade method
name as the event code. This event code should be unique and used to look up an audit
rule from the audit rule list. If an audit rule is found for this event code and this rule is
not disabled, then the rule definition is consulted to see whether it is applicable to the
current application service method. Finally, the data in the audit event is traced by an
audit logger. Listing 6-18 shows how this class is wired in the Spring configuration.
Listing 6-18. audit-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
xsi:schemaLocation=" ">
<!--advice -->
<bean name="auditAdvice"
<property name="rules" >
<bean class="" >
<property name="ruleMap" >
class="" >
<property name="ruleDefinition" value="com.apress å" />
<property name="applyRule" value="true"></property>
Search WWH ::

Custom Search