/** * @return the newly created Servlet instance * @throws ServletException * @throws IllegalAccessException * @throws InstantiationException */ protected Servlet newInstance() throws ServletException, IllegalAccessException, InstantiationException { try { ServletContext ctx = getServletHandler().getServletContext(); if (ctx==null) return getHeldClass().newInstance(); return ((ServletContextHandler.Context)ctx).createServlet(getHeldClass()); } catch (ServletException se) { Throwable cause = se.getRootCause(); if (cause instanceof InstantiationException) throw (InstantiationException)cause; if (cause instanceof IllegalAccessException) throw (IllegalAccessException)cause; throw se; } } }
/** * @return the newly created Servlet instance * @throws ServletException * @throws IllegalAccessException * @throws InstantiationException */ protected Servlet newInstance() throws ServletException, IllegalAccessException, InstantiationException { try { ServletContext ctx = getServletHandler().getServletContext(); if (ctx instanceof ServletContextHandler.Context) return ((ServletContextHandler.Context)ctx).createServlet(getHeldClass()); return getHeldClass().newInstance(); } catch (ServletException se) { Throwable cause = se.getRootCause(); if (cause instanceof InstantiationException) throw (InstantiationException)cause; if (cause instanceof IllegalAccessException) throw (IllegalAccessException)cause; throw se; } }
/** * @return the newly created Servlet instance * @throws ServletException * @throws IllegalAccessException * @throws InstantiationException */ protected Servlet newInstance() throws ServletException, IllegalAccessException, InstantiationException { try { ServletContext ctx = getServletHandler().getServletContext(); if (ctx instanceof ServletContextHandler.Context) return ((ServletContextHandler.Context)ctx).createServlet(getHeldClass()); return getHeldClass().newInstance(); } catch (ServletException se) { Throwable cause = se.getRootCause(); if (cause instanceof InstantiationException) throw (InstantiationException)cause; if (cause instanceof IllegalAccessException) throw (IllegalAccessException)cause; throw se; } }
/** * @return the newly created Servlet instance * @throws ServletException if unable to create a new instance * @throws IllegalAccessException if not allowed to create a new instance * @throws InstantiationException if creating new instance resulted in error */ protected Servlet newInstance() throws ServletException, IllegalAccessException, InstantiationException { try { ServletContext ctx = getServletHandler().getServletContext(); if (ctx instanceof ServletContextHandler.Context) return ((ServletContextHandler.Context)ctx).createServlet(getHeldClass()); return getHeldClass().newInstance(); } catch (ServletException se) { Throwable cause = se.getRootCause(); if (cause instanceof InstantiationException) throw (InstantiationException)cause; if (cause instanceof IllegalAccessException) throw (IllegalAccessException)cause; throw se; } }
/** * @return the newly created Servlet instance * @throws ServletException * @throws IllegalAccessException * @throws InstantiationException */ protected Servlet newInstance() throws ServletException, IllegalAccessException, InstantiationException { try { ServletContext ctx = getServletHandler().getServletContext(); if (ctx==null) return getHeldClass().newInstance(); return ((ServletContextHandler.Context)ctx).createServlet(getHeldClass()); } catch (ServletException se) { Throwable cause = se.getRootCause(); if (cause instanceof InstantiationException) throw (InstantiationException)cause; if (cause instanceof IllegalAccessException) throw (IllegalAccessException)cause; throw se; } } }
/** * @return the newly created Servlet instance * @throws ServletException * @throws IllegalAccessException * @throws InstantiationException */ protected Servlet newInstance() throws ServletException, IllegalAccessException, InstantiationException { try { ServletContext ctx = getServletHandler().getServletContext(); if (ctx instanceof ServletContextHandler.Context) return ((ServletContextHandler.Context)ctx).createServlet(getHeldClass()); return getHeldClass().newInstance(); } catch (ServletException se) { Throwable cause = se.getRootCause(); if (cause instanceof InstantiationException) throw (InstantiationException)cause; if (cause instanceof IllegalAccessException) throw (IllegalAccessException)cause; throw se; } }
/** * @return the newly created Servlet instance * @throws ServletException * @throws IllegalAccessException * @throws InstantiationException */ protected Servlet newInstance() throws ServletException, IllegalAccessException, InstantiationException { try { ServletContext ctx = getServletHandler().getServletContext(); if (ctx==null) return getHeldClass().newInstance(); return ((ServletContextHandler.Context)ctx).createServlet(getHeldClass()); } catch (ServletException se) { Throwable cause = se.getRootCause(); if (cause instanceof InstantiationException) throw (InstantiationException)cause; if (cause instanceof IllegalAccessException) throw (IllegalAccessException)cause; throw se; } } }
if (holder.getClassName()==null && holder.getHeldClass()==null)
if (holder.getClassName()==null && holder.getHeldClass()==null)
@Override protected void configureServlets() { // We add servlets here to override the DefaultServlet automatic registered by WebAppContext // in path "/" with our WaveClientServlet. Any other way to do this? // Related question (unanswered 08-Apr-2011) // http://web.archiveorange.com/archive/v/d0LdlXf1kN0OXyPNyQZp for (Pair<String, ServletHolder> servlet : servletRegistry) { String url = servlet.getFirst(); @SuppressWarnings("unchecked") Class<HttpServlet> clazz = (Class<HttpServlet>) servlet.getSecond().getHeldClass(); Map<String,String> params = servlet.getSecond().getInitParameters(); serve(url).with(clazz,params); bind(clazz).in(Singleton.class); } for (Pair<String, Class<? extends Filter>> filter : filterRegistry) { filter(filter.first).through(filter.second); } } };
/** * @since servlet-api-3.0 */ @Override public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) { if (!isStarting()) throw new IllegalStateException(); if (!_enabled) throw new UnsupportedOperationException(); final ServletHandler handler = ServletContextHandler.this.getServletHandler(); ServletHolder holder = handler.getServlet(servletName); if (holder == null) { holder = handler.newServletHolder(Holder.Source.JAVAX_API); holder.setName(servletName); holder.setServlet(servlet); handler.addServlet(holder); return dynamicHolderAdded(holder); } //complete a partial registration if (holder.getClassName()==null && holder.getHeldClass()==null) { holder.setServlet(servlet); return holder.getRegistration(); } else return null; //existing completed registration for servlet name }
if (holder.getClassName()==null && holder.getHeldClass()==null)
if (holder.getClassName()==null && holder.getHeldClass()==null)
/** * @since servlet-api-3.0 */ @Override public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) { if (!isStarting()) throw new IllegalStateException(); if (!_enabled) throw new UnsupportedOperationException(); //TODO handle partial registrations final ServletHandler handler = ServletContextHandler.this.getServletHandler(); ServletHolder holder = handler.getServlet(servletName); if (holder == null) { holder = handler.newServletHolder(Holder.Source.JAVAX_API); holder.setName(servletName); holder.setServlet(servlet); handler.addServlet(holder); return dynamicHolderAdded(holder); } //complete a partial registration if (holder.getClassName()==null && holder.getHeldClass()==null) { holder.setServlet(servlet); return holder.getRegistration(); } else return null; //existing completed registration for servlet name }
if (holder.getClassName()==null && holder.getHeldClass()==null)
/** * @since servlet-api-3.0 */ @Override public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) { if (!isStarting()) throw new IllegalStateException(); if (!_enabled) throw new UnsupportedOperationException(); final ServletHandler handler = ServletContextHandler.this.getServletHandler(); ServletHolder holder = handler.getServlet(servletName); if (holder == null) { holder = handler.newServletHolder(Holder.Source.JAVAX_API); holder.setName(servletName); holder.setServlet(servlet); handler.addServlet(holder); return dynamicHolderAdded(holder); } //complete a partial registration if (holder.getClassName()==null && holder.getHeldClass()==null) { holder.setServlet(servlet); return holder.getRegistration(); } else return null; //existing completed registration for servlet name }
/** * @since servlet-api-3.0 */ @Override public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) { if (!isStarting()) throw new IllegalStateException(); if (!_enabled) throw new UnsupportedOperationException(); final ServletHandler handler = ServletContextHandler.this.getServletHandler(); ServletHolder holder = handler.getServlet(servletName); if (holder == null) { holder = handler.newServletHolder(Holder.Source.JAVAX_API); holder.setName(servletName); holder.setServlet(servlet); handler.addServlet(holder); return dynamicHolderAdded(holder); } //complete a partial registration if (holder.getClassName()==null && holder.getHeldClass()==null) { holder.setServlet(servlet); return holder.getRegistration(); } else return null; //existing completed registration for servlet name }
/** * @since servlet-api-3.0 */ @Override public ServletRegistration.Dynamic addServlet(String servletName, String className) { if (!isStarting()) throw new IllegalStateException(); if (!_enabled) throw new UnsupportedOperationException(); final ServletHandler handler = ServletContextHandler.this.getServletHandler(); ServletHolder holder = handler.getServlet(servletName); if (holder == null) { //new servlet holder = handler.newServletHolder(Holder.Source.JAVAX_API); holder.setName(servletName); holder.setClassName(className); handler.addServlet(holder); return dynamicHolderAdded(holder); } //complete a partial registration if (holder.getClassName()==null && holder.getHeldClass()==null) { holder.setClassName(className); return holder.getRegistration(); } else return null; //existing completed registration for servlet name }
/** * @since servlet-api-3.0 */ @Override public ServletRegistration.Dynamic addServlet(String servletName, String className) { if (!isStarting()) throw new IllegalStateException(); if (!_enabled) throw new UnsupportedOperationException(); final ServletHandler handler = ServletContextHandler.this.getServletHandler(); ServletHolder holder = handler.getServlet(servletName); if (holder == null) { //new servlet holder = handler.newServletHolder(Holder.Source.JAVAX_API); holder.setName(servletName); holder.setClassName(className); handler.addServlet(holder); return dynamicHolderAdded(holder); } //complete a partial registration if (holder.getClassName()==null && holder.getHeldClass()==null) { holder.setClassName(className); return holder.getRegistration(); } else return null; //existing completed registration for servlet name }
if (holder.getClassName()==null && holder.getHeldClass()==null)