353073 deprecated non factory method for websocket clients

This commit is contained in:
Greg Wilkins 2011-08-29 12:27:53 +10:00
parent 2a5a3a4d01
commit 39d0d4fee9
8 changed files with 56 additions and 14 deletions

View File

@ -119,6 +119,8 @@ public class AsyncHttpConnection extends HttpConnection
// Are we write blocked
if (_generator.isCommitted() && !_generator.isComplete())
((AsyncEndPoint)_endp).scheduleWrite();
else
_generator.returnBuffers();
}
return connection;
}

View File

@ -676,6 +676,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
// Context listeners
if (_contextListeners != null)
{
new Throwable().printStackTrace();
ServletContextEvent event = new ServletContextEvent(_scontext);
for (int i = LazyList.size(_contextListeners); i-- > 0;)
{

View File

@ -67,7 +67,9 @@ public class WebSocketClient
/* ------------------------------------------------------------ */
/** Create a WebSocket Client with private factory.
* <p>Creates a WebSocketClient from a private WebSocketClientFactory. This can be wasteful of resources if many clients are created.
* <p>Creates a WebSocketClient from a private WebSocketClientFactory.
* This can be wasteful of resources if many clients are created.
* @deprecated Use {@link WebSocketClientFactory}
*/
public WebSocketClient() throws Exception
{
@ -85,7 +87,16 @@ public class WebSocketClient
_factory=factory;
_maskGen=_factory.getMaskGen();
}
/* ------------------------------------------------------------ */
/**
* @return The factory this client was created with.
*/
public WebSocketClientFactory getFactory()
{
return _factory;
}
/* ------------------------------------------------------------ */
/** Get the maxIdleTime for connections opened by this client.
* @return The maxIdleTime in ms, or -1 if the default from {@link #getSelectorManager()} is used.

View File

@ -52,8 +52,9 @@ public class WebSocketClientFactory extends AggregateLifeCycle
private final ThreadPool _threadPool;
private final WebSocketClientSelector _selector;
private final WebSocketBuffers _buffers;
private final MaskGen _maskGen;
private MaskGen _maskGen;
private WebSocketBuffers _buffers;
/* ------------------------------------------------------------ */
/** Create a WebSocket Client with default configuration.
@ -111,6 +112,28 @@ public class WebSocketClientFactory extends AggregateLifeCycle
return _maskGen;
}
/* ------------------------------------------------------------ */
public void setMaskGen(MaskGen maskGen)
{
if (isRunning())
throw new IllegalStateException(getState());
_maskGen=maskGen;
}
/* ------------------------------------------------------------ */
public void setBufferSize(int bufferSize)
{
if (isRunning())
throw new IllegalStateException(getState());
_buffers=new WebSocketBuffers(bufferSize);
}
/* ------------------------------------------------------------ */
public int getBufferSize()
{
return _buffers.getBufferSize();
}
/* ------------------------------------------------------------ */
public WebSocketClient newWebSocketClient()
{
@ -147,6 +170,12 @@ public class WebSocketClientFactory extends AggregateLifeCycle
}
}
/* ------------------------------------------------------------ */
@Override
protected void doStop() throws Exception
{
super.doStop();
}
/* ------------------------------------------------------------ */
/** WebSocket Client Selector Manager

View File

@ -58,7 +58,6 @@ public class WebSocketConnectionD12 extends AbstractConnection implements WebSoc
final static int CLOSE_SHUTDOWN=1001;
final static int CLOSE_PROTOCOL=1002;
final static int CLOSE_BADDATA=1003;
final static int CLOSE_LARGE=1004;
final static int CLOSE_NOCODE=1005;
final static int CLOSE_NOCLOSE=1006;
final static int CLOSE_NOTUTF8=1007;
@ -772,7 +771,7 @@ public class WebSocketConnectionD12 extends AbstractConnection implements WebSoc
int max = _connection.getMaxBinaryMessageSize();
if (max>0 && (bufferLen+length)>max)
{
_connection.close(WebSocketConnectionD12.CLOSE_LARGE,"Message size > "+_connection.getMaxBinaryMessageSize());
_connection.close(WebSocketConnectionD12.CLOSE_BADDATA,"Message size > "+_connection.getMaxBinaryMessageSize());
_opcode=-1;
if (_aggregate!=null)
_aggregate.clear();
@ -783,7 +782,7 @@ public class WebSocketConnectionD12 extends AbstractConnection implements WebSoc
private void textMessageTooLarge()
{
_connection.close(WebSocketConnectionD12.CLOSE_LARGE,"Text message size > "+_connection.getMaxTextMessageSize()+" chars");
_connection.close(WebSocketConnectionD12.CLOSE_BADDATA,"Text message size > "+_connection.getMaxTextMessageSize()+" chars");
_opcode=-1;
_utf8.reset();

View File

@ -249,7 +249,7 @@ public class WebSocketParserD12 implements WebSocketParser
if (_length>_buffer.capacity() && !_fakeFragments)
{
events++;
_handler.close(WebSocketConnectionD12.CLOSE_LARGE,"frame size "+_length+">"+_buffer.capacity());
_handler.close(WebSocketConnectionD12.CLOSE_BADDATA,"frame size "+_length+">"+_buffer.capacity());
_skip=true;
}
@ -268,7 +268,7 @@ public class WebSocketParserD12 implements WebSocketParser
if (_length>=_buffer.capacity())
{
events++;
_handler.close(WebSocketConnectionD12.CLOSE_LARGE,"frame size "+_length+">"+_buffer.capacity());
_handler.close(WebSocketConnectionD12.CLOSE_BADDATA,"frame size "+_length+">"+_buffer.capacity());
_skip=true;
}

View File

@ -492,7 +492,7 @@ public class WebSocketMessageD12Test
assertEquals(0x80|WebSocketConnectionD12.OP_CLOSE,input.read());
assertEquals(30,input.read());
int code=(0xff&input.read())*0x100+(0xff&input.read());
assertEquals(1004,code);
assertEquals(WebSocketConnectionD12.CLOSE_BADDATA,code);
lookFor("Text message size > 15 chars",input);
}
@ -543,7 +543,7 @@ public class WebSocketMessageD12Test
assertEquals(0x80|WebSocketConnectionD12.OP_CLOSE,input.read());
assertEquals(30,input.read());
int code=(0xff&input.read())*0x100+(0xff&input.read());
assertEquals(1004,code);
assertEquals(WebSocketConnectionD12.CLOSE_BADDATA,code);
lookFor("Text message size > 15 chars",input);
}
@ -657,7 +657,7 @@ public class WebSocketMessageD12Test
assertEquals(0x80|WebSocketConnectionD12.OP_CLOSE,input.read());
assertEquals(19,input.read());
int code=(0xff&input.read())*0x100+(0xff&input.read());
assertEquals(1004,code);
assertEquals(WebSocketConnectionD12.CLOSE_BADDATA,code);
lookFor("Message size > 15",input);
}
@ -706,7 +706,7 @@ public class WebSocketMessageD12Test
assertEquals(0x80|WebSocketConnectionD12.OP_CLOSE,input.read());
assertEquals(19,input.read());
int code=(0xff&input.read())*0x100+(0xff&input.read());
assertEquals(1004,code);
assertEquals(WebSocketConnectionD12.CLOSE_BADDATA,code);
lookFor("Message size > 15",input);
}

View File

@ -269,7 +269,7 @@ public class WebSocketParserD12Test
assertTrue(progress>0);
assertEquals(WebSocketConnectionD12.CLOSE_LARGE,_handler._code);
assertEquals(WebSocketConnectionD12.CLOSE_BADDATA,_handler._code);
for (int i=0;i<2048;i++)
_in.put((byte)'a');
progress =_parser.parseNext();