亚洲精品在线观看视频,久久久久se,奇米888一区二区三区http://www.aygfsteel.com/itspy/category/17171.htmlzh-cnFri, 06 Jun 2014 15:55:39 GMTFri, 06 Jun 2014 15:55:39 GMT60CGLIB學習札記---生成CLASS的命名規則http://www.aygfsteel.com/itspy/archive/2014/06/06/414464.htmlitspyitspyFri, 06 Jun 2014 04:03:00 GMThttp://www.aygfsteel.com/itspy/archive/2014/06/06/414464.htmlhttp://www.aygfsteel.com/itspy/comments/414464.htmlhttp://www.aygfsteel.com/itspy/archive/2014/06/06/414464.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/414464.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/414464.html
被代理class name(包名和類名) + "$$" +
使用cglib處理的class name(只有類名,不包含包名) +"ByCGLIB" + "$$" +
key的hashcode(接下來會對key有一個詳細的分析) +
序列號

下面是上面規則的示例:
aop.target.HelloImpl$$EnhancerByCGLIB$$494b5b61
aop.target.HelloImpl$$EnhancerByCGLIB$$494b5b61_2
aop.target.HelloImpl$$EnhancerByCGLIB$$494b5b61_3  閱讀全文

itspy 2014-06-06 12:03 發表評論
]]>
JAVA函數可以修改傳入的變量嗎?http://www.aygfsteel.com/itspy/archive/2014/06/04/414381.htmlitspyitspyWed, 04 Jun 2014 04:26:00 GMThttp://www.aygfsteel.com/itspy/archive/2014/06/04/414381.htmlhttp://www.aygfsteel.com/itspy/comments/414381.htmlhttp://www.aygfsteel.com/itspy/archive/2014/06/04/414381.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/414381.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/414381.html閱讀全文

itspy 2014-06-04 12:26 發表評論
]]>
如何讓一個Class被一個虛擬機實例載入2次http://www.aygfsteel.com/itspy/archive/2014/06/03/414343.htmlitspyitspyTue, 03 Jun 2014 05:16:00 GMThttp://www.aygfsteel.com/itspy/archive/2014/06/03/414343.htmlhttp://www.aygfsteel.com/itspy/comments/414343.htmlhttp://www.aygfsteel.com/itspy/archive/2014/06/03/414343.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/414343.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/414343.html閱讀全文

itspy 2014-06-03 13:16 發表評論
]]>
JAXP throw Exception when validate XML with SAXhttp://www.aygfsteel.com/itspy/archive/2011/08/10/356262.htmlitspyitspyWed, 10 Aug 2011 10:12:00 GMThttp://www.aygfsteel.com/itspy/archive/2011/08/10/356262.htmlhttp://www.aygfsteel.com/itspy/comments/356262.htmlhttp://www.aygfsteel.com/itspy/archive/2011/08/10/356262.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/356262.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/356262.htmlException:Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl @1ff7a1e] does not support XML Schema.

只需要在特定目錄添加一個文件:jaxp.properties
內容如下
javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl


如果是Bea/jrockit可以添加到如下類似目錄
D:\bea\jrockit_160_05\jre\lib


-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl


 



itspy 2011-08-10 18:12 發表評論
]]>
在Tomcat中部署Java Web應用程序(轉)http://www.aygfsteel.com/itspy/archive/2008/12/02/243875.htmlitspyitspyTue, 02 Dec 2008 03:14:00 GMThttp://www.aygfsteel.com/itspy/archive/2008/12/02/243875.htmlhttp://www.aygfsteel.com/itspy/comments/243875.htmlhttp://www.aygfsteel.com/itspy/archive/2008/12/02/243875.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/243875.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/243875.htmlhttp://ericxu131.javaeye.com/blog/175831
在Tomcat中部署Java Web應用程序有兩種方式:靜態部署和動態部署。在下文中$CATALINA_HOME指的是Tomcat目錄。
一、靜態部署
     靜態部署指的是我們在服務器啟動之前部署我們的程序,只有當服務器啟動之后,我們的Web應用程序才能訪問。以下3中方式都可以部署:
    1、將PetWeb目錄拷貝到
$CATALINA_HOME\webapps下,然后啟動服務器就可以了。這種方式比較簡單,但是web應用程序必須在webapps目錄下。訪問地址如下:
http://localhost:8080/PetWeb/
   2、這種方式可以不必將PetWeb目錄拷貝到webapps下,直接在F:\部署。方法如下,更改$CATALINA_HOME\conf\server.xml文件,在<host>標簽內添加<Context>標簽,內容如下:
<Context docBase="F:/PetWeb" reloadable="false" path="/Pet"/>
其中reloadable="false"表示當應用程序中的內容發生更改之后服務器不會自動加載,這個屬性在開發階段通常都設為true,方便開發,在發布階段應該設置為false,提高應用程序的訪問速度。docBase為路徑,可以使用絕對路徑,也可以使用相對路徑,相對路徑相對于webapps。path屬性的值是訪問時的根地址。訪問地址如下:
http://localhost:8080/Pet/
    3、這種方式和第二種方式差不多,但是不是在Server.xml文件中添加Context標簽,而是在$CATALINA_HOME\conf\Catalina\localhost中添加一個xml文件,如Pet.xml,內容如下:
<Context docBase="F:/PetWeb" reloadable="false" />大家可能發現和第二種方式差不多,但是缺少了path屬性,這種方式服務器會使用.xml的名字作為path屬性的值。訪問地址如下:http://localhost:8080/Pet/
   
    我們剛才是將PetWeb文件夾部署在了服務器中,我們知道可以將Web應用程序的內容打成.war
包,然后在部署在服務器上。打包請參考如下步驟:
    1、打開命令提示符(Start-->Run-->cmd)
    2、設置jdk環境變量(如果我教過的學生不會配置,以后別說孫老師教過你)
    3、在命令提示符中進入F:\PetWeb文件后,鍵入如下命令:
jar ..\Pet.war *.*  
這樣在F:\下應該有Pet.war文件。其中..表示當前目錄的父目錄。
     部署Pet.war文件非常簡單,將剛才有docBase="F:\PetWeb"更改為docBase="F:\Pet.war"或者直接將其拷貝到webapps下也可以。重新啟動服務器就可以將Pet.war部署為一個Web應用程序了。如果你夠細心的話你會發現,服務器將Pet.war文件解開,并且在webapps下面又生成了一個Pet文件夾,然后把Pet.war的內容拷貝到里面去了。我們可以通過以下方式取消自動解壓縮,配置方式如下:
<Context docBase="F:/PetWeb" reloadable="false" unpackWAR="false"/>
二、動態部署
    動態部署是指可以在服務器啟動之后部署web應用程序,而不用重新啟動服務器。動態部署要用到服務器提供的manager.war文件,如果在
$CATALINA_HOME\webapps\下沒有該文件,你必須去重新下載tomcat,否則不能完成以下的功能。要想使用該管理程序必須首先編輯$CATALINA_HOME\conf\tomcat-users.xml文件,內容如下:關于這個文件的更多內容,請參考Java Web應用程序的安全模型二
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<user username="coresun" password="coresun" roles="manager"/>

<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>
然后在瀏覽器中鍵入如下地址:
http://localhost:8080/應該看到一個漂亮的加菲貓了吧。點擊左邊的Tomcat Manager鏈接,提示輸入用戶名和密碼,本文都是coresun,然后可以看到以下頁面:

在Context Path(option):中輸入/Pet
XML Configration file URL中要指定一個.xml文件,比如我們在F:\下建立一個Pet.xml文件,內容如下:
<Context reloadable="false" />docBase不用寫了,因為在下一個文本框中填入。或者更簡單點,這個文本框什么都不填。
在WAR or Directory URL:中鍵入F:\PetWet或者F:\Pet.war都可以,然后點擊Deploy按鈕,看看上面是不是已經看到了你web應用程序,名字就是你Context Path(option):中的名字。

如果你部署.war文件還有更加簡單的方式,下面還有個Select WAR file uploae點擊瀏覽選擇.war文件,然后點擊Deploy也可以。



itspy 2008-12-02 11:14 發表評論
]]>
如何向Eclipse中輸入系統變量和運行參數http://www.aygfsteel.com/itspy/archive/2008/10/29/237332.htmlitspyitspyWed, 29 Oct 2008 03:08:00 GMThttp://www.aygfsteel.com/itspy/archive/2008/10/29/237332.htmlhttp://www.aygfsteel.com/itspy/comments/237332.htmlhttp://www.aygfsteel.com/itspy/archive/2008/10/29/237332.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/237332.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/237332.html Eg: 2008-12-20


往Eclipse中輸入系統變量,run  -> run..->arguments--> vm arguments.
Eg: -Dlog.level=DEBUG -Dconfig.file="C:\Documents and Settings\feli\workspace\IECAgent\src\ratingAgent.config"


有一點要注意的就是如果參數中有空格,要用引號括起來。









itspy 2008-10-29 11:08 發表評論
]]>
原來mvn war:war 不依賴 mvn:compilehttp://www.aygfsteel.com/itspy/archive/2008/09/24/230884.htmlitspyitspyWed, 24 Sep 2008 06:57:00 GMThttp://www.aygfsteel.com/itspy/archive/2008/09/24/230884.htmlhttp://www.aygfsteel.com/itspy/comments/230884.htmlhttp://www.aygfsteel.com/itspy/archive/2008/09/24/230884.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/230884.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/230884.html
經過查找發現以前之所以可以,是因為剛好對應的工程是Maven得到的Eclispe工程,而Eclipse已經對Java文件編繹過了,并且默認的class輸出目錄是target/classes.而Maven運行mvn:compile也是把class輸出到此目錄.

所以打包前不必運行mvn:compile,但是如果不是Eclipse工程,或者是Eclipse沒有把Class輸出到target/classes,直接打WAR包,得到的包是不完整的,沒有class的.


itspy 2008-09-24 14:57 發表評論
]]>
控制Word/Excel在IE中打開,還是下載http://www.aygfsteel.com/itspy/archive/2008/09/04/227079.htmlitspyitspyThu, 04 Sep 2008 14:48:00 GMThttp://www.aygfsteel.com/itspy/archive/2008/09/04/227079.htmlhttp://www.aygfsteel.com/itspy/comments/227079.htmlhttp://www.aygfsteel.com/itspy/archive/2008/09/04/227079.html#Feedback1http://www.aygfsteel.com/itspy/comments/commentRss/227079.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/227079.html
<%@ page contentType="application/msword;charset=utf8" %>
<!-- 以上這行設定本網頁為Word格式的網頁 -->
<%
   //response.setHeader("Content-disposition","inline; filename=test1.doc"); //線上瀏覽方式,用IE打開
  response.setHeader("Content-disposition","attachment; filename=test1.doc");//下載方式,下載,不用瀏覽器打開
   //以上這行設定傳送到前端瀏覽器時的檔名為test1.doc
   //就是靠這一行,讓前端瀏覽器以為接收到一個word檔
  //來源:http://www.xfuse.cn
%>
 
 
 測試 http://www.xfuse.cn
 

itspy 2008-09-04 22:48 發表評論
]]>
log4j 行號與文件名打印問號http://www.aygfsteel.com/itspy/archive/2008/04/22/194686.htmlitspyitspyTue, 22 Apr 2008 01:52:00 GMThttp://www.aygfsteel.com/itspy/archive/2008/04/22/194686.htmlhttp://www.aygfsteel.com/itspy/comments/194686.htmlhttp://www.aygfsteel.com/itspy/archive/2008/04/22/194686.html#Feedback1http://www.aygfsteel.com/itspy/comments/commentRss/194686.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/194686.html關鍵字:行號 文件名 亂碼 問號 ?

log4j本來設置了要打印行號與文件名的,結果有的能打印出來,有的卻是亂碼,查了些文檔之后才發現,原來打印問題是因為編繹時沒有編繹進去調試信息,所以沒辦法打印.

但是我用的是Ant,如果在Ant編繹時,編繹進去調試信息呢,參考下面配置.

  <javac srcdir="src" destdir="bin" debug="true"  classpathref="accrual.path" >

首發于 http://blog.xfuse.cn

參考文檔
http://ant.apache.org/manual/CoreTasks/javac.html



Log4j配置
log4j.appender.C1.layout.ConversionPattern=%F(%L)-- %-4r %-5p [%t] %37c %3x - %m%n


如果是用JAVAC編繹,那么直接加參數-g就可以了.

用法:javac <選項> <源文件>
其中,可能的選項包括:
  -g                         生成所有調試信息
  -g:none                    不生成任何調試信息
  -g:{lines,vars,source}     只生成某些調試信息
  -nowarn                    不生成任何警告



itspy 2008-04-22 09:52 發表評論
]]>
用代理實現AJAX跨域訪問時遇到HTTPShttp://www.aygfsteel.com/itspy/archive/2007/04/27/114125.htmlitspyitspyFri, 27 Apr 2007 08:26:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/04/27/114125.htmlhttp://www.aygfsteel.com/itspy/comments/114125.htmlhttp://www.aygfsteel.com/itspy/archive/2007/04/27/114125.html#Feedback4http://www.aygfsteel.com/itspy/comments/commentRss/114125.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/114125.html代理服務器:在AJAX可以訪問的域中,并且代理AJAX來訪問其它網站的服務器,
目標服務器:AJAX真實想想訪問的網址所在的服務器。

我遇到的問題就是:代理服務器通過HTTPS訪問目標服務器,但是目標服務器的證書出于一些原因并不被信任。

關鍵字:Ajax ,JavaScript, Coldfusion, HTTPS, cfhttp  閱讀全文

itspy 2007-04-27 16:26 發表評論
]]>
2.0與1.2.8的Spring在事務管理上的區別http://www.aygfsteel.com/itspy/archive/2007/03/29/107277.htmlitspyitspyThu, 29 Mar 2007 09:20:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/03/29/107277.htmlhttp://www.aygfsteel.com/itspy/comments/107277.htmlhttp://www.aygfsteel.com/itspy/archive/2007/03/29/107277.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/107277.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/107277.html閱讀全文

itspy 2007-03-29 17:20 發表評論
]]>
Spring Aop的事務配置的一點疑問http://www.aygfsteel.com/itspy/archive/2007/03/27/106751.htmlitspyitspyTue, 27 Mar 2007 12:18:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/03/27/106751.htmlhttp://www.aygfsteel.com/itspy/comments/106751.htmlhttp://www.aygfsteel.com/itspy/archive/2007/03/27/106751.html#Feedback5http://www.aygfsteel.com/itspy/comments/commentRss/106751.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/106751.html

這樣是不是有可能兩個并行事務,同時讀取一個數據,然后再同時修改,先后提交事務。這樣就會有一個事務丟失其修改,不知道我理解的對不對。




?

itspy 2007-03-27 20:18 發表評論
]]>
JS實現include功能(提供完整的示例下載)http://www.aygfsteel.com/itspy/archive/2007/03/21/105137.htmlitspyitspyWed, 21 Mar 2007 01:07:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/03/21/105137.htmlhttp://www.aygfsteel.com/itspy/comments/105137.htmlhttp://www.aygfsteel.com/itspy/archive/2007/03/21/105137.html#Feedback3http://www.aygfsteel.com/itspy/comments/commentRss/105137.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/105137.html閱讀全文

itspy 2007-03-21 09:07 發表評論
]]>
初步體驗“AJAX不能跨域訪問”(原創)[有源碼,有示例]http://www.aygfsteel.com/itspy/archive/2007/02/11/99262.htmlitspyitspySun, 11 Feb 2007 09:30:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/02/11/99262.htmlhttp://www.aygfsteel.com/itspy/comments/99262.htmlhttp://www.aygfsteel.com/itspy/archive/2007/02/11/99262.html#Feedback14http://www.aygfsteel.com/itspy/comments/commentRss/99262.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/99262.html
大家可以親自體會一下。不過要有Web容器才行,實在沒有Web容器,用網絡鄰居也行。  閱讀全文

itspy 2007-02-11 17:30 發表評論
]]>
打印出Ibatis最終的SQL語句http://www.aygfsteel.com/itspy/archive/2007/02/11/99232.htmlitspyitspySun, 11 Feb 2007 03:22:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/02/11/99232.htmlhttp://www.aygfsteel.com/itspy/comments/99232.htmlhttp://www.aygfsteel.com/itspy/archive/2007/02/11/99232.html#Feedback9http://www.aygfsteel.com/itspy/comments/commentRss/99232.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/99232.htmlAppfuse是有相關的配置,但是好像沒有用,不過關于Hibernate的倒是有用,我想這種問題網上肯定有人遇到過,只要找到這個人就行了。

經過切換不同的關鍵字,我最后找到了正確的配置。  閱讀全文

itspy 2007-02-11 11:22 發表評論
]]>
三種Tomcat的插件比較http://www.aygfsteel.com/itspy/archive/2007/01/17/94442.htmlitspyitspyWed, 17 Jan 2007 09:09:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/01/17/94442.htmlhttp://www.aygfsteel.com/itspy/comments/94442.htmlhttp://www.aygfsteel.com/itspy/archive/2007/01/17/94442.html#Feedback3http://www.aygfsteel.com/itspy/comments/commentRss/94442.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/94442.html
??????在Tomcat下開發一些項目時,不可避免的會用到針對Tomcat的插件來進行調試,目前我接觸到的插件有如下三種,雖然它們都能對工程進行調試,它在一些其它功能上面卻有其區別

????? Myeclipse:這個是最強大的Eclipse插件,差不多什么都有,是一個一站式的解決插件。
????? WTP(Web Tools Platform):是由Eclipse自己開發的插件。
????? TomcatPlugin(sysdeo):最老牌的Tomcat插件,也是最好用的。

?

  1. Myeclipse插件對Tomcat的支持看起來應該是最好的,特點是熱部署。不管是對Servlet的修改,還是對web.xml的修改都可以。卻可以做到,哪個變了,就加載哪個。它可以很方便的把你的工程直接發布到Tomcat中去,或者是以war的形式發布過去。
  2. WTP(Web Tools Platform)
    :相對MyEclipse于,WTP則實現了部署的透明化,Myeclipse在啟動Tomcat后,要你通過myEclipse把工程部署到Tomcat下,它會對你的Tomcat目錄下添加一些文件。但是WTP則對你的Tomcat不會有任何修改。
    但我也發現了使用WTP 部署Web工程時的一個問題,對web.xml文件的修改不會自動的被重新加載,但更改Servlet會重新加載Servlet,并且同時重新加載web.xml。
    也就是你想重新加載web.xml,你只有佯裝修改一個Servlet,才能觸發重新加載web.xml。不知道以后的版本會不會修改這點。
  3. TomcatPlugin(sysdeo):最老牌的tomcat插件了,相對來說在Tomcat調試領域也是最好用的了,不過它有點與WTP一樣,無法自動加載web.xml變化。但它也有它的絕招,是另外兩個插件不能比的。它有兩種支持調試的方式:
    1. 建立Tomcat工程,這時可以使用熱部署,tomcatPlugin(sysdeo)由于它并不真正的部署工程,使用TomcatPlugin(sysdeo)添加一個工程時,實際上在Tomcat\conf\Catalina\localhost目錄下添加了一個文件,當Tomcat啟動時就會加載這個工程,這時當然也可以調試。
    2. 另外一種支持調試的功能是其它兩個插件沒有的,比如你的工程是通過ANT布置到Tomcat下去的,你的目錄結構無法滿足WTP與Myeclipse的要求,這時你沒有辦法來使用這兩個插件來進行調度,但是使用TomcatPlugin卻可以。你只要在設置window->preferences->tomcat->soure path即可。


個人Blog:? http://www.aygfsteel.com/itspy


插件的適應環境:

???如果沒有特別的原因,應該盡量選擇TomcatPlugin(sysdeo)。

  1. 如果是一個全新的項目,上級完全放權了,你可以使用myEclipse與WTP,因為它能實現熱部署,調度修改代碼十分方便。但它們相對Tomcat來說,一個是侵入式的,一個卻是無侵入的。你可以針對這個特點來在兩者之間進行選擇。
  2. 如果是一個已經有一定歷史積累的工程,或者是無法對目錄結構進行控制的工作,這時推薦使用使用TomcatPlugin(sysdeo)。
    因為myEclipse與WTP對工程對目錄結構都有一定的要求,因為它們要把工程部署到Tomcat上去,所以對工程目錄結構上都有自己的要求。比如在哪放置WEB-INFO,在哪個目錄放置源文件,并且兩個插件之間的工程無法形成兼容與共享。
    但是TomcatPlugin(sysdeo)只是充當一個外掛來啟動Tomcat,并把指定的源代碼與Tomcat里面運行的項目關聯起來,進行調試。所以它對目錄結構沒有要求,比較適應于無法對目錄結構進行控制的項目,一個普通的Java工程即可以。

?個人Blog:? http://www.aygfsteel.com/itspy



itspy 2007-01-17 17:09 發表評論
]]>
在單元測試時,測試用例中的屬性實現自動裝載[appfuse學習筆試]http://www.aygfsteel.com/itspy/archive/2007/01/03/91532.htmlitspyitspyWed, 03 Jan 2007 06:19:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/01/03/91532.htmlhttp://www.aygfsteel.com/itspy/comments/91532.htmlhttp://www.aygfsteel.com/itspy/archive/2007/01/03/91532.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/91532.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/91532.html在Appfuse中,對DAO類進行單元測試時有如下代碼
??? private UserDao dao = null;
??? private RoleDao rdao = null;
???
??? public void setUserDao(UserDao dao) {
??????? this.dao = dao;
??? }
???
??? public void setRoleDao(RoleDao rdao) {
??????? this.rdao = rdao;
??? }
通過架構,這兩個Dao類都進行了自動裝載,后來的使用中,我才發現,所有類似的屬性都可以實現自動裝載.
?
?
這我就奇怪了,如果這些類是在Spring的ApplicationContext中設置的,我還知道,Spring提供了很多途徑來解決自動裝載問題.但是這些單元測試的類,都是由它們來管理生成ApplicationContext的,怎么也實現了自動裝載?
經常查看源碼,才知道原來是Appfuse架構中對DAO進行單元測試的類有一個共同的父類AbstractDependencyInjectionSpringContextTests,這個父類得到生成的ApplicationContext,會檢查自己有沒有一些屬性要實現自動裝載的,如果有就到ApplicationContext中去找,找到了就把自己子類的屬性實現自動裝載.
?
最核心的代碼是:AbstractDependencyInjectionSpringContextTests中有如下方法
?private void injectDependencies() throws Exception {
? if (isPopulateProtectedVariables()) {
?? if (this.managedVariableNames == null) {
??? initManagedVariableNames();
?? }
?? populateProtectedVariables();
? }
? else if (getAutowireMode() != AUTOWIRE_NO) {
?? this.applicationContext.getBeanFactory().autowireBeanProperties(
??? this, getAutowireMode(), isDependencyCheck());
? }
?}
?
?AbstractSingleSpringContextTests類中定義了下面的方法,這個方法實現了Junit的類TestCase定義的方法,這個方法會在每個方法之前運行。
? ?protected final void setUp() throws Exception {
??this.applicationContext = getContext(contextKey());//這個contextKey方法會調用BaseDaoTestCase中定義的getConfigLocations方法
??prepareTestInstance();
??onSetUp();
?}

itspy 2007-01-03 14:19 發表評論
]]>
在Appfuse中如何取得當前登錄用戶名http://www.aygfsteel.com/itspy/archive/2007/01/01/91283.htmlitspyitspyMon, 01 Jan 2007 05:44:00 GMThttp://www.aygfsteel.com/itspy/archive/2007/01/01/91283.htmlhttp://www.aygfsteel.com/itspy/comments/91283.htmlhttp://www.aygfsteel.com/itspy/archive/2007/01/01/91283.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/91283.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/91283.html
Appfuse的登錄,權限控制都是通過Acegi來實現的,通過網上查找,看資料先后找到了兩個方法,和大家分享一下。  閱讀全文

itspy 2007-01-01 13:44 發表評論
]]>
Jpetstore(srping 版本)示例學習筆記[1]http://www.aygfsteel.com/itspy/archive/2006/12/28/90461.htmlitspyitspyThu, 28 Dec 2006 04:40:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/12/28/90461.htmlhttp://www.aygfsteel.com/itspy/comments/90461.htmlhttp://www.aygfsteel.com/itspy/archive/2006/12/28/90461.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/90461.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/90461.html閱讀全文

itspy 2006-12-28 12:40 發表評論
]]>
Spring在Web中是如何載入相關的上下文環境http://www.aygfsteel.com/itspy/archive/2006/12/21/89358.htmlitspyitspyThu, 21 Dec 2006 13:00:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/12/21/89358.htmlhttp://www.aygfsteel.com/itspy/comments/89358.htmlhttp://www.aygfsteel.com/itspy/archive/2006/12/21/89358.html#Feedback5http://www.aygfsteel.com/itspy/comments/commentRss/89358.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/89358.html
只要在web.xml設置監聽器:org.springframework.web.context.ContextLoaderListener

org.springframework.web.context.ContextLoaderListener

并且配置一下如下參考

contextConfigLocation

/WEB-INF/dataAccessContext-local.xml /WEB-INF/applicationContext.xml



但是內部細節是如何運作的呢?  閱讀全文

itspy 2006-12-21 21:00 發表評論
]]>
JAVA與C++的一點比較http://www.aygfsteel.com/itspy/archive/2006/11/24/83275.htmlitspyitspyFri, 24 Nov 2006 07:31:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/11/24/83275.htmlhttp://www.aygfsteel.com/itspy/comments/83275.htmlhttp://www.aygfsteel.com/itspy/archive/2006/11/24/83275.html#Feedback5http://www.aygfsteel.com/itspy/comments/commentRss/83275.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/83275.html它們的結果一是-80,還是0呢。我問過很多人,他們都猜錯了。

更奇怪的是在JAVA與C中它的表現還不一樣,剛好相反。  閱讀全文

itspy 2006-11-24 15:31 發表評論
]]>
finalize函數的一點疑問http://www.aygfsteel.com/itspy/archive/2006/11/23/83052.htmlitspyitspyThu, 23 Nov 2006 07:21:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/11/23/83052.htmlhttp://www.aygfsteel.com/itspy/comments/83052.htmlhttp://www.aygfsteel.com/itspy/archive/2006/11/23/83052.html#Feedback6http://www.aygfsteel.com/itspy/comments/commentRss/83052.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/83052.html這句話是不是可以理解:“finalize函數可能根本就不會被運行”  閱讀全文

itspy 2006-11-23 15:21 發表評論
]]>
從JAVA里面的不一致性,淺談設計問題http://www.aygfsteel.com/itspy/archive/2006/11/20/82386.htmlitspyitspyMon, 20 Nov 2006 13:50:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/11/20/82386.htmlhttp://www.aygfsteel.com/itspy/comments/82386.htmlhttp://www.aygfsteel.com/itspy/archive/2006/11/20/82386.html#Feedback10http://www.aygfsteel.com/itspy/comments/commentRss/82386.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/82386.html 得到數組的大小,要通過length屬性
得到String的大小,要用length方法
得到集合(比如List,Set)的大小,要使用size方法。

難道這沒有給你帶來不便嗎?  閱讀全文

itspy 2006-11-20 21:50 發表評論
]]>
C++與JAVA在多態與覆蓋上的區別(一點猜測)http://www.aygfsteel.com/itspy/archive/2006/11/16/81598.htmlitspyitspyThu, 16 Nov 2006 12:28:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/11/16/81598.htmlhttp://www.aygfsteel.com/itspy/comments/81598.htmlhttp://www.aygfsteel.com/itspy/archive/2006/11/16/81598.html#Feedback6http://www.aygfsteel.com/itspy/comments/commentRss/81598.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/81598.html
現分別寫了兩塊代碼證明如下,至于為什么會有如此原因,我也不明白,希望有能懂C++與JAVA的人能出來講解一下。  閱讀全文

itspy 2006-11-16 20:28 發表評論
]]>
動態代理的一些思考和疑問:(疑問還沒解決)http://www.aygfsteel.com/itspy/archive/2006/11/13/80842.htmlitspyitspyMon, 13 Nov 2006 03:36:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/11/13/80842.htmlhttp://www.aygfsteel.com/itspy/comments/80842.htmlhttp://www.aygfsteel.com/itspy/archive/2006/11/13/80842.html#Feedback5http://www.aygfsteel.com/itspy/comments/commentRss/80842.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/80842.html動態代理的一些思考和疑問:(疑問還沒解決)
在Java中有一個動態代理技術,主要通過Proxy,InvocationHandler和Method,這三個類(接口)來實現.但是有如下一個問題不太明白,希望高手解惑.

我查看了幾個例子,它們實現InvocationHandler這個接口時,都通過構造函數傳遞進去了,實際被代理的對象,然后在實現的方法中通過method.invoke(obj,args);obj為構造函數傳遞進來的對象.

比如下面的例子:
public class Handler implements InvocationHandler {

?MethodInterface delegate;

?public Handler(MethodInterface delegate) {
??this.delegate = delegate;
?}

?public Object invoke(Object proxy, Method method, Object[] args)
???throws Throwable {
??if (method.getName().equals("say")) {
???System.out.print("I have get it");
??}
??return method.invoke(this.delegate, args);?
?}

}

函數invoke()傳遞進去的第一個參數proxy就沒有被使用到,但同樣實現了動態代理的效果,后面參考文獻中的例子也是的,難道是這第一個參數就是多余的,如果是這樣的話,就是Sun設置失誤了 ^__^.

sun的文檔是這樣解釋這個參數的:proxy - the proxy instance that the method was invoked on.但這個參數有什么用的,如果不傳遞他進來,會有什么不便呢.


有沒有人能明白這是怎么回事,或者是寫個示例代碼,講講這個第一個參數是干嘛用的?

?

?

注:附兩個完整的動態代理的例子
http://blog.csdn.net/hsyj_0001/archive/2006/04/02/647488.aspx
http://www.java2s.com/Code/Java/Development-Class/Demonstratesadynamicproxy.htm



itspy 2006-11-13 11:36 發表評論
]]>
百度面試題目的答案[原創]http://www.aygfsteel.com/itspy/archive/2006/11/10/80435.htmlitspyitspyFri, 10 Nov 2006 08:46:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/11/10/80435.htmlhttp://www.aygfsteel.com/itspy/comments/80435.htmlhttp://www.aygfsteel.com/itspy/archive/2006/11/10/80435.html#Feedback52http://www.aygfsteel.com/itspy/comments/commentRss/80435.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/80435.html最近有同學找工作,經常在班級群里發一些大公司的面試,筆試題目.昨天收到這樣一個題目,據說是百度的面試題目.

?有一根27厘米的細木桿,在第3厘米、7厘米、11厘米、17厘米、23厘米這五個位置上各有一只螞蟻。 木桿很細,不能同時通過一只螞蟻。開始 時,螞蟻的頭朝左還是朝右是任意的,它們只會朝前走或調頭, 但不會后退。當任意兩只螞蟻碰頭時,兩只螞蟻會同時調頭朝反方向走。假設螞蟻們每秒鐘可以走一厘米的距離。 編寫程序,求所有螞蟻都離開木桿 的最小時間和最大時間。

看了這個題目之后,突然很感興趣,今天搞了半天把它做出來了,大概花了1個半小時.大公司的題目真是考人.反正都已經用算法實現了,我就不多說了,大家看代碼吧.代碼里面注釋我也盡量全寫了.一共有兩個類,一個是Ant的模型,一個是控制類.原代碼,大家可以在這取得:

http://www.aygfsteel.com/Files/itspy/baidu.rar



//////////////////////////////////////
/*百度面試題
?* 有一根27厘米的細木桿,在第3厘米、7厘米、11厘米、17厘米、23厘米這五個位置上各有一只螞蟻。
?* 木桿很細,不能同時通過一只螞蟻。開始 時,螞蟻的頭朝左還是朝右是任意的,它們只會朝前走或調頭,
?* 但不會后退。當任意兩只螞蟻碰頭時,兩只螞蟻會同時調頭朝反方向走。假設螞蟻們每秒鐘可以走一厘米的距離。
?* 編寫程序,求所有螞蟻都離開木桿 的最小時間和最大時間。
?*
?*
?* 分析:題目中的螞蟻只可能相遇在整數點,不可以相遇在其它點,比如3.5cm處之類的,也就是可以讓每只螞蟻走 1秒,然后
?* 查看是否有相遇的即可.
?*
?* 這樣我的程序實現思路就是,初始化5只螞蟻,讓每只螞蟻走1秒,然后看是否有相遇的,如果有則做相應處理.當每只螞蟻都
?* 走出木桿時,我就記錄當前時間.這樣就可以得到當前狀態情況下,需要多久可以走出木桿,然后遍歷所有狀態則可以得到所胡
?* 可能.
?*/

package baidu;

public class Ant {
?/*
? * step 表示螞蟻每一個單位時間所走的長度
? */
?private final static int step = 1;

?/*
? * position表示螞蟻所處的初始位置
? */
?private int position;

?/*
? * direction表示螞蟻的前進方向,如果為1表示向27厘米的方向走, 如果為-1,則表示往0的方向走。
? */
?private int direction = 1;

?/*
? * 此函數運行一次,表示螞蟻前進一個單位時間,如果已經走下木桿則會拋出異常
? */
?public void walk() {
??if (isOut()) {
???throw new RuntimeException("the ant is out");
??}
??position = position + this.direction * step;
?};


?/**
? * 檢查螞蟻是否已經走出木桿,如果走出返回true
? *
? */

?public boolean isOut() {
??return position <= 0 || position >= 27;
?}

?/**
? * 檢查此螞蟻是否已經遇到另外一只螞蟻
? * @param ant
? * @return 如果遇到返回true
? */
?public boolean isEncounter(Ant ant) {
??return ant.position == this.position;
?}

?/**
? * 改變螞蟻的前進方向
? */
?public void changeDistation() {
??direction = -1 * direction;
?}


?/**
? * 構造函數,設置螞蟻的初始前進方向,和初始位置
? * @param position
? * @param direction
? */
?public Ant(int position, int direction) {
??this.position = position;
??if (direction != 1) {
???this.direction = -1;//方向設置初始位置,比如為0時,也將其設置為1.這樣可以方便后面的處理
??} else {
???this.direction = 1;
??}
?}

}

?

/////////////////////////////////////////////////////////


package baidu;

public class Controller {

?public static void main(String[] args) {

??int time = 0;
??for (int i = 0; i < 32; i++) {
???Ant[] antArray = getAntList(getPoistions(), getDirections(i));
???while (!isAllOut(antArray)) {
????for (Ant ant : antArray) {
?????if (!ant.isOut()) {
??????ant.walk();
?????}
????}
????time++;
????// 查看是否有已經相遇的Ant,如果有則更改其前進方向
????dealEncounter(antArray);
???}
???System.out.println(time);

???// 將時間歸0,這樣可以重新設置條件,再次得到全部走完所需要的時間.
???time = 0;
??}

?}

?/**
? * 這個函數的算法很亂,但暫時能解決問題
? *
? * @param list
? */
?public static void dealEncounter(Ant[] antArray) {

??int num_ant = antArray.length;
??for (int j = 0; j < num_ant; j++) {
???for (int k = j + 1; k < num_ant; k++) {
????if (antArray[j].isEncounter(antArray[k])) {
?????antArray[j].changeDistation();
?????antArray[k].changeDistation();
????}
???}
??}

?}

?/**
? * 因為有5只Ant,所以組合之后有32種組合.剛好用5位二進制來表示,如果為0則表示Ant往0的方向走 如果為1,則表示往27的方向走
? *
? * 注:在通過Ant的構造函數設置初始值時,通過過濾把0修改成了-1.
? */
?public static int[] getDirections(int seed) {
??int result[] = new int[5];
??result[0] = seed % 2;
??result[1] = seed / 2 % 2;
??result[2] = seed / 4 % 2;
??result[3] = seed / 8 % 2;
??result[4] = seed / 16 % 2;

??System.out.println("directions is " + result[0] + "|" + result[1] + "|"
????+ result[2] + "|" + result[3] + "|" + result[4]);

??return result;

?}

?/**
? * 批量設置Ant的初始位置,這樣設置不是十分必要,可以直接在代碼中設置
? *
? * @return
? */
?public static int[] getPoistions() {
??return new int[] { 3, 7, 11, 17, 23 };
?}

?/**
? * 取得設置好初始值的5只Ant
? *
? * @param positions
? * @param directions
? * @return
? */
?public static Ant[] getAntList(int[] positions, int[] directions) {
??Ant ant3 = new Ant(positions[0], directions[0]);
??Ant ant7 = new Ant(positions[1], directions[1]);
??Ant ant11 = new Ant(positions[2], directions[2]);
??Ant ant17 = new Ant(positions[3], directions[3]);
??Ant ant23 = new Ant(positions[4], directions[4]);

??return new Ant[] { ant3, ant7, ant11, ant17, ant23 };
?}

?/**
? * 判斷是否所有的Ant都已經走出了木桿,也就是設置退出條件
? *
? * @param antArray
? * @return
? */
?public static boolean isAllOut(Ant[] antArray) {
??for (Ant ant : antArray) {
???if (ant.isOut() == false) {
????return false;
???}
??}
??return true;
?}
}

?



itspy 2006-11-10 16:46 發表評論
]]>
對Appfuse(struts)的一點反悟http://www.aygfsteel.com/itspy/archive/2006/11/09/80242.htmlitspyitspyThu, 09 Nov 2006 12:31:00 GMThttp://www.aygfsteel.com/itspy/archive/2006/11/09/80242.htmlhttp://www.aygfsteel.com/itspy/comments/80242.htmlhttp://www.aygfsteel.com/itspy/archive/2006/11/09/80242.html#Feedback0http://www.aygfsteel.com/itspy/comments/commentRss/80242.htmlhttp://www.aygfsteel.com/itspy/services/trackbacks/80242.html
最近因為可能的工作需要,又開始學習JAVA相關技術了。因為沒有明確的技術方向,只好還是從高層學習起,學習各種框架設計思想,學習模式。
?
順手從手邊拿起一本Struts書《Struts程序員查詢辭典》,看起里面的MVC講解,說真的這本書講的還真不錯,以前看了好多書都不太明白的東西,這一次看什么就明白什么。想想也可能是因為現在有了一定的實踐經驗,要是我以前拿到這本書,可能也是看不懂。反正這個是無從考證了。
?
說到這使我想起以前的一個笑話,一個傻子買了3個大餅,吃了前兩個都沒吃飽,到第三個才吃飽。于是嘆道:早知道,我就只買第三個了,前兩個餅沒用。
?
我看多半,是因為看的多了,加上之前在公司的實踐學習的原因,才能使我這次看這個MVC一看就能明白書上在說什么。
?
記得以前剛開始看Struts時,還以為struts的FormBean是Model層的,還是一位高手告訴我不對,當時我還不太信(不相信權威^--^),當然不久我就知道是我搞錯了。
?
MVC,其實Struts根本就沒有實現M層。它都是直接使用現有的其它技術。比如M層,就可以使用EJB,或者是DAO模式來實現。從書中,我明白了,原來Model層也分了好幾層,接口層,事務邏輯層,數據訪問層。以前Appfuse中為什么把一個DAO分成好幾塊,以前一直不太明白,這幾塊分別是干嘛的。
?
現在有了一些重新的感悟寫下來,不知道對不對,要有不對的請各位看客指出。
用過Appfuse的應該知道,在src/dao目錄下面有四層,org.appfuse,org.appfuse.dao,org.appfuse.hibernate,org.appfuse.model。其中第一層org.appfuse中放的東西,用處不大,里面放置了些常量定義。另外三層分別定義了,dao的接口,dao的hibernate的實現類,和數據傳遞對象(DTO)。上面這些應該都沒有業務邏輯的處理才對,以前早期開發時由于不太明白Appfuse的分層原則,也不理解Struts分層的Model層是如何劃分的,在這些層中放入了一些業務邏輯。沒有找到對應的單獨的事務邏輯層,這一層應該放在了dao的hibernate的實現類里面了。
?
在Appfuse中,好像添加了一個新的層,應該算做是業務邏輯層,也就是在src/service里面。他里面定義了接口,及接口的實現,還有這一層通用的功能塊。通過我的理解,這一層應該主要是體現業務邏輯。也就是提供給Struts層的Action來進行調用。
?
也就是MVC在Appfuse的Struts版本里面,M實現的是對數據庫的操作及一些領域模型的實現;V就視圖,這個在Appfuse里面沒有什么含糊的;另外C只是相當于一個路由的功能,把不同的請求交給不同的業務邏輯處理,把結果交給不同的VIEW去顯示。然后Appfuse在MC之間添加了一個業務邏輯層(src/service)。
?
最近的學習體會,不知對不對,希望有高手指出不對的地方。


itspy 2006-11-09 20:31 發表評論
]]>
主站蜘蛛池模板: 平遥县| 奉新县| 临朐县| 菏泽市| 称多县| 宜兴市| 红安县| 米易县| 罗定市| 岳阳市| 洛阳市| 兰考县| 齐河县| 兴化市| 瓦房店市| 荣成市| 漠河县| 和田市| 长沙县| 新营市| 石门县| 两当县| 太仓市| 绥宁县| 固原市| 青冈县| 县级市| 泰州市| 西昌市| 稷山县| 陈巴尔虎旗| 安康市| 崇信县| 友谊县| 金乡县| 屏南县| 宁武县| 涿鹿县| 古交市| 屯留县| 托克逊县|