KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > handlers > DebugHandler


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.handlers ;
18
19 import org.apache.axis.AxisFault;
20 import org.apache.axis.Constants;
21 import org.apache.axis.Message;
22 import org.apache.axis.MessageContext;
23 import org.apache.axis.components.logger.LogFactory;
24 import org.apache.axis.message.SOAPEnvelope;
25 import org.apache.axis.message.SOAPHeaderElement;
26 import org.apache.axis.utils.Messages;
27 import org.apache.commons.logging.Log;
28
29
30 /**
31  *
32  * @author Doug Davis (dug@us.ibm.com)
33  */

34 public class DebugHandler extends BasicHandler {
35     protected static Log log =
36         LogFactory.getLog(DebugHandler.class.getName());
37
38     public static final String JavaDoc NS_URI_DEBUG = "http://xml.apache.org/axis/debug";
39     
40     public void invoke(MessageContext msgContext) throws AxisFault {
41         log.debug("Enter: DebugHandler::invoke");
42         try {
43             Message msg = msgContext.getRequestMessage();
44
45             SOAPEnvelope message = (SOAPEnvelope)msg.getSOAPEnvelope();
46             SOAPHeaderElement header = message.
47                 getHeaderByName(NS_URI_DEBUG, "Debug");
48
49             if (header != null) {
50                 Integer JavaDoc i = ((Integer JavaDoc)header
51                              .getValueAsType(Constants.XSD_INT));
52                 if (i == null)
53                     throw new AxisFault(Messages.getMessage("cantConvert03"));
54
55                 int debugVal = i.intValue();
56                 log.debug(Messages.getMessage("debugLevel00", "" + debugVal) );
57                 //Debug.setDebugLevel(debugVal);
58
header.setProcessed(true);
59             }
60         }
61         catch( Exception JavaDoc e ) {
62             log.error( Messages.getMessage("exception00"), e );
63             throw AxisFault.makeFault(e);
64         }
65         log.debug("Exit: DebugHandler::invoke");
66     }
67
68     public void onFault(MessageContext msgContext) {
69         log.debug("Enter: DebugHandler::onFault");
70         log.debug("Exit: DebugHandler::onFault");
71     }
72
73 };
74
Popular Tags