Thread:
 Annotated extension (JDK5) 
 RBramley   17 Oct 2006, 04:13 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: RBramley (17 Oct 2006, 04:13) Replies: 0, Views: 24171
Subject: Annotated extension (JDK5)
The audit interceptor was a great start (thanks Rob) - but it didn't
quite meet all of my needs. Some existing entities have an updated_date
- I don't want an audit record for those!

I defined an annotation DoNotAudit:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface DoNotAudit { }

and then modified the logChanges method to add (after
transient/static/final Field check): 

	          // ignore annotated fields
	          if(fields[ii].isAnnotationPresent(DoNotAudit.class)) 
	        	  continue fieldIteration;


Then classes that implement Auditable can use the annotation to indicate
fields that should not be audited, e.g.
	@DoNotAudit private Date updatedDate;


Hope this helps!

Robin
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]