List of usage examples for javax.servlet ServletConfig getServletContext
public ServletContext getServletContext();
From source file:com.predic8.membrane.servlet.embedded.MembraneServlet.java
@Override public void init(ServletConfig config) throws ServletException { try {//ww w. j av a 2 s . c o m appCtx = new BaseLocationXmlWebApplicationContext(); log.debug("loading beans configuration from: " + getProxiesXmlLocation(config)); router = RouterUtil.initializeRoutersFromSpringWebContext(appCtx, config.getServletContext(), getProxiesXmlLocation(config)); if (router == null) throw new RuntimeException( "No <router> with a <servletTransport> was found. To use <router> with <transport>, use MembraneServletContextListener instead of MembraneServlet."); } catch (Exception e) { throw new ServletException(e); } }
From source file:it.marcoberri.mbfasturl.cron.QuartzInitServlet.java
/** * /*from w w w.j a va 2 s. c o m*/ * @param cfg * @throws javax.servlet.ServletException */ @Override public void init(ServletConfig cfg) throws javax.servlet.ServletException { super.init(cfg); this.application = cfg.getServletContext(); StdSchedulerFactory schedulerFactory = null; final String shutdownPref = cfg.getInitParameter("shutdown-on-unload"); if (shutdownPref != null) { performShutdown = Boolean.valueOf(shutdownPref).booleanValue(); } final Properties prop = new Properties(); prop.setProperty("org.quartz.scheduler.instanceName", "OsQuarz_mbfasturl2"); prop.setProperty("org.quartz.scheduler.instanceId", "" + System.nanoTime()); prop.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore"); prop.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); prop.setProperty("org.quartz.threadPool.threadCount", "1"); Commons.log.debug("Init Schduler"); try { schedulerFactory = new StdSchedulerFactory(prop); scheduler = schedulerFactory.getScheduler(); // StartUp Commons.log.debug("configure : StartUp"); final Iterator<JSONObject> iterator = ConfigurationHelper.getCron().iterator(); while (iterator.hasNext()) { final JSONObject c = iterator.next(); final String name = Default.toString(c.get("name")); Commons.log.debug("name:" + name); final String clazz = Default.toString(c.get("class")); Commons.log.debug("clazz:" + clazz); final Boolean enable = Default.toBoolean(c.get("enable")); Commons.log.debug("enable:" + enable); final String cronTab = Default.toString(c.get("cron")); Commons.log.debug("cronTab:" + cronTab); if (!enable) { Commons.log.info(name + " enbale:" + enable); continue; } try { final Class classForCron = Class.forName(clazz); Commons.log.debug("start configure:" + name); final JobDetail job = JobBuilder.newJob(classForCron).withIdentity("job" + name, "group" + name) .build(); final Trigger trigger = TriggerBuilder.newTrigger() .withIdentity("trigger" + name, "group" + name) .withSchedule(CronScheduleBuilder.cronSchedule(cronTab)).build(); scheduler.scheduleJob(job, trigger); } catch (ClassNotFoundException ex) { Commons.log.fatal(ex); } } scheduler.start(); application.setAttribute(QUARTZ_FACTORY_KEY, schedulerFactory); Commons.log.debug("cron started :" + QUARTZ_FACTORY_KEY); } catch (SchedulerException ex) { Commons.log.fatal("Fatal conf Job", ex); } }
From source file:org.wso2.carbon.governance.custom.lifecycles.checklist.ui.clients.LifecycleServiceClient.java
public LifecycleServiceClient(ServletConfig config, HttpSession session) throws RegistryException { String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); epr = backendServerURL + "CustomLifecyclesChecklistAdminService"; try {/*from www .j av a 2 s . c o m*/ stub = new CustomLifecyclesChecklistAdminServiceStub(configContext, epr); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault axisFault) { String msg = "Failed to initiate lifecycles service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:org.apache.stratos.tenant.activity.ui.clients.TenantActivityServiceClient.java
public TenantActivityServiceClient(ServletConfig config, HttpSession session) throws RegistryException { String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); epr = backendServerURL + "TenantActivityService"; try {// w w w .ja v a2 s .c o m stub = new TenantActivityServiceStub(configContext, epr); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault axisFault) { String msg = "Failed to initiate TenantMonitorService service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:org.infoscoop.web.InitializeServlet.java
/** * <P>initialize the servlet.</P><BR> * It is a precondition to operate a servlet that a file of DAO setting (/WEB-INF/conf/dao-config.xml) is set definitely. *///from w w w .j a v a 2 s.co m public void init(ServletConfig config) throws ServletException { initLog4jProperties(config); //loadDAOConfig(config); initVelocity(config); ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext()); SpringUtil.setContext(ctx); initSearchUserService(); Security.setProperty("networkaddress.cache.ttl", "60"); }
From source file:com.expressui.core.util.SpringApplicationServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); log.debug("initializing SpringApplicationServlet"); try {/* w w w . j a va 2 s. c o m*/ webApplicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(servletConfig.getServletContext()); } catch (IllegalStateException e) { throw new ServletException(e); } }
From source file:de.fhg.igd.vaadin.util.servlets.AutowiringApplicationServlet.java
/** * Initialize this servlet./*from w w w . j a v a2 s .c o m*/ * * @throws ServletException if there is no {@link WebApplicationContext} associated with this servlet's context */ @Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); // initApplicationClass(servletConfig); try { webApplicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(servletConfig.getServletContext()); } catch (final IllegalStateException e) { throw new ServletException("could not locate containing WebApplicationContext"); } }
From source file:org.apache.stratos.tenant.activity.ui.clients.TenantActivityServiceClient.java
public TenantActivityServiceClient(String url, ServletConfig config, HttpSession session) throws Exception { //String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); try {//from w w w .java 2 s . co m String cookie = login(url + "/services/", TenantActivityUIServiceComponent.stratosConfiguration.getAdminUserName(), TenantActivityUIServiceComponent.stratosConfiguration.getAdminPassword(), configContext); epr = url + "/services/TenantActivityService"; stub = new TenantActivityServiceStub(configContext, epr); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault axisFault) { String msg = "Failed to initiate TenantMonitorService service client. "; log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }
From source file:org.apache.cocoon.auth.impl.StandardApplicationManager.java
/** * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context) *///from ww w .j av a 2 s . c o m public void contextualize(final Context aContext) throws ContextException { this.context = aContext; try { ServletConfig config = (ServletConfig) this.context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG); config.getServletContext().setAttribute(StandardApplicationManager.class.getName(), this); } catch (ContextException ignore) { // we ignore this if we are not running inside a servlet environment } }
From source file:org.wso2.carbon.registry.search.ui.clients.SearchServiceClient.java
public SearchServiceClient(String cookie, ServletConfig config, HttpSession session) throws RegistryException { this.session = session; String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session); ConfigurationContext configContext = (ConfigurationContext) config.getServletContext() .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT); epr = backendServerURL + "SearchAdminService"; try {//from w w w. j a va 2 s . c om stub = new SearchAdminServiceStub(configContext, epr); ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); } catch (AxisFault axisFault) { String msg = "Failed to initiate search service client. " + axisFault.getMessage(); log.error(msg, axisFault); throw new RegistryException(msg, axisFault); } }