Topic: Distributed servlet.

  Print this page

1.Distributed servlet. Copy to clipboard
Posted by: didongusa
Posted on: 2004-08-12 01:11

If a servlet implementes SingleThreadedModel and deployed to distributed web app, I wander the container is going to pool them in every JVM or just one. The container must pool them or not?
If my container do not pool them, when client send a request, how container handle the request?

Really need the answer.

2.Re:Distributed servlet. [Re: didongusa] Copy to clipboard
Posted by: floater
Posted on: 2004-08-12 04:25

SingleThreadedModel is a broken one, don't use it.

Check Jason's Oreilly's book(... best practice, or Rod's book, expert ... without EJB).

3.Re:Distributed servlet. [Re: didongusa] Copy to clipboard
Posted by: ringayumi
Posted on: 2004-08-12 08:49

As far as I know , When the container receive a request , and that have to generate a new instance to handle it.

4.Re:Distributed servlet. [Re: didongusa] Copy to clipboard
Posted by: emarket
Posted on: 2004-08-14 10:43

1. 没有SingleThreadedModel这个interface!. 只有 SingleThreadModel这个interface
2. servlet规范(2.4)里面有很详细的关于SingleThreadInterface 的描述

SRV.2.2 Number of Instances
The servlet declaration which is part of the deployment descriptor of theWeb application
containing the servlet, as described in Chapter SRV.13, “Deployment
Descriptor”, controls how the servlet container provides instances of the servlet.
For a servlet not hosted in a distributed environment (the default), the servlet
container must use only one instance per servlet declaration. However, for a servlet
implementing the SingleThreadModel interface, the servlet container may
instantiate multiple instances to handle a heavy request load and serialize requests to a particular instance.

In the case where a servlet was deployed as part of an application marked in
the deployment descriptor as distributable, a container may have only one instance
per servlet declaration per Java Virtual Machine (JVMTM). However, if the servlet
in a distributable application implements the SingleThreadModel interface, the
container may instantiate multiple instances of that servlet in each JVM of the
container.

SRV.2.2.1 Note About The Single Thread Model
The use of the SingleThreadModel interface guarantees that only one thread at a
time will execute in a given servlet instance’s service method. It is important to
note that this guarantee only applies to each servlet instance, since the container
may choose to pool such objects. Objects that are accessible to more than one servlet
instance at a time, such as instances of HttpSession, may be available at any particular
time to multiple servlets, including those that implement
SingleThreadModel.
It is recommended that a developer take other means to resolve those issues instead
of implementing this interface, such as avoiding the usage of an instance variable or
synchronizing the block of the code accessing those resources. The
SingleThreadModel Interface is deprecated in this version of the specification.

三句话 概括, 1. 是不是pool 是 container 自己的事, 规范用了“ may ”, 所以可以不pool 也可以pool .
2. 如果 pool, 规范又说了"may", 所以也有可能只在一个container
pool 哦。
2. 如果不pool, request来了就等,直到timeout了。

BTW: 规范一样建议不要用SingleThreadModel

didongusa wrote:
If a servlet implementes SingleThreadedModel and deployed to distributed web app, I wander the container is going to pool them in every JVM or just one. The container must pool them or not?
If my container do not pool them, when client send a request, how container handle the request?
Really need the answer.


5.Re:Distributed servlet. [Re: didongusa] Copy to clipboard
Posted by: didongusa
Posted on: 2004-08-15 12:58

Thanks.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923