/[projects]/dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/db/LogPersistance.java
ViewVC logotype

Contents of /dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/db/LogPersistance.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2541 - (show annotations) (download)
Mon May 11 15:24:09 2015 UTC (9 years ago) by torben
File size: 1219 byte(s)
More explicit error logging
1 package dk.daoas.daoadresseservice.db;
2
3 import java.sql.SQLException;
4 import java.util.concurrent.ExecutorService;
5 import java.util.concurrent.Executors;
6
7 import dk.daoas.daoadresseservice.beans.SearchResult;
8
9 public class LogPersistance {
10
11 ExecutorService threadPool = Executors.newFixedThreadPool(1);
12
13 static class LogPersistanceWorker implements Runnable {
14 String brugerid;
15 String postnr;
16 String adresse;
17 SearchResult result;
18
19 public LogPersistanceWorker(String brugerid, String postnr, String adresse, SearchResult result) {
20 this.brugerid = brugerid;
21 this.postnr = postnr;
22 this.adresse = adresse;
23 this.result = result;
24 }
25
26 @Override
27 public void run() {
28 try {
29 DatabaseLayer.saveRequestLog(brugerid,postnr,adresse,result);
30 } catch (SQLException e) {
31 System.out.println("Error saving log entry " + e.getMessage() + ". Postnr=" + postnr + ". Adresse=" + adresse);
32 }
33 }
34 }
35
36 public void saveRequestLog(String brugerid, String postnr, String adresse, SearchResult result) {
37 threadPool.execute( new LogPersistanceWorker(brugerid,postnr,adresse,result) );
38 }
39
40
41 public void shutdown() {
42 threadPool.shutdown();
43 }
44 }

  ViewVC Help
Powered by ViewVC 1.1.20