staunch
BlogJava
首页
新随笔
联系
聚合
管理
随笔-0 评论-0 文章-9 trackbacks-0
WebAdapterServlet 的运行机制(1)
WebAdapterServlet 类将普通基于Servlet的开发变为了基于事件的开发,所以理清它的运行机制对于理解Millstone的运作情况非常重要。
类中的域:
private
Class applicationClass;
private
Properties applicationProperties;
private
UIDLTransformerFactory transformerFactory;
private
CollectionThemeSource themeSource;
private
String resourcePath
=
null
;
//
private boolean enableBrowserProbe = false;
private
boolean debugMode
=
false
;
private
int
maxConcurrentTransformers;
private
long
transformerCacheTime;
private
long
themeCacheTime;
private
WeakHashMap applicationToDirtyWindowSetMap
=
new
WeakHashMap();
private
WeakHashMap applicationToServerCommandStreamLock
=
new
WeakHashMap();
private
WeakHashMap applicationToLastRequestDate
=
new
WeakHashMap();
private
List allWindows
=
new
LinkedList();
1. init()
String applicationClassName
=
servletConfig.getInitParameter(
"
application
"
);
从web.xml中得到运行的application 的类名
this.applicationProperties = new Properties();
for (Enumeration e = servletConfig.getInitParameterNames();
e.hasMoreElements();
) {
String name = (String) e.nextElement();
this.applicationProperties.setProperty(
name,
servletConfig.getInitParameter(name));
}
将所有的web中的参数转移到applicationProperties中,以便使用.
ServletContext context
=
servletConfig.getServletContext();
for
(Enumeration e
=
context.getInitParameterNames();
e.hasMoreElements();
)
{
String name
=
(String) e.nextElement();
this
.applicationProperties.setProperty(
name,
context.getInitParameter(name));
}
得到servelt的initparameter覆盖web.xml中的参数.
//
Get the debug window parameter
String debug
=
getApplicationOrSystemProperty(PARAMETER_DEBUG,
"
false
"
);
//
Enable application specific debug
this
.debugMode
=
debug.equals(
"
true
"
);
从application中或system 确定是否为debug 状态
//
Add all specified theme sources
this
.themeSource
=
new
CollectionThemeSource();
List directorySources
=
getThemeSources();
for
(Iterator i
=
directorySources.iterator(); i.hasNext();)
{
this
.themeSource.add((ThemeSource) i.next());
}
增加指定的主题
//
Add the default theme source
String defaultThemeJar
=
getApplicationOrSystemProperty(
PARAMETER_DEFAULT_THEME_JAR,
DEFAULT_THEME_JAR);
File f
=
findDefaultThemeJar(defaultThemeJar);
try
{
//
Add themes.jar if exists
if
(f
!=
null
&&
f.exists())
this
.themeSource.add(
new
JarThemeSource(f,
this
,
""
));
else
{
Log.warn(
"
Default theme JAR not found:
"
+
defaultThemeJar);
}
}
catch
(Exception e)
{
throw
new
ServletException(
"
Failed to load default theme from
"
+
defaultThemeJar,
e);
}
增加默任的主题
ClassLoader loader
=
this
.getClass().getClassLoader();
try
{
this
.applicationClass
=
loader.loadClass(applicationClassName);
}
catch
(ClassNotFoundException e)
{
throw
new
ServletException(
"
Failed to load application class:
"
+
applicationClassName);
}
最后是装载application的类.
posted on 2005-08-05 17:00
staunch
阅读(134)
评论(0)
编辑
收藏
新用户注册
刷新评论列表
只有注册用户
登录
后才能发表评论。
网站导航:
博客园
IT新闻
Chat2DB
C++博客
博问
管理
<
2025年7月
>
日
一
二
三
四
五
六
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
留言簿
给我留言
查看公开留言
查看私人留言
文章档案
2005年9月 (1)
2005年8月 (7)
2005年7月 (1)
搜索
最新评论