tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1295724 - in /tomcat/trunk/webapps/examples/WEB-INF: classes/websocket/EchoMessage.java web.xml
Date Fri, 02 Mar 2012 20:21:06 GMT
On 1 March 2012 18:27,  <fhanik@apache.org> wrote:
> Author: fhanik
> Date: Thu Mar  1 18:27:56 2012
> New Revision: 1295724
>
> URL: http://svn.apache.org/viewvc?rev=1295724&view=rev
> Log:
> Allow the examples to configure the buffer on the fly
>
> Modified:
>    tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/EchoMessage.java
>    tomcat/trunk/webapps/examples/WEB-INF/web.xml
>
> Modified: tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/EchoMessage.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/EchoMessage.java?rev=1295724&r1=1295723&r2=1295724&view=diff
> ==============================================================================
> --- tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/EchoMessage.java (original)
> +++ tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/EchoMessage.java Thu Mar
 1 18:27:56 2012
> @@ -20,6 +20,8 @@ import java.io.IOException;
>  import java.nio.ByteBuffer;
>  import java.nio.CharBuffer;
>
> +import javax.servlet.ServletException;
> +
>  import org.apache.catalina.websocket.MessageInbound;
>  import org.apache.catalina.websocket.StreamInbound;
>  import org.apache.catalina.websocket.WebSocketServlet;
> @@ -28,13 +30,40 @@ import org.apache.catalina.websocket.Web
>  public class EchoMessage extends WebSocketServlet {
>
>     private static final long serialVersionUID = 1L;
> +    private volatile int byteBufSize;
> +    private volatile int charBufSize;
> +
> +    @Override
> +    public void init() throws ServletException {
> +        super.init();
> +        byteBufSize = getInitParameterIntValue("byteBufferMaxSize", 2097152);
> +        charBufSize = getInitParameterIntValue("charBufferMaxSize", 2097152);

Value does not agree with below.
Is that intended?

> +    }
> +
> +    public int getInitParameterIntValue(String name, int defaultValue) {
> +        String val = this.getInitParameter(name);
> +        int result = defaultValue;
> +        try {
> +            result = Integer.parseInt(val);
> +        }catch (Exception x) {
> +        }
> +        return result;
> +    }
> +
> +
>
>     @Override
>     protected StreamInbound createWebSocketInbound(String subProtocol) {
> -        return new EchoMessageInbound();
> +        return new EchoMessageInbound(byteBufSize,charBufSize);
>     }
>
>     private static final class EchoMessageInbound extends MessageInbound {
> +
> +        public EchoMessageInbound(int byteBufferMaxSize, int charBufferMaxSize)
{
> +            super();
> +            setByteBufferMaxSize(byteBufferMaxSize);
> +            setCharBufferMaxSize(charBufferMaxSize);
> +        }
>
>         @Override
>         protected void onBinaryMessage(ByteBuffer message) throws IOException {
>
> Modified: tomcat/trunk/webapps/examples/WEB-INF/web.xml
> URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/web.xml?rev=1295724&r1=1295723&r2=1295724&view=diff
> ==============================================================================
> --- tomcat/trunk/webapps/examples/WEB-INF/web.xml (original)
> +++ tomcat/trunk/webapps/examples/WEB-INF/web.xml Thu Mar  1 18:27:56 2012
> @@ -359,6 +359,8 @@
>     <servlet>
>       <servlet-name>wsEchoMessage</servlet-name>
>       <servlet-class>websocket.EchoMessage</servlet-class>
> +      <init-param><param-name>byteBufferMaxSize</param-name><param-value>20971520</param-value></init-param>
> +      <init-param><param-name>charBufferMaxSize</param-name><param-value>20971520</param-value></init-param>

Value does not agree with above.
Is that intended?

>     </servlet>
>     <servlet-mapping>
>       <servlet-name>wsEchoMessage</servlet-name>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message