staunch
BlogJava
首页
新随笔
联系
聚合
管理
随笔-0 评论-0 文章-9 trackbacks-0
WebAdapterServlet 运行机制(2)
WebAdapterServlet 运行机制(2)
LinkedList applications
=
(LinkedList) session.getAttribute(SESSION_ATTR_APPS);
if
(applications
==
null
)
return
null
;
//
Search for the application (using the application URI) from the list
Application application
=
null
;
for
(Iterator i
=
applications.iterator();
i.hasNext()
&&
application
==
null
;
)
{
Application a
=
(Application) i.next();
String aPath
=
a.getURL().getPath();
String servletPath
=
request.getContextPath()
+
request.getServletPath();
if
(servletPath.length()
<
aPath.length())
servletPath
+=
"
/
"
;
if
(servletPath.equals(aPath))
application
=
a;
}
//
Remove stopped applications from the list
if
(application
!=
null
&&
!
application.isRunning())
{
applications.remove(application);
application
=
null
;
}
根据request 得到适当的application,如果为第一次请求则建立一个application
application
=
createApplication(request);
详细过程如下:
URL applicationUrl
=
getApplicationUrl(request);
创建session 中的applications.
//
Get application list.
HttpSession session
=
request.getSession();
if
(session
==
null
)
return
null
;
LinkedList applications
=
(LinkedList) session.getAttribute(SESSION_ATTR_APPS);
if
(applications
==
null
)
{
applications
=
new
LinkedList();
session.setAttribute(SESSION_ATTR_APPS, applications);
HttpSessionBindingListener sessionBindingListener
=
new
SessionBindingListener(applications);
session.setAttribute(
SESSION_BINDING_LISTENER,
sessionBindingListener);
}
初始化并启动
application
=
(Application)
this
.applicationClass.newInstance();
applications.add(application);
application.addListener((Application.WindowAttachListener)
this
);
application.addListener((Application.WindowDetachListener)
this
);
application.setLocale(request.getLocale());
application.start(
applicationUrl,
this
.applicationProperties,
new
WebApplicationContext(session));
启动过程非常简单,设置变量,并调用application.init()
public
void
start(URL applicationUrl, Properties applicationProperties, ApplicationContext context)
{
this
.applicationUrl
=
applicationUrl;
this
.properties
=
applicationProperties;
this
.context
=
context;
init();
applicationIsRunning
=
true
;
}
posted on 2005-08-05 18:43
staunch
阅读(175)
评论(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)
搜索
最新评论