You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2007/03/06 21:20:22 UTC

svn commit: r515282 - in /activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp: StompFrame.java StompSslTransportFactory.java StompTransportFactory.java StompTransportFilter.java

Author: chirino
Date: Tue Mar  6 12:20:20 2007
New Revision: 515282

URL: http://svn.apache.org/viewvc?view=rev&rev=515282
Log:
Better Stomp protocol trace logging support.  When the ?transport.trace=true
option is specified on a stomp connector, we now log the Stomp protocol frames instead of the ActiveMQ command objects.


Modified:
    activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java
    activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java
    activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFactory.java
    activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java

Modified: activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java?view=diff&rev=515282&r1=515281&r2=515282
==============================================================================
--- activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java (original)
+++ activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompFrame.java Tue Mar  6 12:20:20 2007
@@ -17,8 +17,10 @@
  */
 package org.apache.activemq.transport.stomp;
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.activemq.command.Command;
@@ -147,4 +149,26 @@
 		return false;
 	}
 
+	public String toString() {
+		StringBuffer buffer = new StringBuffer();
+		buffer.append(getAction());
+		buffer.append("\n");
+		Map headers = getHeaders();
+		for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();) {
+			Map.Entry entry = (Map.Entry) iter.next();
+			buffer.append(entry.getKey());
+			buffer.append(":");
+			buffer.append(entry.getValue());
+			buffer.append("\n");
+		}
+		buffer.append("\n");
+		if( getContent()!=null ) {
+			try {
+				buffer.append(new String(getContent()));
+			} catch (Throwable e) {
+				buffer.append(Arrays.toString(getContent()));
+			}
+		}
+		return buffer.toString();
+	}
 }

Modified: activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java?view=diff&rev=515282&r1=515281&r2=515282
==============================================================================
--- activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java (original)
+++ activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompSslTransportFactory.java Tue Mar  6 12:20:20 2007
@@ -17,13 +17,13 @@
  */
 package org.apache.activemq.transport.stomp;
 
-import org.apache.activemq.transport.tcp.TcpTransportFactory;
-import org.apache.activemq.transport.tcp.SslTransportFactory;
+import java.util.Map;
+
 import org.apache.activemq.transport.Transport;
+import org.apache.activemq.transport.tcp.SslTransportFactory;
+import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.wireformat.WireFormat;
 
-import java.util.Map;
-
 /**
  * A <a href="http://stomp.codehaus.org/">STOMP</a> over SSL transport factory
  *
@@ -37,6 +37,7 @@
 
     public Transport compositeConfigure(Transport transport, WireFormat format, Map options) {
     	transport = new StompTransportFilter(transport, new LegacyFrameTranslator());
+    	IntrospectionSupport.setProperties(transport, options);
     	return super.compositeConfigure(transport, format, options);
     }
 }

Modified: activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFactory.java?view=diff&rev=515282&r1=515281&r2=515282
==============================================================================
--- activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFactory.java (original)
+++ activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFactory.java Tue Mar  6 12:20:20 2007
@@ -21,6 +21,7 @@
 
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.tcp.TcpTransportFactory;
+import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.wireformat.WireFormat;
 
 /**
@@ -36,6 +37,7 @@
 
     public Transport compositeConfigure(Transport transport, WireFormat format, Map options) {
     	transport = new StompTransportFilter(transport, new LegacyFrameTranslator());
+    	IntrospectionSupport.setProperties(transport, options);
     	return super.compositeConfigure(transport, format, options);
     }
 }

Modified: activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java?view=diff&rev=515282&r1=515281&r2=515282
==============================================================================
--- activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java (original)
+++ activemq/branches/activemq-4.1/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompTransportFilter.java Tue Mar  6 12:20:20 2007
@@ -25,6 +25,8 @@
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFilter;
 import org.apache.activemq.util.IOExceptionSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * The StompTransportFilter normally sits on top of a TcpTransport
@@ -36,7 +38,7 @@
  * @author <a href="http://hiramchirino.com">chirino</a>
  */
 public class StompTransportFilter extends TransportFilter {
-
+	static final private Log log = LogFactory.getLog(StompTransportFilter.class);
     private final ProtocolConverter protocolConverter;
 
     private final Object sendToActiveMQMutex = new Object();
@@ -44,6 +46,8 @@
 
     private final FrameTranslator frameTranslator;
 
+    private boolean trace;
+    
     public StompTransportFilter(Transport next, FrameTranslator translator) {
 		super(next);
         this.frameTranslator = translator;
@@ -61,6 +65,9 @@
 
 	public void onCommand(Object command) {
         try {
+    		if( trace ) {
+    			log.trace("Received: \n"+command);
+    		}
         	protocolConverter.onStompCommad((StompFrame) command);
 		} catch (IOException e) {
 			onException(e);
@@ -76,6 +83,9 @@
 	}
 
 	public void sendToStomp(StompFrame command) throws IOException {
+		if( trace ) {
+			log.trace("Sending: \n"+command);
+		}
 		synchronized(sendToStompMutex) {
 			next.oneway(command);
 		}
@@ -85,4 +95,12 @@
     {
         return frameTranslator;
     }
+
+	public boolean isTrace() {
+		return trace;
+	}
+
+	public void setTrace(boolean trace) {
+		this.trace = trace;
+	}
 }