/** * Initialize the wrapped Servlet instance. * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) */ @Override public void afterPropertiesSet() throws Exception { if (this.servletClass == null) { throw new IllegalArgumentException("'servletClass' is required"); } if (this.servletName == null) { this.servletName = this.beanName; } this.servletInstance = ReflectionUtils.accessibleConstructor(this.servletClass).newInstance(); this.servletInstance.init(new DelegatingServletConfig()); }
@Override public void init(ServletConfig config) throws ServletException { wrappedServlet.init(new ServletConfigWrapper(config)); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof Servlet) { ServletConfig config = this.servletConfig; if (config == null || !this.useSharedServletConfig) { config = new DelegatingServletConfig(beanName, this.servletContext); } try { ((Servlet) bean).init(config); } catch (ServletException ex) { throw new BeanInitializationException("Servlet.init threw exception", ex); } } return bean; }
/** * Initialize the wrapped Servlet instance. * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) */ @Override public void afterPropertiesSet() throws Exception { if (this.servletClass == null) { throw new IllegalArgumentException("'servletClass' is required"); } if (this.servletName == null) { this.servletName = this.beanName; } this.servletInstance = ReflectionUtils.accessibleConstructor(this.servletClass).newInstance(); this.servletInstance.init(new DelegatingServletConfig()); }
/** * Initialize the {@link Filter} * * @throws javax.servlet.ServletException */ public void init() throws ServletException { for (FilterConfigImpl f : filters) { if (f != null) { f.getFilter().init(f); } } if (servlet != null) { servlet.init(configImpl); } }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof Servlet) { ServletConfig config = this.servletConfig; if (config == null || !this.useSharedServletConfig) { config = new DelegatingServletConfig(beanName, this.servletContext); } try { ((Servlet) bean).init(config); } catch (ServletException ex) { throw new BeanInitializationException("Servlet.init threw exception", ex); } } return bean; }
@Override protected void doPortalInit() throws Exception { ServletContext servletContext = servletConfig.getServletContext(); ClassLoader classLoader = (ClassLoader)servletContext.getAttribute( PluginContextListener.PLUGIN_CLASS_LOADER); String servletClass = servletConfig.getInitParameter("servlet-class"); servlet = (Servlet)InstanceFactory.newInstance( classLoader, servletClass); servlet.init(servletConfig); }
public void setServletConfig(ServletConfig servletConfig) { try { shadowCxfServlet = (Servlet)servletClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } try { shadowCxfServlet.init(servletConfig); } catch (ServletException ex) { throw new RuntimeException(ex.getMessage(), ex); } }
servlet.init(new MockServletConfig(servletContext, "myHandler"));
@Override protected void doPortalInit() throws Exception { ServletContext servletContext = servletConfig.getServletContext(); ClassLoader classLoader = (ClassLoader)servletContext.getAttribute( PluginContextListener.PLUGIN_CLASS_LOADER); String servletClass = servletConfig.getInitParameter("servlet-class"); _subcontext = servletConfig.getInitParameter("sub-context"); if (_subcontext == null) { _subcontext = getServletName(); } servlet = (Servlet)InstanceFactory.newInstance( classLoader, servletClass); if (!(servlet instanceof HttpServlet)) { throw new IllegalArgumentException( "servlet-class is not an instance of " + HttpServlet.class.getName()); } servlet.init(servletConfig); PortalDelegatorServlet.addDelegate(_subcontext, (HttpServlet)servlet); }
private static Servlet getServlet( String cbClassName, String dataSourceText, Map<List<String>, Servlet> cache) throws ServletException { final List<String> key = Collections.singletonList( dataSourceText); Servlet servlet = cache.get(key); if (servlet != null) { return servlet; } MockServletContext servletContext = new MockServletContext(); MockServletConfig servletConfig = new MockServletConfig(servletContext); servletConfig.addInitParameter( XmlaServlet.PARAM_CALLBACKS, cbClassName); servletConfig.addInitParameter( XmlaServlet.PARAM_CHAR_ENCODING, "UTF-8"); servletConfig.addInitParameter( XmlaServlet.PARAM_DATASOURCES_CONFIG, "inline:" + dataSourceText); servlet = new MondrianXmlaServlet(); servlet.init(servletConfig); if (cache != null) { cache.put(key, servlet); } return servlet; }
@Override public void init(ServletConfig config) throws ServletException { displayChart.init(config); }
public void setServletConfig(ServletConfig servletConfig) { try { shadowCxfServlet = (Servlet)servletClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } try { shadowCxfServlet.init(servletConfig); } catch (ServletException ex) { throw new RuntimeException(ex.getMessage(), ex); } }
@Override public void init(final ServletConfig config) throws ServletException { super.init(config); dispatcherServlet.init(config); getHttpServiceController().register(config.getServletContext(), serviceRegProps); }
public void update(Servlet servlet, Collection<BasicRequestHandler> basicRequestHandlers){ try { servlet.init(this.servlet.getServletConfig()); } catch (ServletException e) { throw new RuntimeException(e); } this.servlet=servlet; this.basicRequestHandler = basicRequestHandlers==null? Collections.emptyList():new ArrayList<>(basicRequestHandlers); }
synchronized Servlet getServlet() throws ClassNotFoundException, InstantiationException, IllegalAccessException, ServletException { if (_servlet == null) { Class servletClass = Class.forName( getClassName() ); _servlet = (Servlet) servletClass.newInstance(); String servletName = _servletName != null ? _servletName : _servlet.getClass().getName(); _servlet.init( new ServletUnitServletConfig( servletName, WebApplication.this, getInitParams() ) ); } return _servlet; }
synchronized Servlet getServlet() throws ClassNotFoundException, InstantiationException, IllegalAccessException, ServletException { if (_servlet == null) { Class servletClass = Class.forName( getClassName() ); _servlet = (Servlet) servletClass.newInstance(); String servletName = _servletName != null ? _servletName : _servlet.getClass().getName(); _servlet.init( new ServletUnitServletConfig( servletName, WebApplication.this, getInitParams() ) ); } return _servlet; }
/** * Starts {@link Servlet} instance of this {@link OSGiServletHandler}. * * @throws ServletException If {@link Servlet} startup failed. */ public void startServlet() throws ServletException { configureServletEnv(); servletInstance.init(getServletConfig()); }
String jspClassName = findJspClassForJSP("your.jsp"); Class jspClass = Class.forName(jspClassName); Servlet jspServlet = (Servlet)jspClass.newInstance(); MyServletRequest req = new MyServletRequest(); MyServletResponse resp = new MyServletResponse(); jspServlet.init(); jspServlet.service(req, resp); jspServlet.destroy(); String results = reps.getContent();
@Override public void init() throws ServletException { String name = "servlet_" + getId(); ServletConfig config = new ServletConfigImpl(name, getContext(), getInitParams()); this.servlet.init(config); }