Author: chirino Date: Mon Feb 6 15:04:42 2012 New Revision: 1241035 URL: http://svn.apache.org/viewvc?rev=1241035&view=rev Log: Cleanup the waiting on logic a bit. Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala?rev=1241035&r1=1241034&r2=1241035&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala (original) +++ activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala Mon Feb 6 15:04:42 2012 @@ -61,6 +61,8 @@ object OpenwireProtocolHandler extends L preferred_wireformat_settings.setMaxInactivityDurationInitalDelay(10 * 1000 * 1000); preferred_wireformat_settings.setCacheSize(1024); preferred_wireformat_settings.setMaxFrameSize(OpenWireFormat.DEFAULT_MAX_FRAME_SIZE); + + val WAITING_ON_CLIENT_REQUEST = ()=> "client request" } /** @@ -109,7 +111,7 @@ class OpenwireProtocolHandler extends Pr var heart_beat_monitor = new HeartBeatMonitor - var waiting_on: String = "client request" + var waiting_on = WAITING_ON_CLIENT_REQUEST var current_command: Object = _ var codec:OpenwireCodec = _ @@ -122,7 +124,7 @@ class OpenwireProtocolHandler extends Pr rc.protocol_version = ""+(if (wire_format == null) 0 else wire_format.getVersion) rc.user = login.map(_.toString).getOrElse(null) rc.subscription_count = all_consumers.size - rc.waiting_on = waiting_on + rc.waiting_on = waiting_on() rc } @@ -154,14 +156,14 @@ class OpenwireProtocolHandler extends Pr } } - 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 } 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=1241035&r1=1241034&r2=1241035&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 Mon Feb 6 15:04:42 2012 @@ -68,12 +68,7 @@ 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" - } + val WAITING_ON_CLIENT_REQUEST = ()=> "client request" } /** @@ -83,6 +78,7 @@ class StompProtocolHandler extends Proto import StompProtocolHandler._ var connection_log:Log = StompProtocolHandler + def protocol = "stomp" def broker = connection.connector.broker @@ -558,7 +554,7 @@ class StompProtocolHandler extends Proto var heart_beat_monitor = new HeartBeatMonitor val security_context = new SecurityContext - var waiting_on: ()=>String = WAITING_ON_CLIENT_REQUEST + var waiting_on = WAITING_ON_CLIENT_REQUEST var config:StompDTO = _ var protocol_filters = List[ProtocolFilter]() @@ -669,7 +665,7 @@ class StompProtocolHandler extends Proto private def die[T](headers:HeaderMap, body:String):T = { if( !dead ) { dead = true - waiting_on = WAITING_ON_SHUTDOWN + waiting_on = ()=>"shutdown" connection.transport.resumeRead if( body.isEmpty ) {