public void contextInitialized(ServletContextEvent event) { super.contextInitialized(event); WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()); IFunctionService resourceService = (IFunctionService) wac.getBean("functionService"); resourceService.findAllUrl(); event.getServletContext().setAttribute(Constants.APP_MANAGER_THEME, "default"); }
protected void setUp() throws Exception { super.setUp(); sc = new MockServletContext(""); // initialize Spring sc.addInitParameter( ContextLoader.CONFIG_LOCATION_PARAM, "classpath:/applicationContext-dao.xml, " + "classpath:/applicationContext-service.xml, " + "classpath:/applicationContext-resources.xml"); springListener = new ContextLoaderListener(); springListener.contextInitialized(new ServletContextEvent(sc)); listener = new StartupListener(); }
@Override public void contextInitialized(ServletContextEvent sce) { File app = Env.getDefaultEnvFile(); File keyStore = InstallUtils.getKeyStore(); Map<String, String> propertiesMap = KeyUtils.getMapProperties(app, keyStore); ConfigContainer.putAll(propertiesMap); File xmlProp = InstallUtils.getXmlEnv(); if (!ConfigContainer.isAppInstalled() && xmlProp.exists()) { Map<String, String> settings = EnvironmentsUtils.convertFromXml(xmlProp); ConfigContainer.putAll(settings); } File propFile = InstallUtils.getPropEnv(); if (!ConfigContainer.isAppInstalled() && propFile.exists()) { ConfigContainer.putAll(MiscUtils.getProperties(propFile)); } if (!xmlProp.exists()) { if (!OpenFlameConfig.DOMAIN_URL.exist()) OpenFlameConfig.DOMAIN_URL.setValue(TomcatUtils.getCatalinaHost(sce)); if (!OpenFlameConfig.PORT.exist()) OpenFlameConfig.PORT.setValue(TomcatUtils.getCatalinaPort(sce).toString()); if (!OpenFlameConfig.CONTEXT_URL.exist()) OpenFlameConfig.CONTEXT_URL.setValue(TomcatUtils.getCatalinaContext(sce)); } String domainUrl = OpenFlameConfig.DOMAIN_URL.getValue(); String port = OpenFlameConfig.PORT.getValue(); String contextUrl = OpenFlameConfig.CONTEXT_URL.getValue(); if (domainUrl != null && port != null && contextUrl != null) { Env.FIREJACK_URL.setValue(WebUtils.getNormalizedUrl(domainUrl, port, contextUrl)); } ConfigContainer.setHost(TomcatUtils.getCatalinaHost(sce)); ConfigContainer.setPort(TomcatUtils.getCatalinaPort(sce)); super.contextInitialized(sce); }
@Override public void contextInitialized(ServletContextEvent event) { ApplicationHelper.changeLogLvl(); super.contextInitialized(event); }
public void contextInitialized(ServletContextEvent event) { if (log.isDebugEnabled()) { log.debug("initializing context..."); } // call Spring's context ContextLoaderListener to initialize // all the context files specified in web.xml super.contextInitialized(event); ServletContext context = event.getServletContext(); // Orion starts Servlets before Listeners, so check if the config // object already exists Map config = (HashMap) context.getAttribute(Constants.CONFIG); if (config == null) { config = new HashMap(); } if (context.getInitParameter(Constants.CSS_THEME) != null) { config.put(Constants.CSS_THEME, context.getInitParameter(Constants.CSS_THEME)); } ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); boolean encryptPassword = false; try { ProviderManager provider = (ProviderManager) ctx.getBean("authenticationManager"); for (Iterator it = provider.getProviders().iterator(); it.hasNext(); ) { AuthenticationProvider p = (AuthenticationProvider) it.next(); if (p instanceof RememberMeAuthenticationProvider) { config.put("rememberMeEnabled", Boolean.TRUE); } } if (ctx.containsBean("passwordEncoder")) { encryptPassword = true; config.put(Constants.ENCRYPT_PASSWORD, Boolean.TRUE); String algorithm = "SHA"; if (ctx.getBean("passwordEncoder") instanceof Md5PasswordEncoder) { algorithm = "MD5"; } config.put(Constants.ENC_ALGORITHM, algorithm); } } catch (NoSuchBeanDefinitionException n) { // ignore, should only happen when testing } context.setAttribute(Constants.CONFIG, config); // output the retrieved values for the Init and Context Parameters if (log.isDebugEnabled()) { log.debug("Remember Me Enabled? " + config.get("rememberMeEnabled")); log.debug("Encrypt Passwords? " + encryptPassword); if (encryptPassword) { log.debug("Encryption Algorithm: " + config.get(Constants.ENC_ALGORITHM)); } log.debug("Populating drop-downs..."); } setupContext(context); }
@Override public void contextInitialized(ServletContextEvent event) { System.out.println("初始化系统的上下文,初始化所有的bean"); super.contextInitialized(event); }