activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1235355 - /activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
Date Tue, 24 Jan 2012 16:58:04 GMT
Author: chirino
Date: Tue Jan 24 16:58:04 2012
New Revision: 1235355

URL: http://svn.apache.org/viewvc?rev=1235355&view=rev
Log:
Make the waiting_on variable be a callback function to avoid constructing the waiting on status
string every time the wait status changes.  The string only needs to be constructed when the
management APIs poll the status of the connection.

Modified:
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala?rev=1235355&r1=1235354&r2=1235355&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
Tue Jan 24 16:58:04 2012
@@ -71,6 +71,12 @@ object StompProtocolHandler extends Log 
   val DEFAULT_INBOUND_HEARTBEAT = 10*1000L
   var inbound_heartbeat = DEFAULT_INBOUND_HEARTBEAT
 
+  val WAITING_ON_CLIENT_REQUEST: () => String = () => {
+    "client request"
+  }
+  val WAITING_ON_SHUTDOWN: () => String = () => {
+    "shutdown"
+  }
 
   def noop = shift {  k: (Unit=>Unit) => k() }
   def unit:Unit = {}
@@ -551,7 +557,7 @@ class StompProtocolHandler extends Proto
 
   var heart_beat_monitor = new HeartBeatMonitor
   val security_context = new SecurityContext
-  var waiting_on:String = "client request"
+  var waiting_on: ()=>String = WAITING_ON_CLIENT_REQUEST
   var config:StompDTO = _
   var session_id:String = _
 
@@ -632,7 +638,7 @@ class StompProtocolHandler extends Proto
     rc.protocol_version = if( protocol_version == null ) null else protocol_version.toString
     rc.user = security_context.user
     rc.subscription_count = consumers.size
-    rc.waiting_on = waiting_on
+    rc.waiting_on = waiting_on()
     rc
   }
 
@@ -663,7 +669,7 @@ class StompProtocolHandler extends Proto
   private def die[T](headers:HeaderMap, body:String):T = {
     if( !dead ) {
       dead = true
-      waiting_on = "shutdown"
+      waiting_on = WAITING_ON_SHUTDOWN
       connection.transport.resumeRead
 
       if( body.isEmpty ) {
@@ -801,13 +807,13 @@ class StompProtocolHandler extends Proto
     }
   }
 
-  def suspend_read(reason:String) = {
-    waiting_on = reason
+  def suspend_read(reason: =>String) = {
+    waiting_on = reason _
     connection.transport.suspendRead
     heart_beat_monitor.suspendRead
   }
   def resume_read() = {
-    waiting_on = "client request"
+    waiting_on = WAITING_ON_CLIENT_REQUEST
     connection.transport.resumeRead
     heart_beat_monitor.resumeRead
   }



Mime
View raw message