(Class<T> httpUpgradeHandlerClass)
| 1892 | |
| 1893 | |
| 1894 | @SuppressWarnings("unchecked") |
| 1895 | @Override |
| 1896 | public <T extends HttpUpgradeHandler> T upgrade(Class<T> httpUpgradeHandlerClass) |
| 1897 | throws IOException, ServletException { |
| 1898 | T handler; |
| 1899 | InstanceManager instanceManager = null; |
| 1900 | try { |
| 1901 | // Do not go through the instance manager for internal Tomcat classes since they don't |
| 1902 | // need injection |
| 1903 | if (InternalHttpUpgradeHandler.class.isAssignableFrom(httpUpgradeHandlerClass)) { |
| 1904 | handler = httpUpgradeHandlerClass.getConstructor().newInstance(); |
| 1905 | } else { |
| 1906 | instanceManager = getContext().getInstanceManager(); |
| 1907 | handler = (T) instanceManager.newInstance(httpUpgradeHandlerClass); |
| 1908 | } |
| 1909 | } catch (ReflectiveOperationException | NamingException | IllegalArgumentException | SecurityException e) { |
| 1910 | throw new ServletException(e); |
| 1911 | } |
| 1912 | UpgradeToken upgradeToken = new UpgradeToken(handler, getContext(), instanceManager, |
| 1913 | getUpgradeProtocolName(httpUpgradeHandlerClass)); |
| 1914 | |
| 1915 | coyoteRequest.action(ActionCode.UPGRADE, upgradeToken); |
| 1916 | |
| 1917 | // Output required by RFC2616. Protocol specific headers should have |
| 1918 | // already been set. |
| 1919 | response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS); |
| 1920 | |
| 1921 | return handler; |
| 1922 | } |
| 1923 | |
| 1924 | |
| 1925 | private String getUpgradeProtocolName(Class<? extends HttpUpgradeHandler> httpUpgradeHandlerClass) { |
nothing calls this directly
no test coverage detected