public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { T listenerInstance = null; try { listenerInstance = (T) context.getInstanceManager().newInstance(clazz); } catch (Exception e) { throw new ServletException(MESSAGES.listenerCreationFailed(clazz.getName()), e); } asyncListenerInstances.add(listenerInstance); return listenerInstance; }
public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { T listenerInstance = null; try { listenerInstance = (T) context.getInstanceManager().newInstance(clazz); } catch (Exception e) { throw new ServletException(sm.getString("coyoteRequest.createListener", clazz.getName()), e); } return listenerInstance; }
@SuppressWarnings("unchecked") @Override public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { check(); T listener = null; try { listener = (T) context.getInstanceManager().newInstance( clazz.getName(), clazz.getClassLoader()); } catch (ReflectiveOperationException | NamingException e) { ServletException se = new ServletException(e); throw se; } catch (Exception e) { ExceptionUtils.handleThrowable(e.getCause()); ServletException se = new ServletException(e); throw se; } return listener; }
@SuppressWarnings("unchecked") @Override public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException { check(); T listener = null; try { listener = (T) context.getInstanceManager().newInstance( clazz.getName(), clazz.getClassLoader()); } catch (ReflectiveOperationException | NamingException e) { ServletException se = new ServletException(e); throw se; } catch (Exception e) { ExceptionUtils.handleThrowable(e.getCause()); ServletException se = new ServletException(e); throw se; } return listener; }
/** * {@inheritDoc} * * @since Servlet 3.1 */ @SuppressWarnings("unchecked") @Override public <T extends HttpUpgradeHandler> T upgrade( Class<T> httpUpgradeHandlerClass) throws java.io.IOException, ServletException { T handler; try { handler = (T) context.getInstanceManager().newInstance(httpUpgradeHandlerClass); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NamingException e) { throw new ServletException(e); } coyoteRequest.action(ActionCode.UPGRADE, handler); // Output required by RFC2616. Protocol specific headers should have // already been set. response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS); return handler; }
@SuppressWarnings("unchecked") @Override public <T extends HttpUpgradeHandler> T upgrade( Class<T> httpUpgradeHandlerClass) throws java.io.IOException, ServletException { T handler; InstanceManager instanceManager = null; try { // Do not go through the instance manager for internal Tomcat classes since they don't // need injection if (InternalHttpUpgradeHandler.class.isAssignableFrom(httpUpgradeHandlerClass)) { handler = httpUpgradeHandlerClass.getConstructor().newInstance(); } else { instanceManager = getContext().getInstanceManager(); handler = (T) instanceManager.newInstance(httpUpgradeHandlerClass); } } catch (ReflectiveOperationException | NamingException | IllegalArgumentException | SecurityException e) { throw new ServletException(e); } UpgradeToken upgradeToken = new UpgradeToken(handler, getContext(), instanceManager); coyoteRequest.action(ActionCode.UPGRADE, upgradeToken); // Output required by RFC2616. Protocol specific headers should have // already been set. response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS); return handler; }
@SuppressWarnings("unchecked") @Override public <T extends HttpUpgradeHandler> T upgrade( Class<T> httpUpgradeHandlerClass) throws java.io.IOException, ServletException { T handler; InstanceManager instanceManager = null; try { // Do not go through the instance manager for internal Tomcat classes since they don't // need injection if (InternalHttpUpgradeHandler.class.isAssignableFrom(httpUpgradeHandlerClass)) { handler = httpUpgradeHandlerClass.getConstructor().newInstance(); } else { instanceManager = getContext().getInstanceManager(); handler = (T) instanceManager.newInstance(httpUpgradeHandlerClass); } } catch (ReflectiveOperationException | NamingException | IllegalArgumentException | SecurityException e) { throw new ServletException(e); } UpgradeToken upgradeToken = new UpgradeToken(handler, getContext(), instanceManager); coyoteRequest.action(ActionCode.UPGRADE, upgradeToken); // Output required by RFC2616. Protocol specific headers should have // already been set. response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS); return handler; }
@SuppressWarnings("unchecked") public <T extends HttpUpgradeHandler> T upgrade(Class<T> upgradeHandlerClass) throws IOException { T ugradeHandler = null; Throwable upgradeError = null; try { ugradeHandler = (T) context.getInstanceManager().newInstance(upgradeHandlerClass); } catch (Throwable t) { upgradeError = t; } if (ugradeHandler == null) { throw new IOException(MESSAGES.upgradeError(), upgradeError); } response.sendUpgrade(); eventMode = true; this.upgradeHandler = ugradeHandler; asyncContext = new AsyncContextImpl(); return ugradeHandler; }
/** * Return the application Filter we are configured for. * * @exception ClassCastException if the specified class does not implement * the <code>javax.servlet.Filter</code> interface * @exception ClassNotFoundException if the filter class cannot be found * @exception IllegalAccessException if the filter class cannot be * publicly instantiated * @exception InstantiationException if an exception occurs while * instantiating the filter object * @exception ServletException if thrown by the filter's init() method * @throws NamingException * @throws ReflectiveOperationException * @throws SecurityException * @throws IllegalArgumentException */ Filter getFilter() throws ClassCastException, ReflectiveOperationException, ServletException, NamingException, IllegalArgumentException, SecurityException { // Return the existing filter instance, if any if (this.filter != null) return this.filter; // Identify the class loader we will be using String filterClass = filterDef.getFilterClass(); this.filter = (Filter) context.getInstanceManager().newInstance(filterClass); initFilter(); return this.filter; }
/** * Return the application Filter we are configured for. * * @exception ClassCastException if the specified class does not implement * the <code>javax.servlet.Filter</code> interface * @exception ClassNotFoundException if the filter class cannot be found * @exception IllegalAccessException if the filter class cannot be * publicly instantiated * @exception InstantiationException if an exception occurs while * instantiating the filter object * @exception ServletException if thrown by the filter's init() method * @throws NamingException * @throws ReflectiveOperationException * @throws SecurityException * @throws IllegalArgumentException */ Filter getFilter() throws ClassCastException, ReflectiveOperationException, ServletException, NamingException, IllegalArgumentException, SecurityException { // Return the existing filter instance, if any if (this.filter != null) return this.filter; // Identify the class loader we will be using String filterClass = filterDef.getFilterClass(); this.filter = (Filter) context.getInstanceManager().newInstance(filterClass); initFilter(); return this.filter; }
this.filter = (Filter) context.getInstanceManager().newInstance(filterClass); } else { this.filter = filterInstance;
for (AsyncListener listener : asyncListenerInstances) { try { context.getInstanceManager().destroyInstance(listener); } catch (Throwable t) { context.getLogger().error(MESSAGES.preDestroyException(), t);
} else { this.filter = filterDef.getFilter(); context.getInstanceManager().newInstance(filter); initFilter();
} else { this.filter = filterDef.getFilter(); context.getInstanceManager().newInstance(filter); initFilter();
this.filter = (Filter) context.getInstanceManager().newInstance(filterClass); } else { this.filter = filterInstance;
((Context) getParent()).getInstanceManager().destroyInstance(instance); ((Context) getParent()).getInstanceManager().destroyInstance(s);
((Context) getParent()).getInstanceManager().destroyInstance(instance); ((Context) getParent()).getInstanceManager().destroyInstance(s);
((Context)getParent()).getInstanceManager().destroyInstance(instance); } catch (Throwable t) { ExceptionUtils.handleThrowable(t);
context.getInstanceManager().destroyInstance(this.filter); } catch (Exception e) { Throwable t = ExceptionUtils
context.getInstanceManager().destroyInstance(this.filter); } catch (Exception e) { Throwable t = ExceptionUtils