锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产一区二区三区四区,国产a级全部精品,26uuu久久噜噜噜噜http://www.aygfsteel.com/carob/archive/2006/08/15/63766.htmlcarobcarobTue, 15 Aug 2006 12:56:00 GMThttp://www.aygfsteel.com/carob/archive/2006/08/15/63766.htmlhttp://www.aygfsteel.com/carob/comments/63766.htmlhttp://www.aygfsteel.com/carob/archive/2006/08/15/63766.html#Feedback0http://www.aygfsteel.com/carob/comments/commentRss/63766.htmlhttp://www.aygfsteel.com/carob/services/trackbacks/63766.html聽聽聽聽聽聽聽聽聽 浠庣洰鍓嶇殑瓚嬪娍鏉ョ湅錛孫SGI鍦ㄨ蔣浠惰涓氱殑搴旂敤鐩稿綋琚湅濂斤紝ECLIPSE,WAS涔熷叏闈㈤噰鐢∣SGI瑙勮寖浜嗭紝鐢變簬eclipse鑷韓鍦ㄩ噰鐢∣SGI涔嬪墠鏈変竴濂楄嚜鎭扮殑plugin鏈哄埗錛岃岃繖縐嶅嚑涔庡叿澶囨棤闄愭墿鍏呯殑plugin鏈哄埗鎵撳紑浜嗕竴涓法澶х殑plugin甯傚満錛屽啀鍔犱笂OpenSource鐨勪笢椋庯紝浣垮緱eclipse鍑犱箮涓緇烰ava鐨処DE甯傚満銆?br />聽聽聽聽聽聽聽聽 浠?.0eclipse鍏ㄩ潰閲囩敤OSGI寮濮嬶紝渚垮OSGI澶氫簡涓浠界爺絀訛紝鍦ㄤ互eclipse涓鴻儗鏅殑妗岄潰杞歡寮鍙戦鍩燂紝osgi濡傞奔寰楁按錛屼絾鎴戞洿澶氱殑鏄湪鍋欽ava鐨剆erver绔紑鍙戯紝寰堟兂鑳藉鐪嬪埌web棰嗗煙鑳戒粠osgi/Equinox涓緱鍒頒竴浜涚伒鎰燂紝寰堝笇鏈涳紝閭g伒媧葷殑plugin/bundle鏈哄埗鑳藉彂鎸ュ湪web鐨勫墠鍚庣寮鍙戜腑錛屼箣鍓嶅湪TSS涓婃湁浜哄仛浜嗕竴涓嚜縐頒負RSP錛堜笌RCP鐩稿搷搴旓級鐨凞EMO錛屽睍紺轟簡濡備綍鍦╓eb欏甸潰涓仛鍒頒笉閲嶅惎鏈嶅姟鍣ㄦ潵瀹炵幇欏甸潰鏁版嵁鐨勫姩鎬佺粍瑁呭強鏈嶅姟璇鋒眰銆傛垜浠兘鐭ラ亾鍦╡clipse鐨勬彃浠跺紑鍙戜腑錛屾垜浠彲浠ュ崟鐙紑鍙戜竴涓獀iewpart鎴栬呰彍鍗曟潵鎻掑叆鍒扮幇鎴愮殑IDE涓屼繚鎸佺嫭绔嬫э紝濡傛灉榪欑鐗規ц兘鍦╓EB涓疄鐜扮殑璇濓紝閭f槸鐩稿綋鐨勮浜虹殑錛岀幇鍦‥quinox宸茬粡瀹炵幇鐨凮SGI 鐨勫ぇ閮ㄥ垎瑙勮寖錛屼篃鎻愪緵浜嗗serlvet鍙妀sp鐨勬敮鎸侊紝浣嗕粛涓嶅鏂逛究錛屽笇鏈涘湪涓嶄箙浠ュ悗鑳界湅榪欐柟闈㈢殑榪涘睍銆?br />聽聽聽聽聽



carob 2006-08-15 20:56 鍙戣〃璇勮
]]>
SWT涓殑Sytem Tray鐩稿叧澶勭悊http://www.aygfsteel.com/carob/archive/2006/03/19/36076.htmlcarobcarobSun, 19 Mar 2006 08:36:00 GMThttp://www.aygfsteel.com/carob/archive/2006/03/19/36076.htmlhttp://www.aygfsteel.com/carob/comments/36076.htmlhttp://www.aygfsteel.com/carob/archive/2006/03/19/36076.html#Feedback0http://www.aygfsteel.com/carob/comments/commentRss/36076.htmlhttp://www.aygfsteel.com/carob/services/trackbacks/36076.html聽聽聽聽聽聽聽聽聽SWT宸茬粡鎻愪緵浜嗗閮ㄥ垎騫沖彴錛堟瘮濡倃indow錛変笂鐨勭郴緇熸墭鐩樼殑鏀寔銆備絾鏀寔寰楄繕涓嶅濂斤紝鎴戞渶榪戦渶瑕佸湪涓涓亰澶╁伐鍏峰疄鐜癇alloon鏁堟灉(綺橀檮浜庣郴緇熸墭鐩樹笂鐨勪竴涓秷鎭皵娉℃晥鏋滐紝鍦↖M杞歡涓櫘閬嶈鏀寔)錛屾煡涓涓婼WT API,鍒扮洰鍓嶄負涓婂茍娌℃湁鎻愪緵鏀寔銆備絾涓涓ソ娑堟伅鏄湪鏈堝簳浜よ鍑烘潵鐨?.2M6涓紝灝嗗閮ㄥ垎API鍋氳皟鏁達紝澧炲姞瀵笲alloon鐨勬敮鎸併?br />

Milestone聽Plan聽 3.2 聽M6聽March聽 31 ,聽 2006 聽聽

聽Implement聽custom聽draw聽
for 聽table聽and聽tree聽
Implement聽
native 聽drag聽source聽effects聽 for 聽cursor聽
Implement聽ImageTransfer聽support聽
Implement聽Balloon聽tooltips
Implement聽Accessibility聽on聽Mac聽OS聽X聽

聽聽聽聽聽榪欏効鏄疎clipseZone涓婄殑涓涓拡瀵硅繖涓鏁堟灉鐨勬枃绔狅細TrayIcons and ToolTips 聽http://www.eclipsezone.com/eclipse/forums/t66093.rhtml


鐢氳嚦鍦ㄥ畼鏂圭綉绔欎笂錛屽凡緇忔彁渚涗簡榪欎竴涓狝PI鐨凷nippet

//http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet225.java
/*******************************************************************************
聽*聽Copyright聽(c)聽2000,聽2006聽IBM聽Corporation聽and聽others.
聽*聽All聽rights聽reserved.聽This聽program聽and聽the聽accompanying聽materials
聽*聽are聽made聽available聽under聽the聽terms聽of聽the聽Eclipse聽Public聽License聽v1.0
聽*聽which聽accompanies聽this聽distribution,聽and聽is聽available聽at
聽*聽
http://www.eclipse.org/legal/epl-v10.html
聽*
聽*聽Contributors:
聽*聽聽聽聽聽IBM聽Corporation聽-聽initial聽API聽and聽implementation
聽******************************************************************************
*/

package聽org.eclipse.swt.snippets;
聽聽
/*
聽*聽Tooltip聽example聽snippet:聽create聽a聽balloon聽tooltip聽for聽a聽tray聽item
聽*
聽*聽For聽a聽list聽of聽all聽SWT聽example聽snippets聽see
聽*聽
http://www.eclipse.org/swt/snippets/
聽*聽
聽*聽@since聽3.0
*/

import聽org.eclipse.swt.*;
import聽org.eclipse.swt.graphics.*;
import聽org.eclipse.swt.widgets.*;

publicclass聽Snippet225聽{

publicstaticvoid聽main(String[]聽args)聽{
聽聽聽聽Display聽display聽
=new聽Display();
聽聽聽聽Shell聽shell聽
=new聽Shell(display);
聽聽聽聽Image聽image聽
=null;
聽聽聽聽
final聽ToolTip聽tip聽=new聽ToolTip(shell,聽SWT.BALLOON聽|聽SWT.ICON_INFORMATION);
聽聽聽聽tip.setMessage(
"Here聽is聽message聽for聽the聽user.聽When聽the聽message聽is聽too聽long聽it聽wraps.聽I聽should聽say聽something聽cool聽but聽nothing聽comes聽to聽my聽mind.");
聽聽聽聽Tray聽tray聽
=聽display.getSystemTray();
聽聽聽聽
if聽(tray聽!=null)聽{
聽聽聽聽聽聽聽聽TrayItem聽item聽
=new聽TrayItem(tray,聽SWT.NONE);
聽聽聽聽聽聽聽聽image聽
=new聽Image(display,聽Snippet225.class.getResourceAsStream("eclipse.png"));
聽聽聽聽聽聽聽聽item.setImage(image);
聽聽聽聽聽聽聽聽tip.setText(
"Notification聽from聽a聽tray聽item");
聽聽聽聽聽聽聽聽item.setToolTip(tip);
聽聽聽聽}
else{
聽聽聽聽聽聽聽聽tip.setText(
"Notification聽from聽anywhere");
聽聽聽聽聽聽聽聽tip.setLocation(
400,聽400);
聽聽聽聽}

聽聽聽聽Button聽button聽
=new聽Button聽(shell,聽SWT.PUSH);
聽聽聽聽button.setText(
"Press聽for聽balloon聽tip");
聽聽聽聽button.addListener(SWT.Selection,聽
new聽Listener()聽{
聽聽聽聽聽聽聽聽
publicvoid聽handleEvent(Event聽event)聽{
聽聽聽聽聽聽聽聽聽聽聽聽tip.setVisible(
true);
聽聽聽聽聽聽聽聽}

聽聽聽聽}
);
聽聽聽聽button.pack();
聽聽聽聽shell.setBounds(
50,聽50,聽300,聽200);
聽聽聽聽shell.open();
聽聽聽聽
while聽(!shell.isDisposed())聽{
聽聽聽聽聽聽聽聽
if聽(!display.readAndDispatch())聽display.sleep();
聽聽聽聽}

聽聽聽聽
if聽(image聽!=null)聽image.dispose();
聽聽聽聽display.dispose();
}

}

闄ゆ涔嬪錛屼篃鏈夊叾瀹冪殑絎笁鏂笰PI瀹炵幇浜嗘涓鏁堟灉銆傛槸鐢?a >www.novocode.com鎻愪緵鐨凚alloonWindow銆傚叾API鍙湪涓婅堪鐨勭綉绔欎腑鑾峰緱銆?/p>

carob 2006-03-19 16:36 鍙戣〃璇勮
]]>
濡備綍鑾峰彇call stack(璋冪敤鏍?淇℃伅鈥斺斾箣浜?/title><link>http://www.aygfsteel.com/carob/archive/2005/03/13/2027.html</link><dc:creator>carob</dc:creator><author>carob</author><pubDate>Sun, 13 Mar 2005 10:25:00 GMT</pubDate><guid>http://www.aygfsteel.com/carob/archive/2005/03/13/2027.html</guid><wfw:comment>http://www.aygfsteel.com/carob/comments/2027.html</wfw:comment><comments>http://www.aygfsteel.com/carob/archive/2005/03/13/2027.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/carob/comments/commentRss/2027.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/carob/services/trackbacks/2027.html</trackback:ping><description><![CDATA[  浠庤繖鍎垮彲浠ョ湅鍒幫細娉ㄦ剰濡傛灉瀹㈡埛绔▼搴忔病鏈夋樉寮忓湴鎸囧畾婧愭柟娉曞悕鍜屾簮綾誨悕錛屽垯LogRecord 綾誨皢閫氳繃鍒嗘瀽 call stack(璋冪敤鏍?鏉ヨ嚜鍔ㄦ彁鍙栬繖浜涗俊鎭紙鏂規硶<STRONG>getSourceMethodname</STRONG>鍜屾柟娉?STRONG>getSourceClassName</STRONG>錛?鎴戜滑宸茬粡璧板湪姝g‘鐨勯亾璺笂浜嗭紝緇х畫榪芥煡<STRONG>getSourceMethodname()</STRONG>鈥︹︹︹?BR>         <BR> <DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <DIV><IMG id=Codehighlighter1_39_119_Open_Image onclick="this.style.display='none'; Codehighlighter1_39_119_Open_Text.style.display='none'; Codehighlighter1_39_119_Closed_Image.style.display='inline'; Codehighlighter1_39_119_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_39_119_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_39_119_Closed_Text.style.display='none'; Codehighlighter1_39_119_Open_Image.style.display='inline'; Codehighlighter1_39_119_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> String getSourceClassName() </SPAN><SPAN id=Codehighlighter1_39_119_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_39_119_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_65_88_Open_Image onclick="this.style.display='none'; Codehighlighter1_65_88_Open_Text.style.display='none'; Codehighlighter1_65_88_Closed_Image.style.display='inline'; Codehighlighter1_65_88_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_65_88_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_65_88_Closed_Text.style.display='none'; Codehighlighter1_65_88_Open_Image.style.display='inline'; Codehighlighter1_65_88_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (needToInferCaller) </SPAN><SPAN id=Codehighlighter1_65_88_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_65_88_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        inferCaller();<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> sourceClassName;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>    }</SPAN></SPAN></DIV></DIV>      緇х畫<BR> <DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <DIV><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Private method to infer the caller's class and method names</SPAN><SPAN style="COLOR: #008000"><BR><IMG id=Codehighlighter1_94_491_Open_Image onclick="this.style.display='none'; Codehighlighter1_94_491_Open_Text.style.display='none'; Codehighlighter1_94_491_Closed_Image.style.display='inline'; Codehighlighter1_94_491_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_94_491_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_94_491_Closed_Text.style.display='none'; Codehighlighter1_94_491_Open_Image.style.display='inline'; Codehighlighter1_94_491_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> inferCaller() </SPAN><SPAN id=Codehighlighter1_94_491_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_94_491_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    needToInferCaller </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">false</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Get the stack trace.</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">    StackTraceElement stack[] </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Throwable()).getStackTrace();<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> First, search back to a method in the Logger class.</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> ix </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR><IMG id=Codehighlighter1_309_476_Open_Image onclick="this.style.display='none'; Codehighlighter1_309_476_Open_Text.style.display='none'; Codehighlighter1_309_476_Closed_Image.style.display='inline'; Codehighlighter1_309_476_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_309_476_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_309_476_Closed_Text.style.display='none'; Codehighlighter1_309_476_Open_Image.style.display='inline'; Codehighlighter1_309_476_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000"> (ix </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> stack.length) </SPAN><SPAN id=Codehighlighter1_309_476_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_309_476_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        StackTraceElement frame </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> stack[ix];<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        String cname </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> frame.getClassName();<BR><IMG id=Codehighlighter1_446_462_Open_Image onclick="this.style.display='none'; Codehighlighter1_446_462_Open_Text.style.display='none'; Codehighlighter1_446_462_Closed_Image.style.display='inline'; Codehighlighter1_446_462_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_446_462_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_446_462_Closed_Text.style.display='none'; Codehighlighter1_446_462_Open_Image.style.display='inline'; Codehighlighter1_446_462_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (cname.equals(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">java.util.logging.Logger</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)) </SPAN><SPAN id=Codehighlighter1_446_462_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_446_462_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        ix</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>鈥︹︹︹︹︹?BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>鈥︹︹︹︹︹?/SPAN></DIV></DIV></SPAN>      鐩磋嚦榪欏効錛屾垜浠粓浜庡彲浠ユ澗涓鍙f皵浜嗭紝鍥犱負鎴戜滑宸茬粡鎵懼埌浜嗗叾涓殑鍏抽敭<BR> <DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <DIV><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>    StackTraceElement stack[] </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Throwable()).getStackTrace();</SPAN></DIV></DIV>   <BR>      娌¢敊錛屽氨鏄繖涓猄tackTraceElement鏁扮粍璁拌澆浜嗘垜浠兂瑕佺殑淇℃伅錛堢被鍚嶏紝鏂規硶鍚嶇瓑錛夛紝榪欏拰鎴戜滑鐢ㄥ埌鐨凟xception綾諱腑鐨勬樉紺鴻皟鐢ㄦ爤鏄竴涓亾鐞嗙殑銆?BR><BR>      娉ㄦ剰錛氳繖鍎塊氳繃鍒涘緩涓涓猅hrowable瀹炰緥錛屽茍鍒╃敤鍦═hrowable綾諱腑鎻愪緵榪欎釜getStackTrace()鏂規硶錛岃繑鍥炴槸StackTraceElement鏁扮粍鏉ヨ幏鍙栧埌浜嗚皟鐢ㄦ爤淇℃伅銆?BR><BR>      鎴戜滑鏉ョ湅涓涓皬渚嬪瓙<BR> <DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <DIV><IMG id=Codehighlighter1_23_227_Open_Image onclick="this.style.display='none'; Codehighlighter1_23_227_Open_Text.style.display='none'; Codehighlighter1_23_227_Closed_Image.style.display='inline'; Codehighlighter1_23_227_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_23_227_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_23_227_Closed_Text.style.display='none'; Codehighlighter1_23_227_Open_Image.style.display='inline'; Codehighlighter1_23_227_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> CallStack </SPAN><SPAN id=Codehighlighter1_23_227_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_23_227_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_48_116_Open_Image onclick="this.style.display='none'; Codehighlighter1_48_116_Open_Text.style.display='none'; Codehighlighter1_48_116_Closed_Image.style.display='inline'; Codehighlighter1_48_116_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_48_116_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_48_116_Closed_Text.style.display='none'; Codehighlighter1_48_116_Open_Image.style.display='inline'; Codehighlighter1_48_116_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    String showTrace() </SPAN><SPAN id=Codehighlighter1_48_116_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_48_116_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Throwable().getStackTrace()[</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">].toString();<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_162_225_Open_Image onclick="this.style.display='none'; Codehighlighter1_162_225_Open_Text.style.display='none'; Codehighlighter1_162_225_Closed_Image.style.display='inline'; Codehighlighter1_162_225_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_162_225_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_162_225_Closed_Text.style.display='none'; Codehighlighter1_162_225_Open_Image.style.display='inline'; Codehighlighter1_162_225_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String[] args) </SPAN><SPAN id=Codehighlighter1_162_225_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_162_225_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> CallStack().showTrace());<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV>      <BR>      鎵撳嵃濡備笅<BR>      chapter5.CallStack.showTrace(CallStack.java:5)<BR><BR>      鎴戜滑浜﹀彲浠ラ氳繃榪欐牱涓涓畝鍗曞湴瀹炰緥鍖栦竴涓猅hrowable鏉ヨ幏鍙栫浉搴旂殑call strack銆?BR>      涓嶈繃錛屼竴鑸殑搴旂敤綰х▼搴忛噷闈笉澶細鐢ㄥ埌瀹冿紝鍙兘鍦ㄥ伐鍏風駭杞歡閲岄潰鐢ㄥ緱澶氫竴鐐逛簡錛氾級<BR><img src ="http://www.aygfsteel.com/carob/aggbug/2027.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/carob/" target="_blank">carob</a> 2005-03-13 18:25 <a href="http://www.aygfsteel.com/carob/archive/2005/03/13/2027.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>濡備綍鑾峰彇call stack(璋冪敤鏍?淇℃伅鈥斺斾箣涓http://www.aygfsteel.com/carob/archive/2005/03/13/2025.htmlcarobcarobSun, 13 Mar 2005 09:58:00 GMThttp://www.aygfsteel.com/carob/archive/2005/03/13/2025.htmlhttp://www.aygfsteel.com/carob/comments/2025.htmlhttp://www.aygfsteel.com/carob/archive/2005/03/13/2025.html#Feedback0http://www.aygfsteel.com/carob/comments/commentRss/2025.htmlhttp://www.aygfsteel.com/carob/services/trackbacks/2025.html         
         鎴戜滑鍏堟潵鐪嬩竴孌典唬鐮?BR>
鈥︹︹︹?BR>鈥︹︹︹?BR>void doSomething(){
     logger.info(
"doSomething()璋冪敤鎴愬姛");
}

鈥︹︹︹?BR>鈥︹︹︹?/SPAN>
榪欐槸鎴戞渶甯歌鐨勬棩蹇楄褰曟柟寮忋?BR>
      鎴戜笅闈㈠氨寮濮嬫垜浠殑榪借釜浠ユ煡鍑簂ogging API鏄浣曡褰曚笂闈㈡彁鍒扮殑榪欎簺metadata鐨勩?BR>
      榪欏効浠DK1.4涓殑logging API涓虹爺絀跺璞°?BR>
      鍏堣繘鍏ava.util.logging.Logger涓紝鐪嬩竴涓媔nfo(String msg)榪欎釜鏂規硶
    public void info(String msg) {
    
if (Level.INFO.intValue() < levelValue) {
        
return;
    }

    log(Level.INFO, msg);
    }
      緇х畫榪借釜
    public void log(Level level, String msg) {
    
if (level.intValue() < levelValue || levelValue == offValue) {
        
return;
    }

    LogRecord lr 
= new LogRecord(level, msg);
    doLog(lr);
    }

榪欏効鎴戜滑鍙戠幇浜嗕竴涓煎緱鍏蟲敞鐨勭被 LogRecord ,浠庡悕瀛椾笂鐚滃簲璇ユ槸鍜屾棩蹇椾俊鎭湁鍏崇殑涓涓被銆傛垜浠潵鐪嬩竴涓嬪畠鐨凧avadoc涓殑鎻忚堪
/**
 * LogRecord objects are used to pass logging requests between
 * the logging framework and individual log Handlers.
 * <p>
 * When a LogRecord is passed into the logging framework it 
 * logically belongs to the framework and should no longer be
 * used or updated by the client application.
 * <p>
 * Note that if the client application has not specified an
 * explicit source method name and source class name, then the
 * LogRecord class will infer them automatically when they are
 * first accessed (due to a call on getSourceMethodName or
 * getSourceClassName) by analyzing the call stack.  
   
        浠庤繖鍎垮彲浠ョ湅鍒幫細娉ㄦ剰濡傛灉瀹㈡埛绔▼搴忔病鏈夋樉寮忓湴鎸囧畾婧愭柟娉曞悕鍜屾簮綾誨悕錛屽垯LogRecord 綾誨皢閫氳繃鍒嗘瀽 call stack(璋冪敤鏍?鏉ヨ嚜鍔ㄦ彁鍙栬繖浜涗俊鎭紙鏂規硶getSourceMethodname鍜屾柟娉?STRONG>getSourceClassName錛?鎴戜滑宸茬粡璧板湪姝g‘鐨勯亾璺笂浜嗭紝緇х畫榪芥煡getSourceMethodname()鈥︹︹︹?BR>         
    錛堟湭瀹岋級

carob 2005-03-13 17:58 鍙戣〃璇勮
]]>
搴旂敤Java Dynamic Proxy 瀹炵幇綾繪柟娉曠殑鎷︽埅(AOP)http://www.aygfsteel.com/carob/archive/2005/03/04/1678.htmlcarobcarobFri, 04 Mar 2005 02:37:00 GMThttp://www.aygfsteel.com/carob/archive/2005/03/04/1678.htmlhttp://www.aygfsteel.com/carob/comments/1678.htmlhttp://www.aygfsteel.com/carob/archive/2005/03/04/1678.html#Feedback0http://www.aygfsteel.com/carob/comments/commentRss/1678.htmlhttp://www.aygfsteel.com/carob/services/trackbacks/1678.html
姣斿鎴戜滑鐜版湁涓瀵笽nterface/Implemention錛歋peakable/Translater銆?BR>Speakable鎺ュ彛鎸囨槑浜嗗彲浠ayEnglish(),sayChinese()銆傛垜浠洰鍓嶇殑translater瀹炵幇浜嗚繖涓や釜鏂規硶銆傜幇鍦ㄦ垜浠湪姝ゅ熀紜涓婏紝澧炲姞瀵箃ranslater鐨勬柟娉曠殑logging鍔熻兘銆?BR>
鍦ㄤ互鍓嶏紝鎴戜滑鍙互錛?BR>
1.鐩存帴鏀瑰啓鍘熶唬鐮侊紝澧炲姞logging鍔熻兘銆?ugly)
2.澧炲姞涓涓狶oggingTranlater瀹炵幇Speakable,閲囩敤delegation(Design Pattern)錛屽鏂規硶榪涜澧炲己銆傚姝ょ被proxy鍙互鍙傝僯ive錛屽叾涓亶甯僷roxy 銆傜己鐐瑰氨鏄瘡涓涓澧炲姞鐨勭被閮借瀹炵幇涓涓唬鐞嗙被錛屽彲浠ユ兂璞★紝浠g爜閲忔ュ墽鑶ㄨ儉銆?BR>
鐜板湪璁╂垜浠潵鐪嬬湅Java Dynamic Proxy鏄浣曡揪鍒拌繖涓鐐圭殑錛屽0鏄庢垜緇欏嚭鐨勪唬鐞嗘槸紺轟緥鎬х殑錛屾瘮杈冪畝闄嬶紝涓昏鏄粰鍑轟竴涓疄鐜版柟娉曪紝鍔犱互鏀硅繘錛屽嵆鍙艦鎴愪竴涓瘮杈冮氱敤鐨勫伐鍏楓?BR>
鍏堟潵鐪嬬湅鎴戜滑鐨処nterface/Implemention瀵癸細

package reflection.example;

public interface Speakable {
    
void sayEnglish();

    
void sayChinese();
}


package reflection.example;

public class Translater implements Speakable {

    
public void sayEnglish() {
        System.
out.println("Hello,i am robbie");

    }


    
public void sayChinese() {
        System.
out.println("浣犲ソ錛屾垜鏄ズ瀛?/SPAN>");

    }


}


鐜板湪鎴戜滑瑕佽繘琛宭ogging鍔熻兘浜嗭紝璁頒綇錛屾垜浠彧闇鎻愪緵涓涓狪nvocationHandler:

package reflection.example;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class LoggingInvoktionHandler implements InvocationHandler {
    
private Object target = null;

    
public LoggingInvoktionHandler(Object target) {
        
this.target = target;
    }


    
public Object invoke(Object proxy, Method method, Object[] args)
            throws Throwable 
{
        logging(method);
        
return method.invoke(target, args);
    }


    
private void logging(Method method) {
        
if ("sayChinese".equals(method.getName())) {
            System.
out.println("緲昏瘧寮濮?/SPAN>");
        }


        
if ("sayEnglish".equals(method.getName())) {
            System.
out.println("Tranlation beginning");
        }

    }


}


榪欎釜LoggingInvocationHandler瀹炵幇浜咺nvocationHandler鎺ヤ腑銆傛柟娉曠殑浠g悊璋冪敤鍦╥nvoke(鈥︹?涓紝鍙互濡傛垜娣誨姞logging()鍔熻兘涓鏍鳳紝鍔犲叆鍏跺畠鐨勪換浣曟兂瑕佺殑鍔熻兘錛岀劧鍚庡啀榪涜 real target鐨勬柟娉曡皟鐢ㄣ?BR>
濡傛灉灝唋ogging(Method method)涓殑閫昏緫鎶藉嚭鏉ワ紝鏀懼埌澶栭儴鏂囦歡(XML)涓繘琛岄厤緗鍙栥傚啀瀵規柟娉曞悕閲囩敤姝e垯琛ㄨ揪寮忋傛槸涓嶆槸鏇翠負閫氱敤浜嗗憿錛?/P>

涓嬮潰鏄鎴風璋冪敤錛?BR>

package reflection.example;

import java.lang.reflect.Proxy;

public class Main {

    
/**
     * @param args
     
*/

    
public static void main(String[] args) {
        Speakable speaker 
= new Translater();

        Speakable loggingSpeaker 
= (Speakable) Proxy.newProxyInstance(
                speaker.getClass().getClassLoader(),
                
new Class[] { Speakable.class },
                
new LoggingInvoktionHandler(speaker));

        loggingSpeaker.sayChinese();
        loggingSpeaker.sayEnglish();
    }

}



鏄笉鏄潪甯哥畝鍗曞憿錛燂細)

濡傛灉鍒版涓烘錛岃繕鏄湅涓嶅嚭Dynamic鍦ㄥ摢鍎跨殑錛屾兂鎯蟲垜榪欏効緇欏嚭鐨勭ず渚嬩笌spring鐨凙OP鐨勪笉鍚岋紝鍛靛懙錛屽尯鍒湪浜庢垜榪欏効緇欏嚭鐨凪ain浜︽槸spring AOP鐨勪竴閮ㄥ垎錛屽湪spring閲岋紝 瀵規煇涓狪nterface鐨則arget鐨勪唬鐞嗭紝閲囩敤浜哛eflection錛屼互杈懼埌鏅亶閫傜敤鐨勶紝涓嶇敤璞℃垜榪欐牱鐩存帴鏄懼紡鍦扮粰鍑虹被鍚嶈屽凡銆傝嫢鎴戞妸Main鍋氭垚涓涓狧elper綾伙紝鍚屾椂錛屾妸閰嶇疆鎺ュ彛鍙婁粬鐨勫疄鐜扮被閮芥斁鍒板閮╔ML涓厤緗紝鏄笉鏄氨鏈夌偣璞′竴涓秴綰х畝鍖栫殑spring AOP浜嗭紵

褰撶劧spring涓嶆槸瀹屽叏鐢↗ava Dynamic Proxy鐨勶紝鍥犱負Java Dynamic Proxy鐨勫墠鎻愨斺?STRONG>閽堝鎺ュ彛緙栫▼錛侊紝閽堝鏅氱殑綾葷殑AOP錛孲pring閲囩敤浜嗗瓧鑺傜爜澧炲己鏉ュ疄鐜般?BR>



carob 2005-03-04 10:37 鍙戣〃璇勮
]]>
閫氳繃Java Reflection 鑾峰彇鎸囧畾static鍙橀噺鐨勫?/title><link>http://www.aygfsteel.com/carob/archive/2005/03/04/1675.html</link><dc:creator>carob</dc:creator><author>carob</author><pubDate>Fri, 04 Mar 2005 01:28:00 GMT</pubDate><guid>http://www.aygfsteel.com/carob/archive/2005/03/04/1675.html</guid><wfw:comment>http://www.aygfsteel.com/carob/comments/1675.html</wfw:comment><comments>http://www.aygfsteel.com/carob/archive/2005/03/04/1675.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/carob/comments/commentRss/1675.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/carob/services/trackbacks/1675.html</trackback:ping><description><![CDATA[姣斿錛氭湁涓涓猄QLUtil綾伙紝鏄竴涓狧ibernate欏圭洰涓殑鐢ㄦ潵瀛樺偍涓緋誨垪sql鐨勭被錛岀殕涓哄父閲忋傚湪鍏跺畠鐨勭被涓彲浠ユ牴鎹彉閲忕殑鍚嶇О鏉ョ儲寮曠浉搴旂殑鍊鹼紝闂鍦ㄤ簬鍚嶇О鍦ㄥ彟澶栫殑綾諱腑浜︿負鍙橀噺錛岀洿鎺ョ儲寮曟槸娌℃湁鍔炴硶鐨勶紝浣嗗彲浠ラ忚繃Java Reflection闈炲父鏂逛究鐨勫疄鐜般傜粰鍑虹殑鏄ず鎰忔т唬鐮侊紝鐩稿簲鐨凟xception澶勭悊鏄劇劧涓嶅 <STRONG>elegant</STRONG><BR> <DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <DIV><IMG id=Codehighlighter1_0_153_Open_Image onclick="this.style.display='none'; Codehighlighter1_0_153_Open_Text.style.display='none'; Codehighlighter1_0_153_Closed_Image.style.display='inline'; Codehighlighter1_0_153_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_0_153_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_153_Closed_Text.style.display='none'; Codehighlighter1_0_153_Open_Image.style.display='inline'; Codehighlighter1_0_153_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN id=Codehighlighter1_0_153_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_0_153_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Created on 2005-3-3<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> *<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * TODO To change the template for this generated file go to<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Window - Preferences - Java - Code Style - Code Templates<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top> </SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>package reflection;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_176_331_Open_Image onclick="this.style.display='none'; Codehighlighter1_176_331_Open_Text.style.display='none'; Codehighlighter1_176_331_Closed_Image.style.display='inline'; Codehighlighter1_176_331_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_176_331_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_176_331_Closed_Text.style.display='none'; Codehighlighter1_176_331_Open_Image.style.display='inline'; Codehighlighter1_176_331_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_176_331_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_176_331_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000">*<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * @author ruby<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> *<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * TODO To change the template for this generated type comment go to<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Window - Preferences - Java - Code Style - Code Templates<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top> </SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_354_409_Open_Image onclick="this.style.display='none'; Codehighlighter1_354_409_Open_Text.style.display='none'; Codehighlighter1_354_409_Closed_Image.style.display='inline'; Codehighlighter1_354_409_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_354_409_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_354_409_Closed_Text.style.display='none'; Codehighlighter1_354_409_Open_Image.style.display='inline'; Codehighlighter1_354_409_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> SQLUtil </SPAN><SPAN id=Codehighlighter1_354_409_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_354_409_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> final String SELECT_SQL</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">from Ruby</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></DIV><BR> <DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"> <DIV><IMG id=Codehighlighter1_0_153_Open_Image onclick="this.style.display='none'; Codehighlighter1_0_153_Open_Text.style.display='none'; Codehighlighter1_0_153_Closed_Image.style.display='inline'; Codehighlighter1_0_153_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_0_153_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_0_153_Closed_Text.style.display='none'; Codehighlighter1_0_153_Open_Image.style.display='inline'; Codehighlighter1_0_153_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN id=Codehighlighter1_0_153_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_0_153_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Created on 2005-3-3<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> *<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * TODO To change the template for this generated file go to<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Window - Preferences - Java - Code Style - Code Templates<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top> </SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>package reflection;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top>import java.lang.reflect.Field;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_209_365_Open_Image onclick="this.style.display='none'; Codehighlighter1_209_365_Open_Text.style.display='none'; Codehighlighter1_209_365_Closed_Image.style.display='inline'; Codehighlighter1_209_365_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_209_365_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_209_365_Closed_Text.style.display='none'; Codehighlighter1_209_365_Open_Image.style.display='inline'; Codehighlighter1_209_365_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_209_365_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_209_365_Open_Text><SPAN style="COLOR: #008000">/*</SPAN><SPAN style="COLOR: #008000">*<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * @author ruby<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * TODO To change the template for this generated type comment go to Window -<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top> * Preferences - Java - Code Style - Code Templates<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top> </SPAN><SPAN style="COLOR: #008000">*/</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_388_821_Open_Image onclick="this.style.display='none'; Codehighlighter1_388_821_Open_Text.style.display='none'; Codehighlighter1_388_821_Closed_Image.style.display='inline'; Codehighlighter1_388_821_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_388_821_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_388_821_Closed_Text.style.display='none'; Codehighlighter1_388_821_Open_Image.style.display='inline'; Codehighlighter1_388_821_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> Manager </SPAN><SPAN id=Codehighlighter1_388_821_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_388_821_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> String getValue(String sqlName) throws SecurityException,<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>            NoSuchFieldException, IllegalArgumentException,<BR><IMG id=Codehighlighter1_541_624_Open_Image onclick="this.style.display='none'; Codehighlighter1_541_624_Open_Text.style.display='none'; Codehighlighter1_541_624_Closed_Image.style.display='inline'; Codehighlighter1_541_624_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_541_624_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_541_624_Closed_Text.style.display='none'; Codehighlighter1_541_624_Open_Image.style.display='inline'; Codehighlighter1_541_624_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            IllegalAccessException </SPAN><SPAN id=Codehighlighter1_541_624_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_541_624_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        Field f </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> SQLUtil.</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">.getField(sqlName);<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> f.</SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">).toString();<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String[] args) throws SecurityException,<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>            NoSuchFieldException, IllegalArgumentException,<BR><IMG id=Codehighlighter1_770_819_Open_Image onclick="this.style.display='none'; Codehighlighter1_770_819_Open_Text.style.display='none'; Codehighlighter1_770_819_Closed_Image.style.display='inline'; Codehighlighter1_770_819_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_770_819_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_770_819_Closed_Text.style.display='none'; Codehighlighter1_770_819_Open_Image.style.display='inline'; Codehighlighter1_770_819_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>            IllegalAccessException </SPAN><SPAN id=Codehighlighter1_770_819_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_770_819_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        System.</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">.println(getValue(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">SELECT_SQL</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV></DIV><img src ="http://www.aygfsteel.com/carob/aggbug/1675.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/carob/" target="_blank">carob</a> 2005-03-04 09:28 <a href="http://www.aygfsteel.com/carob/archive/2005/03/04/1675.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎼埌鏂板鏉ワ細)http://www.aygfsteel.com/carob/archive/2005/02/28/1562.htmlcarobcarobMon, 28 Feb 2005 12:10:00 GMThttp://www.aygfsteel.com/carob/archive/2005/02/28/1562.htmlhttp://www.aygfsteel.com/carob/comments/1562.htmlhttp://www.aygfsteel.com/carob/archive/2005/02/28/1562.html#Feedback0http://www.aygfsteel.com/carob/comments/commentRss/1562.htmlhttp://www.aygfsteel.com/carob/services/trackbacks/1562.html銆?BR>鈥滃崥瀹㈠洯鈥濊繕搴斿仛寰楀啀涓撲笟涓鐐規墠琛岋紝娉ㄥ唽鐨勬椂鍊欙紝鎸夌潃鎻愮ず璧幫紝绔熺劧瀵艱埅鏄敊璇殑錛屾敞鍐屽埌鍏跺畠鍦版柟鍘諱簡銆?img src ="http://www.aygfsteel.com/carob/aggbug/1562.html" width = "1" height = "1" />

carob 2005-02-28 20:10 鍙戣〃璇勮
]]>
Groovlets http://www.aygfsteel.com/carob/archive/2005/02/28/1564.htmlcarobcarobMon, 28 Feb 2005 03:18:00 GMThttp://www.aygfsteel.com/carob/archive/2005/02/28/1564.htmlhttp://www.aygfsteel.com/carob/comments/1564.htmlhttp://www.aygfsteel.com/carob/archive/2005/02/28/1564.html#Feedback0http://www.aygfsteel.com/carob/comments/commentRss/1564.htmlhttp://www.aygfsteel.com/carob/services/trackbacks/1564.html浣犺兘鍦℅roovy閲岄潰鍐欐櫘閫氱殑Java Servlet銆?BR>瀛樺湪涓涓?STRONG>GroovyServlet錛岃嚜鍔ㄧ紪璇?groovy鏂囦歡錛岃漿鍙樻垚瀛楄妭鐮侊紝瑁呰澆綾伙紝騫剁紦瀛樺畠浠紝鐩村埌淇敼浜嗘簮鏂囦歡銆?BR>榪欏効鏈変竴涓畝鍗曠殑渚嬪瓙鏉ュ悜浣犺鏄庤繖浜嬶細
(娉ㄦ剰璁塊棶session,output,request鐨勯殣寮忓彉閲忕殑鐢ㄦ硶)

import java.util.Date

if (session.counter == null{
  session.counter 
= 1
}


println 
"""
<html>
    
<head>
        
<title>Groovy Servlet</title>
    
</head>
    
<body>
Hello, $
{request.remoteHost}: ${session.counter}! ${new Date()}
    
</body>
</html>
"""
session.counter = session.counter + 1
鎴栬咃紝鐢∕arkupBuilder瀹屾垚鐩稿悓鐨勫姛鑳?BR>
import java.util.Date
import groovy.xml.MarkupBuilder

if (session.counter == null{
      session.counter 
= 1
}


html.html 
{    // html is implicitly bound to new MarkupBuilder(out)
  head {
      title(
"Groovy Servlet")
  }

  body 
{
    p(
"Hello, ${request.remoteHost}: ${session.counter}! ${new Date()}")
  }

}

session.counter 
= session.counter + 1

闅愬紡鍙橀噺

o_implicit variables.jpg

* 榪欎簺鍙橀噺鍦╣roovylet閲岄潰涓嶈兘琚啀嬈¤祴鍊箋備粬浠湪絎竴嬈¤闂椂琚粦瀹氾紝鍏佽璇稿鍦ㄧ敤"out"涔嬪墠璋冪敤瀵硅薄"response"鐨勬柟娉曘?BR>
寤虹珛Groovylet

灝嗕笅闈㈡斁鍏eb.xml涓?BR>
<servlet>
<servlet-name>Groovy</servlet-name>
<servlet-class>groovy.servlet.GroovyServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Groovy</servlet-name>
<url-pattern>*.groovy</url-pattern>
</servlet-mapping>

鐒跺悗錛屾墍鏈塯roovy jar鏂囦歡鏀懼埌WEB/lib鐩綍涓?鍙渶鏀懼叆groovy.jar鍜宎sm.jar鍗沖彲)

鎶?groovy鏂囦歡鏀懼叆鏍圭洰褰?鏀緃tml鏂囦歡鐨勫湴鏂?涓紝groovy servlet灝嗕細鐓х榪欎簺.groovy鏂囦歡

灝辮繖涓緥瀛愪嬌鐢╰omcat鏉ヨ錛岃緙栬緫tomcat/conf/server.xml 錛岀被浼間簬涓嬮潰榪欐牱

<Context path="/groovy" docBase="c:/groovy-servlet"/>




carob 2005-02-28 11:18 鍙戣〃璇勮
]]>
GSQLhttp://www.aygfsteel.com/carob/archive/2005/02/28/1565.htmlcarobcarobMon, 28 Feb 2005 02:26:00 GMThttp://www.aygfsteel.com/carob/archive/2005/02/28/1565.htmlhttp://www.aygfsteel.com/carob/comments/1565.htmlhttp://www.aygfsteel.com/carob/archive/2005/02/28/1565.html#Feedback0http://www.aygfsteel.com/carob/comments/commentRss/1565.htmlhttp://www.aygfsteel.com/carob/services/trackbacks/1565.html涓句緥錛?BR>
/**
 * Test to verify valid construction of default DDL
 * 
 * @author <a href="mailto:jeremy.rayner@bigfoot.com">Jeremy Rayner</a>
 * @version $Revision: 1.2 $
 
*/

package org.javanicus.gsql

import java.io.
*

class SqlGeneratorTest extends GroovyTestCase {
    property database
    property sqlGenerator
              
    
void setUp() {
        typeMap 
= new TypeMap()          
        build 
= new RelationalBuilder(typeMap)
        sqlGenerator 
= new SqlGenerator(typeMap,System.getProperty( "line.separator""\n" ))
                  
        database 
= build.database(name:'genealogy'{
          table(name:
'event'{
              column(name:
'event_id', type:'integer', size:10, primaryKey:true, required:true)
              column(name:
'description', type:'varchar', size:30)          
          }

          table(name:
'individual'{
            column(name:
'individual_id', type:'integer', size:10, required:true, primaryKey:true, autoIncrement:true)
            column(name:
'surname', type:'varchar', size:15, required:true)
            column(name:
'event_id', type:'integer', size:10)
            foreignKey(foreignTable:
'event'{
                reference(local:
'event_id',foreign:'event_id')
            }

            index(name:
'surname_index'{
                indexColumn(name:
'surname')
            }

          }

        }

    }

    
    
void testGenerateDDL() {
        testWriter 
= new PrintWriter(new FileOutputStream("SqlGeneratorTest.sql"))
        sqlGenerator.writer 
= testWriter
        sqlGenerator.createDatabase(database,
true)
        testWriter.flush()
   }


}


carob 2005-02-28 10:26 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 平罗县| 正定县| 宁阳县| 清徐县| 十堰市| 奉贤区| 丹江口市| 泗洪县| 康乐县| 正蓝旗| 石狮市| 宁陕县| 泰顺县| 防城港市| 五原县| 集安市| 东乡县| 舞阳县| 商水县| 临高县| 瑞金市| 荆门市| 无为县| 乡宁县| 彭阳县| 修水县| 康保县| 石河子市| 扶沟县| 门源| 册亨县| 文成县| 绥江县| 灵石县| 长寿区| 隆尧县| 忻城县| 泾源县| 玉门市| 东光县| 五台县|