Author: markt Date: Wed Feb 29 21:22:10 2012 New Revision: 1295279 URL: http://svn.apache.org/viewvc?rev=1295279&view=rev Log: Make the outbound buffer sizes configurable
Modified: tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java Modified: tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java?rev=1295279&r1=1295278&r2=1295279&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java (original) +++ tomcat/trunk/java/org/apache/catalina/websocket/StreamInbound.java Wed Feb 29 21:22:10 2012 @@ -38,10 +38,51 @@ public abstract class StreamInbound impl private UpgradeProcessor<?> processor = null; private WsOutbound outbound; + private int outboundByteBufferSize = WsOutbound.DEFAULT_BUFFER_SIZE; + private int outboundCharBufferSize = WsOutbound.DEFAULT_BUFFER_SIZE; + + + + public int getOutboundByteBufferSize() { + return outboundByteBufferSize; + } + + + /** + * This only applies to the {@link WsOutbound} instance returned from + * {@link #getWsOutbound()} created by a subsequent call to + * {@link #setUpgradeOutbound(UpgradeOutbound)}. The current + * {@link WsOutbound} instance, if any, is not affected. + * + * @param outboundByteBufferSize + */ + public void setOutboundByteBufferSize(int outboundByteBufferSize) { + this.outboundByteBufferSize = outboundByteBufferSize; + } + + + public int getOutboundCharBufferSize() { + return outboundCharBufferSize; + } + + + /** + * This only applies to the {@link WsOutbound} instance returned from + * {@link #getWsOutbound()} created by a subsequent call to + * {@link #setUpgradeOutbound(UpgradeOutbound)}. The current + * {@link WsOutbound} instance, if any, is not affected. + * + * @param outboundCharBufferSize + */ + public void setOutboundCharBufferSize(int outboundCharBufferSize) { + this.outboundCharBufferSize = outboundCharBufferSize; + } + @Override public final void setUpgradeOutbound(UpgradeOutbound upgradeOutbound) { - outbound = new WsOutbound(upgradeOutbound); + outbound = new WsOutbound(upgradeOutbound, outboundByteBufferSize, + outboundCharBufferSize); } Modified: tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java?rev=1295279&r1=1295278&r2=1295279&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java (original) +++ tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java Wed Feb 29 21:22:10 2012 @@ -33,7 +33,7 @@ public class WsOutbound { private static final StringManager sm = StringManager.getManager(Constants.Package); - private static final int DEFAULT_BUFFER_SIZE = 8192; + public static final int DEFAULT_BUFFER_SIZE = 8192; private UpgradeOutbound upgradeOutbound; private ByteBuffer bb; @@ -44,10 +44,15 @@ public class WsOutbound { public WsOutbound(UpgradeOutbound upgradeOutbound) { + this(upgradeOutbound, DEFAULT_BUFFER_SIZE, DEFAULT_BUFFER_SIZE); + } + + + public WsOutbound(UpgradeOutbound upgradeOutbound, int byteBufferSize, + int charBufferSize) { this.upgradeOutbound = upgradeOutbound; - // TODO: Make buffer size configurable - this.bb = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE); - this.cb = CharBuffer.allocate(DEFAULT_BUFFER_SIZE); + this.bb = ByteBuffer.allocate(byteBufferSize); + this.cb = CharBuffer.allocate(charBufferSize); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org