WebAppUtil.getService() 得到同一物件???

ttxyzr發表於2008-05-11
《JdonFramework使用開發指南》講到“getService方法每次返回的一個新的服務例項物件,相當於new一物件。如果物件池攔截器被配置,那麼...”

實際測試如下:

test.xml
<pojoService name="testService" class="com.yourcompany.struts.TestServicePOJO1"/>

index.jsp
TestService test = (TestService)WebAppUtil.getService("testService", request);
TestService test1 = (TestService)WebAppUtil.getService("testService", request);

TestService test2 = (TestService)WebAppUtil.getComponentInstance("testService", request);

out.println(test == test1);
out.println(test == test2);
out.println(test1 == test2);

結果輸出:
true false false

====================================================
1. test == test1為true做何解?
2. WebAppUtil.getService()與WebAppUtil.getComponentInstance()連續呼叫後使得com.yourcompany.struts.TestServicePOJO1不在是單例?

相關文章