KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > handlers > common > FileLoggingHandler


1 /*
2  * Copyright (c) 2005 Sun Microsystems, Inc.
3  * All rights reserved.
4  */

5 package demo.handlers.common;
6
7 import java.io.FileOutputStream JavaDoc;
8 import java.io.IOException JavaDoc;
9 import java.io.PrintStream JavaDoc;
10
11 import java.util.Map JavaDoc;
12 import java.util.Set JavaDoc;
13
14 import javax.xml.namespace.QName JavaDoc;
15 import javax.xml.ws.handler.soap.SOAPMessageContext;
16
17 /*
18  * This simple SOAPHandler will output the contents of incoming
19  * and outgoing messages into a file.
20  */

21 public class FileLoggingHandler extends LoggingHandler {
22
23     public FileLoggingHandler() {
24         try {
25             setLogStream(new PrintStream JavaDoc(new FileOutputStream JavaDoc("demo.log")));
26         } catch (IOException JavaDoc ex) {
27             System.err.println("Could not open log file demo.log");
28         }
29     }
30
31     public void init(Map JavaDoc c) {
32         System.out.println("FileLoggingHandler : init() Called....");
33     }
34
35     public Set JavaDoc<QName JavaDoc> getHeaders() {
36         return null;
37     }
38
39     public boolean handleMessage(SOAPMessageContext smc) {
40         System.out.println("FileLoggingHandler : handleMessage Called....");
41         logToSystemOut(smc);
42         return true;
43     }
44
45     public boolean handleFault(SOAPMessageContext smc) {
46         System.out.println("FileLoggingHandler : handleFault Called....");
47         logToSystemOut(smc);
48         return true;
49     }
50 }
51
Popular Tags