/** * @see AppContext#getServletContext() */ public static javax.servlet.ServletContext servletContext() throws IllegalStateException { return current().getServletContext(); }
protected boolean initHomeDirectoryFromWebapp() throws Throwable { if(context.isServletEnvironment()){ ServletResource r = Servlets.getResource(context.getServletContext(), "/WEB-INF"); if(r.exists() && r.isFile()){ dir = Resources.createFileResource(r.getFile()); //project // /src/main/webapp/WEB-INF // /target/classes if(dir.createRelative("../../../../target/classes").exists()){ dir = dir.createRelative("../../../../target"); } return true; } } return false; }
protected void doBeanAware(BeanDefinitionBase bd,Object bean){ if(bean instanceof ServletContextAware){ if(appContext.isServletEnvironment()){ ((ServletContextAware) bean).setServletContext(appContext.getServletContext()); } } if(bean instanceof BeanFactoryAware){ ((BeanFactoryAware) bean).setBeanFactory(beanFactory); } if(bean instanceof AppContextAware){ ((AppContextAware) bean).setAppContext(appContext); } if(bean instanceof AppConfigAware){ ((AppConfigAware) bean).setAppConfig(appContext.getConfig()); } //TODO : check the bean name is empty? if(bean instanceof BeanNameAware){ ((BeanNameAware) bean).setBeanName(bd.getName()); } if(bean instanceof BeanPrimaryAware) { ((BeanPrimaryAware) bean).setBeanPrimary(bd.isPrimary()); } }