1 16 17 package org.apache.axis.handlers; 18 19 import org.apache.axis.AxisFault; 20 import org.apache.axis.Message; 21 import org.apache.axis.MessageContext; 22 import org.apache.axis.SOAPPart; 23 import org.apache.axis.monitor.SOAPMonitorConstants; 24 import org.apache.axis.monitor.SOAPMonitorService; 25 26 32 33 public class SOAPMonitorHandler extends BasicHandler { 34 35 private static long next_message_id = 1; 36 37 40 public SOAPMonitorHandler() { 41 super(); 42 } 43 44 47 public void invoke(MessageContext messageContext) throws AxisFault { 48 String target = messageContext.getTargetService(); 49 if (target == null) { 51 target = ""; 52 } 53 Long id; 55 Integer type; 56 Message message; 57 if (!messageContext.getPastPivot()) { 58 id = assignMessageId(messageContext); 59 type = new Integer (SOAPMonitorConstants.SOAP_MONITOR_REQUEST); 60 message = messageContext.getRequestMessage(); 61 } else { 62 id = getMessageId(messageContext); 63 type = new Integer (SOAPMonitorConstants.SOAP_MONITOR_RESPONSE); 64 message = messageContext.getResponseMessage(); 65 } 66 String soap = null; 68 if (message != null) { 69 soap = ((SOAPPart)message.getSOAPPart()).getAsString(); 70 } 71 if ((id != null) && (soap != null)) { 74 SOAPMonitorService.publishMessage(id,type,target,soap); 75 } 76 } 77 78 81 private Long assignMessageId(MessageContext messageContext) { 82 Long id = null; 83 synchronized(SOAPMonitorConstants.SOAP_MONITOR_ID) { 84 id = new Long (next_message_id); 85 next_message_id++; 86 } 87 messageContext.setProperty(SOAPMonitorConstants.SOAP_MONITOR_ID, id); 88 return id; 89 } 90 91 94 private Long getMessageId(MessageContext messageContext) { 95 Long id = null; 96 id = (Long ) messageContext.getProperty(SOAPMonitorConstants.SOAP_MONITOR_ID); 97 return id; 98 } 99 } 100 | Popular Tags |