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=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd ">
<!--advice -->
<bean name="auditAdvice"
class="com.apress.einsure.security.audit.AuditAdviseInterceptor">
<property name="rules" >
<bean class="com.apress.einsure.security.audit.AuditRules" >
<property name="ruleMap" >
<map>
<entry>
<key><value>underwriteNewPolicy</value></key>
<bean
class="com.apress.einsure.security.audit.AuditRule" >
<property name="ruleDefinition" value="com.apress å
.einsure.business.impl.UnderwritingApplicationService.underwriteNewPolicy" />
<property name="applyRule" value="true"></property>
 
Search WWH ::




Custom Search