Author: alessio.soldano(a)jboss.com
Date: 2007-12-11 07:36:37 -0500 (Tue, 11 Dec 2007)
New Revision: 5253
Modified:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/invocation/RecordingServerHandler.java
Log:
Code cleanup
Modified:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/invocation/RecordingServerHandler.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/invocation/RecordingServerHandler.java 2007-12-11
12:36:13 UTC (rev 5252)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/invocation/RecordingServerHandler.java 2007-12-11
12:36:37 UTC (rev 5253)
@@ -28,6 +28,7 @@
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
+import javax.xml.namespace.QName;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.ws.handler.MessageContext;
@@ -44,13 +45,20 @@
import org.jboss.wsf.test.GenericSOAPHandler;
/**
+ * This handler is responsible for collecting the information about the
+ * messages being exchanged and recording them on the server side. This
+ * is performed delegating to the RecordProcessors installed into the
+ * current endpoint.
*
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
*/
public class RecordingServerHandler extends GenericSOAPHandler
{
// provide logging
private static Logger log = Logger.getLogger(RecordingServerHandler.class);
-
+
+ @SuppressWarnings("unchecked")
protected boolean handleInbound(MessageContext ctx)
{
log.info("*** INBOUND ***");
@@ -60,6 +68,7 @@
Long groupID = RecordFactory.newGroupID();
RecordGroupAssociation.pushGroupID(groupID);//check, perhaps we should try
peeking before pushing...
Record record = RecordFactory.newRecord(groupID);
+ record = RecordFactory.newRecord(groupID);
record.setDate(new Date());
HttpServletRequest httpServletRequest =
(HttpServletRequest)ctx.get(MessageContext.SERVLET_REQUEST);
if (httpServletRequest != null)
@@ -76,7 +85,7 @@
}
record.setHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_REQUEST_HEADERS)));
record.setMessageType(MessageType.INBOUND);
- record.setOperation((String)ctx.get(MessageContext.WSDL_OPERATION));
+ record.setOperation((QName)ctx.get(MessageContext.WSDL_OPERATION));
SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
try
{
@@ -91,64 +100,11 @@
log.error("Cannot trace SOAPMessage", ex);
}
endpoint.processRecord(record);
-
-// log.info("WSDL_OPERATION:
"+ctx.get(MessageContext.WSDL_OPERATION));
-// log.info("WSDL_PORT: "+ctx.get(MessageContext.WSDL_PORT));
-// log.info("WSDL_SERVICE: "+ctx.get(MessageContext.WSDL_SERVICE));
-// log.info("PATH_INFO: "+ctx.get(MessageContext.PATH_INFO));
-// log.info("QUERY_STRING: "+ctx.get(MessageContext.QUERY_STRING));
-// log.info("HTTP_REQUEST_METHOD:
"+ctx.get(MessageContext.HTTP_REQUEST_METHOD));
-// log.info("HTTP_RESPONSE_CODE:
"+ctx.get(MessageContext.HTTP_RESPONSE_CODE));
-// log.info("HTTP_REQUEST_HEADERS:
"+this.printHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_REQUEST_HEADERS))));
-// log.info("HTTP_RESPONSE_HEADERS:
"+this.printHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_RESPONSE_HEADERS))));
-// log.info("WSDL_INTERFACE:
"+ctx.get(MessageContext.WSDL_INTERFACE));
-// log.info("SERVLET_REQUEST:
"+(HttpServletRequest)ctx.get(MessageContext.SERVLET_REQUEST));
-// if ((HttpServletRequest)ctx.get(MessageContext.SERVLET_REQUEST)!=null)
-// {
-// try {
-// log.info("DESTINATION HOST: "+new
URL(((HttpServletRequest)ctx.get(MessageContext.SERVLET_REQUEST)).getRequestURL().toString()).getHost());
-// } catch (Exception e) {e.printStackTrace();}
-// log.info("SOURCE HOST:
"+((HttpServletRequest)ctx.get(MessageContext.SERVLET_REQUEST)).getRemoteHost());
-// }
-//
-//
-// try
-// {
-// SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
-// if (soapEnv != null)
-// {
-// String envStr = DOMWriter.printNode(soapEnv, true);
-// log.info("ENVELOPE: "+envStr);
-// }
-// }
-// catch (SOAPException ex)
-// {
-// log.error("Cannot trace SOAPMessage", ex);
-// }
}
return true;
}
- private String printHeaders(Map<String,List<String>> headers)
- {
- StringBuffer sb = new StringBuffer();
- if (headers!=null)
- {
- for (String key : headers.keySet())
- {
- sb.append(key);
- sb.append(": ");
- for (String h : headers.get(key))
- {
- sb.append(h);
- sb.append("; ");
- }
- sb.append("\n");
- }
- }
- return sb.toString();
- }
-
+ @SuppressWarnings("unchecked")
protected boolean handleOutbound(MessageContext ctx)
{
Endpoint endpoint = EndpointAssociation.getEndpoint();
@@ -160,7 +116,7 @@
record.setDate(new Date());
record.setHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_RESPONSE_HEADERS)));
record.setMessageType(MessageType.OUTBOUND);
- record.setOperation((String)ctx.get(MessageContext.WSDL_OPERATION));
+ record.setOperation((QName)ctx.get(MessageContext.WSDL_OPERATION));
SOAPMessageContext soapCtx = (SOAPMessageContext)ctx;
try
{
@@ -175,39 +131,13 @@
log.error("Cannot trace SOAPMessage", ex);
}
endpoint.processRecord(record);
-
-
-// log.info("WSDL_OPERATION:
"+ctx.get(MessageContext.WSDL_OPERATION));
-// log.info("WSDL_PORT: "+ctx.get(MessageContext.WSDL_PORT));
-// log.info("WSDL_SERVICE: "+ctx.get(MessageContext.WSDL_SERVICE));
-// log.info("PATH_INFO: "+ctx.get(MessageContext.PATH_INFO));
-// log.info("QUERY_STRING: "+ctx.get(MessageContext.QUERY_STRING));
-// log.info("HTTP_REQUEST_METHOD:
"+ctx.get(MessageContext.HTTP_REQUEST_METHOD));
-// log.info("HTTP_RESPONSE_CODE:
"+ctx.get(MessageContext.HTTP_RESPONSE_CODE));
-// log.info("HTTP_REQUEST_HEADERS:
"+this.printHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_REQUEST_HEADERS))));
-// log.info("HTTP_RESPONSE_HEADERS:
"+this.printHeaders((Map<String,List<String>>)(ctx.get(MessageContext.HTTP_RESPONSE_HEADERS))));
-//
-// try
-// {
-// SOAPEnvelope soapEnv = soapCtx.getMessage().getSOAPPart().getEnvelope();
-// if (soapEnv != null)
-// {
-// String envStr = DOMWriter.printNode(soapEnv, true);
-// log.info("ENVELOPE: "+envStr);
-// }
-// }
-// catch (SOAPException ex)
-// {
-// log.error("Cannot trace SOAPMessage", ex);
-// }
}
return true;
}
- public boolean handleFault(MessageContext arg0)
+ public boolean handleFault(MessageContext ctx)
{
- // TODO Auto-generated method stub
- return false;
+ return handleOutbound(ctx);
}
}
Show replies by date