??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品美女久久久,久久久噜噜噜久久,亚洲自啪免费http://www.aygfsteel.com/flyffa/category/16807.htmlzh-cnWed, 28 Feb 2007 03:46:04 GMTWed, 28 Feb 2007 03:46:04 GMT60【web】面向对象的javascripthttp://www.aygfsteel.com/flyffa/archive/2006/12/28/90493.htmlflyffaflyffaThu, 28 Dec 2006 06:39:00 GMThttp://www.aygfsteel.com/flyffa/archive/2006/12/28/90493.htmlhttp://www.aygfsteel.com/flyffa/comments/90493.htmlhttp://www.aygfsteel.com/flyffa/archive/2006/12/28/90493.html#Feedback1http://www.aygfsteel.com/flyffa/comments/commentRss/90493.htmlhttp://www.aygfsteel.com/flyffa/services/trackbacks/90493.html 1.1. l承

今天遇到了需要在 javascript 中承的问题Q?/span>

查了一些帖子,自己又写了几个例子测试了一下,ȝ如下Q?/span>

1.1.1.     三种Ҏ(gu)

js 中实现承有三种Ҏ(gu)Q?/span>

假设父类?/span> Parent, 子类?/span> Child,

 

W一U,子类强制调用父类构?/span>

function Child(){

       Parent.call(this);

}

 

W二U,子类间接调用父类构?/span>

function Child(){

       this.base = Parent;

       this.base();

}

 

W三U:(x)讄原型

function Child(){}

Child.prototype = new Parent();

q种方式虽然不够直观Q却应该是最有效率的方式?/span>

 

1.1.2.     ȝQ?/font>

其实 js 本n是没有什么承之cȝ概念的,只是Z使用利用 js 的一些特性而加的?/span>

 

js 的原型方?/span> prototype, 使得许多的工作变得容易?/span>

 

一?/span> function 对象和根?/span> function 构造出来的对象是不同的?/span>

 

一?/span> function 对象的原型其实就是一个根?/span> function 对象构徏出来的对象?/span>

CQ这个对象可?/span> new 出来的对象不一栗在 function 内部的代码ƈ不会(x)被执行,如:(x)

this.funcName = function() q样的代码。?/span> new 出来的对象则不然Q他h执行后的对象Ҏ(gu)?/span>

 

function 的局部变量相当于 class 里的U有变量Q无法在子类中获取和操作。但 this. 的部分是可以的?/span>

 

1.1.3.     猜测和假?/font>

Q这是我推断的,没有M的根据,当然也是可以试的)Q?/span>

当一?/span> Child ?/span> new ӞW一二种Ҏ(gu)中, js 执行?/span>

1 、先分配一个空_(d)Q相当于 this = new Object() Q?/span> (msdn 中有具体的描q?/span> )

2 、拷贝原型:(x)

3 、执行构造:(x)也就?/span> Child.call(this) Q相当于 child(), 此时 this 对象有|Q?/span> msdn 中有描述Q?/span>

然后执行 Parent(); q个时?/span> parent 的构造函数执行以下几步:(x)

1 、将 parent ?/span> prototype 拯?/span> object 区域Q这时覆盖了前面的区?/span> ( 好像试证明 parent 的原型ƈ不会(x)被拷贝,此步不会(x)被执?/span> )

2 、对q个区域执行初始化,也就是正常的 function 调用的过E。(相当?/span> Parent(),this 变量有|

 

而普通的 function 调用应该是这个样子:(x)׃没有 new 操作W,所以没有ؓ(f)其分配当前的 this( 也没有空?/span> ),

this 被放C window 对象上。但?/span> new 的时候显然不是这栗?/span>

 

obj.func() 的调用和 func() 调用是完全不一L(fng)Q?/span> obj.func ?/span> this 对象?/span> obj 对象Q?/span> func() 调用 this 对象?/span> window 对象Q这个应该和 jvm 中静态方法和cd例方法调用的区别的原理一栗?/span>

 

1.2. Ҏ(gu)重蝲

在实C对象l承之后Q我开始面临到W二个问题,重蝲?/span>

1.1.4.     两种Ҏ(gu)

js 怎样实现重蝲?/span>

1 、简单的重蝲Q?/span>

在这U重载中Q子cȝҎ(gu)无需调用父类的方法,直接在执行父cL造之后,再执行子cȝ重蝲Ҏ(gu)Q如 Parent ?/span> toString() Ҏ(gu)Q这时只需执行 this.toString = function(){....} 可以了?/span>

 

2 、调用父cL法的重蝲Q?/span>

׃ js 实际q行时ƈ没有父类、子cM个实例空_(d)所?/span> super.toString() 肯定是不行的Q而在子类?/span> toString Ҏ(gu)中进?/span> this.toString() 调用只能引v内存溢出Q其实这U也可以惛_法做到?/span>

 

this.super_toString = this.toString();

this.toString=function(){

       ..............

       this.super_toString();

       ..............

}



flyffa 2006-12-28 14:39 发表评论
]]>
得到准确的在Uh数统计-减少搜烦引擎的干?/title><link>http://www.aygfsteel.com/flyffa/archive/2006/12/14/87722.html</link><dc:creator>flyffa</dc:creator><author>flyffa</author><pubDate>Thu, 14 Dec 2006 07:10:00 GMT</pubDate><guid>http://www.aygfsteel.com/flyffa/archive/2006/12/14/87722.html</guid><wfw:comment>http://www.aygfsteel.com/flyffa/comments/87722.html</wfw:comment><comments>http://www.aygfsteel.com/flyffa/archive/2006/12/14/87722.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/flyffa/comments/commentRss/87722.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/flyffa/services/trackbacks/87722.html</trackback:ping><description><![CDATA[ <h2 style="MARGIN: 13pt 0cm"> <span style="FONT-FAMILY: 黑体; mso-ascii-font-family: Arial">基本Ҏ(gu)Q?/span> </h2> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">基本的方法,|上到处都是Q在</span> <span lang="EN-US">java</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中就是在</span> <span lang="EN-US">web.xml</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">注册一?/span> <span lang="EN-US">Listener</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q如下:(x)</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"><listener><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span><listener-class>xp.web.SessionCounter</listener-class><o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"></listener></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US">SessionCounter.java</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现</span> <span lang="EN-US">javax.servlet.http.HttpSessionListener</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口Q分别在</span> <span lang="EN-US">sessionCreated</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Ҏ(gu)?/span> <span lang="EN-US">sessionDestroyed</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Ҏ(gu)中处?/span> <span lang="EN-US">session</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数目?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q样的方法有一定的问题Q?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US">1</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、对于真正从|页讉K的和搜烦引擎?/span> <span lang="EN-US">spider</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">无法区分?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US">2</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、当</span> <span lang="EN-US">Tomcat</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">重启Ӟ加蝲了上ơ持久化?/span> <span lang="EN-US">session</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Ӟ无法准确计算在线数?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">W二个问题我们可以不予考虑Q这?/span> <span lang="EN-US">tomcat</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">容器实现不标准的问题Q我们要解决的是的第一个问题,如何知道你的讉K的是真实的?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <strong> <span id="wmqeeuq" class="2Char"> <span style="FONT-SIZE: 16pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'">?/span> </span> <span id="wmqeeuq" class="2Char"> <span lang="EN-US" style="FONT-SIZE: 16pt; mso-bidi-font-family: 'Times New Roman'"> <font face="Arial">js</font> </span> </span> <span id="wmqeeuq" class="2Char"> <span style="FONT-SIZE: 16pt; FONT-FAMILY: 黑体; mso-ascii-font-family: Arial; mso-bidi-font-family: 'Times New Roman'">l过搜烦引擎</span> </span> </strong> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Q?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">做过</span> <span lang="EN-US">pv</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">l计的都知道Q可以用</span> <span lang="EN-US">script</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的方式得C真实?/span> <span lang="EN-US">pageView</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数目Q我们现在要做的是q样的一件事情,我们在所有的面都加入一D话Q?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"><script type="text/javascript"><o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">document.write ("<iframe src='/sessionCountServlet' width=0 height=0 frameborder=no border=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no></iframe>");<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"></script></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后我们写上一?/span> <span lang="EN-US">servlet</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来记录这些真正的讉K者?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">import java.io.*;<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">import javax.servlet.*;<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">import javax.servlet.http.*;</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">public class SessionCounterServlet extends HttpServlet {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public SessionCounterServlet() {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>super();<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public void doGet(HttpServletRequest request,<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">                      </span>HttpServletResponse response) throws IOException,<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">            </span>ServletException {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>process(request, response);<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public void doPost(HttpServletRequest request,<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">                       </span>HttpServletResponse response) throws IOException,<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">            </span>ServletException {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>process(request, response);<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public void process(HttpServletRequest request,<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">                        </span>HttpServletResponse response) throws IOException,<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">            </span>ServletException {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>SessionCounter.put(request.getSession().getId());<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">}</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"> <span lang="EN-US"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们可以看到q个</span> <span lang="EN-US">servlet</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">只是做了一件事情,?/span> <span lang="EN-US">process</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里面做了</span> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">SessionCounter.put(request.getSession().getId());</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">q个动作?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们来看看我们的</span> <span lang="EN-US">SessionCounter</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">做了些什么:(x)</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">import javax.servlet.http.*;<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">import java.util.Hashtable;<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">public class SessionCounter implements HttpSessionListener {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public SessionCounter() {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public static Hashtable m_real = new Hashtable();<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>private static long count = 0;<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public void sessionCreated(HttpSessionEvent e) {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>count++;<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public void sessionDestroyed(HttpSessionEvent e) {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>if (count > 0) {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">            </span>count--;<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>m_real.remove(e.getSession().getId());<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public static long getSessionCount() {<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>return count;<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public static void put(String sessionId){<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>m_real.put(sessionId,"1");<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <o:p> </o:p> </span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>public static int getRealCount(){<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">        </span>return m_real.size();<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver"> <span style="mso-spacerun: yes">    </span>}<o:p></o:p></span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span lang="EN-US" style="BACKGROUND: silver; mso-highlight: silver">}</span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们记录了一个静态的</span> <span lang="EN-US">hash</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表来记录Ȁzȝ态的</span> <span lang="EN-US">sessionid</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">Qƈ?/span> <span lang="EN-US">session</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">销毁的时候将q个</span> <span lang="EN-US">sessionid</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">|ؓ(f)I?/span> </p> <p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">怎么?/span> <span lang="EN-US">servlet</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">配置?/span> <span lang="EN-US">web</span> <span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用中我׃|唆了?/span> </p> <img src ="http://www.aygfsteel.com/flyffa/aggbug/87722.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/flyffa/" target="_blank">flyffa</a> 2006-12-14 15:10 <a href="http://www.aygfsteel.com/flyffa/archive/2006/12/14/87722.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【服务配|】apache+tomcat配置负蝲均衡的网?/title><link>http://www.aygfsteel.com/flyffa/archive/2006/11/06/79356.html</link><dc:creator>flyffa</dc:creator><author>flyffa</author><pubDate>Mon, 06 Nov 2006 03:49:00 GMT</pubDate><guid>http://www.aygfsteel.com/flyffa/archive/2006/11/06/79356.html</guid><wfw:comment>http://www.aygfsteel.com/flyffa/comments/79356.html</wfw:comment><comments>http://www.aygfsteel.com/flyffa/archive/2006/11/06/79356.html#Feedback</comments><slash:comments>9</slash:comments><wfw:commentRss>http://www.aygfsteel.com/flyffa/comments/commentRss/79356.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/flyffa/services/trackbacks/79356.html</trackback:ping><description><![CDATA[     摘要: 在网上找了一些文档,q是觉得不是很清楚,自己C些弯路,才把q个配置好,q是写下来吧Q以备后查? 1.   目标 使用 apache ? tomcat 配置一个可以应用的 web |站Q要辑ֈ以下要求Q? ...  <a href='http://www.aygfsteel.com/flyffa/archive/2006/11/06/79356.html'>阅读全文</a><img src ="http://www.aygfsteel.com/flyffa/aggbug/79356.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/flyffa/" target="_blank">flyffa</a> 2006-11-06 11:49 <a href="http://www.aygfsteel.com/flyffa/archive/2006/11/06/79356.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Proxoolq接池的单配|?/title><link>http://www.aygfsteel.com/flyffa/archive/2006/11/02/78639.html</link><dc:creator>flyffa</dc:creator><author>flyffa</author><pubDate>Thu, 02 Nov 2006 04:00:00 GMT</pubDate><guid>http://www.aygfsteel.com/flyffa/archive/2006/11/02/78639.html</guid><wfw:comment>http://www.aygfsteel.com/flyffa/comments/78639.html</wfw:comment><comments>http://www.aygfsteel.com/flyffa/archive/2006/11/02/78639.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.aygfsteel.com/flyffa/comments/commentRss/78639.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/flyffa/services/trackbacks/78639.html</trackback:ping><description><![CDATA[      自己以前做程序都是自己写q接池,那个时候项目大Q环境各异,Z便于实施QLpp行连接池的管理,{到自己惛_一些小东西的时候,才发现这个连接池成了一个专用的东西Q和pȝ做了太多的绑定,只能找连接池用,用过resin自带的连接池Q再用tomcatq接池的时候就很不爽,没有监控的功能,在网上选来选去Q最后选择了Proxool?br /><br />      Proxoolq接池是sourceforge下的一个开源项?q个目提供一个健壮、易用的q接池,最为关键的是这个连接池提供监控的功能,方便易用Q便于发现连接泄漏的情况。开源项目地址是:(x)<a ><br />http://proxool.sourceforge.net/</a><br /><br />配置q接池比较的单:(x)<br />1、将下蝲的包解开Q从包中的lib目录下将proxool-xxx.jar(xxx随着不同的版本号变化)加入你的工程中?br />2、配|数据源Q?br />      在web-info下徏立文Ӟ(x)proxool.xmlQ文件内容如下:(x)<br /><font style="BACKGROUND-COLOR: #d3d3d3"><font size="2"><?xml version="1.0" encoding="UTF-8"?><br /><something-else-entirely><br />  <proxool><br />    <alias>Develop</alias><br />    <driver-url>jdbc:mysql://localhost/kuanxue</driver-url><br />    <driver-class>com.mysql.jdbc.Driver</driver-class><br />    <driver-properties><br />      <property name="user" value="root"/><br />      <property name="password" value=""/><br />      <property name="useUnicode" value="true"/><br />      <property name="characterEncoding" value="GBK"/><br />    </driver-properties><br />    <maximum-connection-count>500</maximum-connection-count><br />    <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql><br />  </proxool><br /> </something-else-entirely><br /></font><br /><font style="BACKGROUND-COLOR: #ffffff">3、配|web.xml<br />在web.xml中增加:(x)<br /><font style="BACKGROUND-COLOR: #d3d3d3" size="2"><!-- 配置初始化servlet,在web容器加蝲的时候自动加载配|文Ӟ如果不是webE序Q这个部分就需要通过开发接口来初始化了 --><br /><servlet><br />     <servlet-name>proxoolInitialServlet</servlet-name><br /> <servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class><br />     <init-param><br />       <param-name>xmlFile</param-name><br />       <param-value>WEB-INF/proxool.xml</param-value><br />     </init-param><br />     <load-on-startup>1</load-on-startup><br />   </servlet><br /><!--配置监控servlet,其实如果不想监控的话Q可以不?-><br />   <servlet><br />    <servlet-name>dbpoolAdmin</servlet-name><br />    <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class><br />  </servlet><br />   <servlet-mapping><br />    <servlet-name>dbpoolAdmin</servlet-name><br />    <url-pattern>/dbpool</url-pattern><br />  </servlet-mapping><br /></font><br /></font></font><font style="BACKGROUND-COLOR: #ffffff">4、在E序中调?br />一般我获取connection的行为封装ؓ(f)一个工厂模式,便于多种情况的切换,以下是其中proxool数据源的getConnectionҎ(gu)的实玎ͼ(x)<br /><br /></font><font style="BACKGROUND-COLOR: #d3d3d3" size="2">public Connection getConnection() {<br />        try{<br />            Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");<br />            return DriverManager.getConnection("proxool.Develop");<br />        }catch(Exception ex){<br />            ex.printStackTrace();<br />        }<br />        return null;<br />    }<br /><br /><font style="BACKGROUND-COLOR: #ffffff">5、应用开发:(x)<br />      在实际的应用中,我们可能需要更多的功能Q比如监控功能不够强大,权限不好控制Q我们希望能够编写出更强大的功能Q比如杀M些大的查询语句等Q记录各U查询语句占用的旉Q这需要对开发接口进行进一步的研究了?br /></font></font><img src ="http://www.aygfsteel.com/flyffa/aggbug/78639.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/flyffa/" target="_blank">flyffa</a> 2006-11-02 12:00 <a href="http://www.aygfsteel.com/flyffa/archive/2006/11/02/78639.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˳</a>| <a href="http://" target="_blank">»Ȱ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">뵺</a>| <a href="http://" target="_blank">ͨ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">峣</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">½</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">׿</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ļ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">¡Ң</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">԰</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank">Ȫ</a>| <a href="http://" target="_blank">ǭ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ȷ</a>| <a href="http://" target="_blank">ǰ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>