1
1
/*
2
- * Copyright 2014 Janith Bandara, This source is a part of Audit4j -
3
- * An open-source audit platform for Enterprise java platform .
2
+ * Copyright (c) 2014-2015 Janith Bandara, This source is a part of
3
+ * Audit4j - An open source auditing framework .
4
4
* http://audit4j.org
5
5
*
6
6
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -66,6 +66,8 @@ public class DatabaseAuditHandler extends Handler {
66
66
67
67
/** The factory. */
68
68
private ConnectionFactory factory ;
69
+
70
+ private AuditLogDao logDao ;
69
71
70
72
/**
71
73
* Initialize database handler.
@@ -80,10 +82,10 @@ public void init() throws InitializationException {
80
82
db_driver = server .getDriver ();
81
83
db_url = server .getNetworkProtocol () + "://localhost/audit4j" ;
82
84
if (db_user == null ) {
83
- db_user = "audit4jdbuser" ;
85
+ db_user = Utils . EMBEDED_DB_USER ;
84
86
}
85
87
if (db_password == null ) {
86
- db_password = "audit4jdbpassword" ;
88
+ db_password = Utils . EMBEDED_DB_PASSWORD ;
87
89
}
88
90
server .setUname (db_user );
89
91
server .setPassword (db_password );
@@ -107,9 +109,9 @@ public void init() throws InitializationException {
107
109
108
110
factory .init ();
109
111
110
- AuditLogDao dao = AuditLogDaoImpl .getInstance ();
112
+ logDao = AuditLogDaoImpl .getInstance ();
111
113
try {
112
- dao .createAuditTableIFNotExist ();
114
+ logDao .createAuditTableIFNotExist ();
113
115
} catch (SQLException e ) {
114
116
throw new InitializationException ("Could not create the audit table structure." , e );
115
117
}
@@ -122,9 +124,8 @@ public void init() throws InitializationException {
122
124
*/
123
125
@ Override
124
126
public void handle () throws HandlerException {
125
- AuditLogDao dao = AuditLogDaoImpl .getInstance ();
126
127
try {
127
- dao .writeEvent (getAuditEvent ());
128
+ logDao .writeEvent (getAuditEvent ());
128
129
} catch (SQLException e ) {
129
130
throw new HandlerException ("SQL exception occured while writing the event" , DatabaseAuditHandler .class , e );
130
131
}
0 commit comments