[jboss-cvs] JBossAS SVN: r66975 - projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/src/main/java/org/jboss/example/aspect.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 12 14:56:15 EST 2007


Author: newtonm
Date: 2007-11-12 14:56:15 -0500 (Mon, 12 Nov 2007)
New Revision: 66975

Modified:
   projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/src/main/java/org/jboss/example/aspect/AuditAspect.java
Log:
Improved creation of auditLog filename.

Modified: projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/src/main/java/org/jboss/example/aspect/AuditAspect.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/src/main/java/org/jboss/example/aspect/AuditAspect.java	2007-11-12 19:49:33 UTC (rev 66974)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/gettingStarted/auditAspect/src/main/java/org/jboss/example/aspect/AuditAspect.java	2007-11-12 19:56:15 UTC (rev 66975)
@@ -3,6 +3,7 @@
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
 
 import org.jboss.aop.joinpoint.ConstructorInvocation;
@@ -30,7 +31,11 @@
 	}
 	
 	public Object audit(ConstructorInvocation inv) throws Throwable {
-		File auditLog = new File(logDir + "/" + createFilename());
+		SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyy-kkmmss");
+		Calendar now = Calendar.getInstance();
+		String filename = "auditLog-" + formatter.format(now.getTime());
+
+		File auditLog = new File(logDir + "/" + filename);
 		auditLog.createNewFile();
 		out = new BufferedWriter(new FileWriter(auditLog));
 		return inv.invokeNext();		
@@ -62,16 +67,4 @@
 		}
 		return retVal;
 	}
-	
-	private String createFilename() {
-		Calendar now = Calendar.getInstance();
-		String year = Integer.toString(now.get(Calendar.YEAR));
-		String month = Integer.toString(now.get(Calendar.MONTH));
-		String day = Integer.toString(now.get(Calendar.DAY_OF_MONTH));
-		String hour = Integer.toString(now.get(Calendar.HOUR_OF_DAY));
-		String min = Integer.toString(now.get(Calendar.MINUTE));
-		String sec = Integer.toString(now.get(Calendar.SECOND));
-		
-		return "auditLog-" + day + month + year + "-" + hour + min + sec;			
-	}
 }




More information about the jboss-cvs-commits mailing list