Search in sources :

Example 1 with Connection

use of org.glassfish.tyrus.spi.Connection in project spring-framework by spring-projects.

the class WebLogicRequestUpgradeStrategy method handleSuccess.

@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response, UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {
    response.setStatus(upgradeResponse.getStatus());
    for (Map.Entry<String, List<String>> entry : upgradeResponse.getHeaders().entrySet()) {
        response.addHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
    }
    AsyncContext asyncContext = request.startAsync();
    asyncContext.setTimeout(-1L);
    Object nativeRequest = getNativeRequest(request);
    BeanWrapper beanWrapper = new BeanWrapperImpl(nativeRequest);
    Object httpSocket = beanWrapper.getPropertyValue("connection.connectionHandler.rawConnection");
    Object webSocket = webSocketHelper.newInstance(request, httpSocket);
    webSocketHelper.upgrade(webSocket, httpSocket, request.getServletContext());
    response.flushBuffer();
    boolean isProtected = request.getUserPrincipal() != null;
    Writer servletWriter = servletWriterHelper.newInstance(webSocket, isProtected);
    Connection connection = upgradeInfo.createConnection(servletWriter, noOpCloseListener);
    new BeanWrapperImpl(webSocket).setPropertyValue("connection", connection);
    new BeanWrapperImpl(servletWriter).setPropertyValue("connection", connection);
    webSocketHelper.registerForReadEvent(webSocket);
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl) Connection(org.glassfish.tyrus.spi.Connection) List(java.util.List) AsyncContext(javax.servlet.AsyncContext) Map(java.util.Map) Writer(org.glassfish.tyrus.spi.Writer)

Aggregations

List (java.util.List)1 Map (java.util.Map)1 AsyncContext (javax.servlet.AsyncContext)1 Connection (org.glassfish.tyrus.spi.Connection)1 Writer (org.glassfish.tyrus.spi.Writer)1 BeanWrapper (org.springframework.beans.BeanWrapper)1 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)1