本文整理汇总了Java中org.eclipse.jetty.io.Connection类的典型用法代码示例。如果您正苦于以下问题:Java Connection类的具体用法?Java Connection怎么用?Java Connection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Connection类属于org.eclipse.jetty.io包,在下文中一共展示了Connection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setConnection
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public void setConnection(Connection connection)
{
Connection old=_connection;
_connection=(AsyncConnection)connection;
if (old!=null && old!=_connection)
_manager.endPointUpgraded(this,old);
}
示例2: connectionClosed
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
@Override
protected void connectionClosed(Connection connection) {
if (connection instanceof AsyncHttpConnection) {
AsyncHttpConnection conn = (AsyncHttpConnection)connection;
ServerSessionMonitor monitor = (ServerSessionMonitor)conn.getAssociatedObject();
if (monitor != null) {
monitorService.deregisterSessionMonitor(monitor, session);
conn.setAssociatedObject(null);
}
}
super.connectionClosed(connection);
}
示例3: endPointUpgraded
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
@Override
protected void endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection)
{
LOG.debug("upgrade {} -> {}", oldConnection, endpoint.getConnection());
}
示例4: handle
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public Connection handle() throws IOException
{
while (_endp.isOpen() && !_parser.isComplete())
{
if (_handshake==null || _handshake.length()>0)
if (!handshake())
return this;
if (!_parser.parseAvailable())
{
if (_endp.isInputShutdown())
_future.handshakeFailed(new IOException("Incomplete handshake response"));
return this;
}
}
if (_error == null)
{
if (_accept == null)
{
_error = "No Sec-WebSocket-Accept";
}
else if (!WebSocketConnectionRFC6455.hashKey(_key).equals(_accept))
{
_error = "Bad Sec-WebSocket-Accept";
}
else if (!initExtensions(_future.getExtensions()))
{
_error = "Bad Sec-WebSocket-Extension";
}
else
{
WebSocketConnection connection = newWebSocketConnection();
Buffer header = _parser.getHeaderBuffer();
if (header.hasContent())
connection.fillBuffersFrom(header);
_buffers.returnBuffer(header);
_future.onConnection(connection);
return connection;
}
}
_endp.close();
return this;
}
示例5: getConnection
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public WebSocket.Connection getConnection()
{
return _connection;
}
示例6: handle
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public Connection handle() throws IOException
{
Thread current = Thread.currentThread();
ClassLoader oldcontext = current.getContextClassLoader();
current.setContextClassLoader(_context);
try
{
// handle the framing protocol
boolean progress=true;
while (progress)
{
int flushed=_generator.flushBuffer();
int filled=_parser.parseNext();
progress = flushed>0 || filled>0;
_endp.flush();
if (_endp instanceof AsyncEndPoint && ((AsyncEndPoint)_endp).hasProgressed())
progress=true;
}
}
catch(IOException e)
{
try
{
if (_endp.isOpen())
_endp.close();
}
catch(IOException e2)
{
LOG.ignore(e2);
}
throw e;
}
finally
{
current.setContextClassLoader(oldcontext);
_parser.returnBuffer();
_generator.returnBuffer();
if (_endp.isOpen())
{
if (_closedIn && _closedOut && _outbound.isBufferEmpty())
_endp.close();
else if (_endp.isInputShutdown() && !_closedIn)
closeIn(CLOSE_NO_CLOSE,null);
else
checkWriteable();
}
}
return this;
}
示例7: shutdown
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public void shutdown()
{
final WebSocket.Connection connection = _connection;
if (connection != null)
connection.close(CLOSE_SHUTDOWN, null);
}
示例8: handle
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public Connection handle() throws IOException
{
try
{
allocateBuffers();
boolean progress=true;
while (progress)
{
progress=false;
// If we are handshook let the delegate connection
if (_engine.getHandshakeStatus()!=HandshakeStatus.NOT_HANDSHAKING)
progress=process(null,null);
// handle the delegate connection
AsyncConnection next = (AsyncConnection)_connection.handle();
if (next!=_connection && next!=null)
{
_connection=next;
progress=true;
}
_logger.debug("{} handle {} progress={}", _session, this, progress);
}
}
finally
{
releaseBuffers();
if (!_ishut && _sslEndPoint.isInputShutdown() && _sslEndPoint.isOpen())
{
_ishut=true;
try
{
_connection.onInputShutdown();
}
catch(Throwable x)
{
_logger.warn("onInputShutdown failed", x);
try{_sslEndPoint.close();}
catch(IOException e2){
_logger.ignore(e2);}
}
}
}
return this;
}
示例9: onClose
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public void onClose()
{
Connection connection = _sslEndPoint.getConnection();
if (connection != null && connection != this)
connection.onClose();
}
示例10: getConnection
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public Connection getConnection()
{
return _connection;
}
示例11: setConnection
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public void setConnection(Connection connection)
{
_connection=(AsyncConnection)connection;
}
示例12: newConnection
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
@Override
public Connection newConnection(Connector connector, EndPoint endPoint) {
System.out.println("Received new connection from " + endPoint.getRemoteAddress());
ConnectionTracker.getInstance().onConnection();
return super.newConnection(connector, endPoint);
}
示例13: handle
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
public Connection handle() throws IOException
{
while (_endp.isOpen() && !_parser.isComplete())
{
if (_handshake==null || _handshake.length()>0)
if (!handshake())
return this;
if (!_parser.parseAvailable())
{
if (_endp.isInputShutdown())
_future.handshakeFailed(new IOException("Incomplete handshake response"));
return this;
}
}
if (_error == null)
{
if (_accept == null)
{
_error = "No Sec-WebSocket-Accept";
}
else if (!WebSocketConnectionRFC6455.hashKey(_key).equals(_accept))
{
_error = "Bad Sec-WebSocket-Accept";
}
else
{
WebSocketConnection connection = newWebSocketConnection();
Buffer header = _parser.getHeaderBuffer();
if (header.hasContent())
connection.fillBuffersFrom(header);
_buffers.returnBuffer(header);
_future.onConnection(connection);
return connection;
}
}
_endp.close();
return this;
}
示例14: newConnection
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
@Override
public Connection newConnection(Connector connector, EndPoint endPoint) {
ArrayByteBufferPool bufferPool = new ArrayByteBufferPool();
return new EchoConnection(bufferPool, endPoint, connector.getExecutor());
}
示例15: newConnection
import org.eclipse.jetty.io.Connection; //导入依赖的package包/类
@Override
public Connection newConnection(Connector connector, EndPoint endPoint) {
throw new UnsupportedOperationException();
}