strust2中是如何初始化container并且使其全局单例?
StrutsPrepareAndExecuteFilter
protected PrepareOperations prepare;
protected ExecuteOperations execute;
Dispatcher dispatcher = init.initDispatcher(config);
init()
Container container = init_PreloadConfiguration();
private Container init_PreloadConfiguration() {
Configuration config = configurationManager.getConfiguration();
Container container = config.getContainer();
boolean reloadi18n = Boolean.valueOf(container.getInstance(String.class, StrutsConstants.STRUTS_I18N_RELOAD));
LocalizedTextUtil.setReloadBundles(reloadi18n);
return container;
}
Configuration config = configurationManager.getConfiguration();
Container container = config.getContainer();
public synchronized Configuration getConfiguration() {
if (configuration == null) {
setConfiguration(createConfiguration(defaultFrameworkBeanName));
try {
configuration.reloadContainer(getContainerProviders());
} catch (ConfigurationException e) {
setConfiguration(null);
throw new ConfigurationException("Unable to load configuration.", e);
}
} else {
conditionalReload(configuration.getContainer());
}
return configuration;
}
....
prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher);
execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher);
分享到:
相关推荐
Spring 框架是一个开源的Java企业级应用开发框架,由Rod Johnson在其著作《Expert One-on-One J2EE Design and Development》中首次提出。它的设计理念是简化Java应用程序的开发,通过控制反转(IoC)和面向切面编程...
IoC或依赖注入减少了应用程序代码量,使其更易于测试,无需使用单例和JNDI查找机制。它还降低了对象之间的耦合度,使系统更加灵活。此外,IoC容器支持按需初始化和懒加载。 #### 12. ApplicationContext常见实现 -...
Struts 1.x和Struts 2.x是其两个主要版本,其中Struts 2更加强大,支持更多的特性如拦截器、类型转换等。 - **Struts 1.x**:主要关注于Servlet/JavaServer Pages技术,使用ActionServlet作为中心控制器。 - **...
1. 单例模式(Singleton):单例模式确保一个类只有一个实例,并提供全局访问点。在Java中,可以使用双重检查锁定(Double-Checked Locking)或者静态内部类方式实现单例,以保证线程安全并避免性能损失。 2. 工厂...
SpringBean的生命周期包括初始化、运行时和销毁三个阶段。开发者可以通过实现特定的方法或使用注解来定制Bean的生命周期行为。 #### 9. Bean的作用域 - **singleton**:在整个Spring容器中只存在一个实例。 - **...
与cgi的区别在于servlet处于服务器进程中,它通过多线程方式运行其service方法,一个实例可以服务于多个请求,并且其实例一般不会销毁,而CGI对每个请求都产生新的进程,服务完成后就销毁,所以效率上低于servlet。...
- **Rod Johnson**,被誉为“Spring之父”,在其著作《Expert One-to-One J2EE Design and Development》中阐述了 J2EE 使用 EJB 的优点及解决方案,在后续的《Expert One-to-One J2EE Development without EJB》中...
与cgi的区别在于servlet处于服务器进程中,它通过多线程方式运行其service方法,一个实例可以服务于多个请求,并且其实例一般不会销毁,而CGI对每个请求都产生新的进程,服务完成后就销毁,所以效率上低于servlet。...
- **类加载过程:** 加载、验证、准备、解析和初始化五个阶段。 - **双亲委派模型:** 由顶层的启动类加载器向下委托加载任务。 **7. 内存模型** - **堆内存:** 存储对象实例。 - **栈内存:** 存储局部变量等。 ...