锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产综合专区电影在线,亚洲精品456人成在线,亚洲色图.comhttp://www2.blogjava.net/kapok/category/891.html鍨冨溇妗?鍢垮樋錛屾垜钘忕殑榪欎箞娣變綘浠繕鑳芥壘鍒板晩錛岀湡鐗涳紒zh-cnWed, 28 Feb 2007 03:24:36 GMTWed, 28 Feb 2007 03:24:36 GMT60杞繪澗榪涜Java Portlets 寮鍙戝熀浜嶫SR 168鐨勫紑鍙戝拰閮ㄧ講 http://www.tkk7.com/kapok/archive/2005/04/22/3630.html絎ㄧ絎ㄧFri, 22 Apr 2005 13:55:00 GMThttp://www.tkk7.com/kapok/archive/2005/04/22/3630.htmlhttp://www.tkk7.com/kapok/comments/3630.htmlhttp://www.tkk7.com/kapok/archive/2005/04/22/3630.html#Feedback0http://www.tkk7.com/kapok/comments/commentRss/3630.htmlhttp://www.tkk7.com/kapok/services/trackbacks/3630.htmlhttp://dev2dev.bea.com.cn/techdoc/webplat/200410224.html

鎽樿
銆銆Portlet鏄敓鎴愮墖孌碉紙閬靛畧鐗瑰畾瑙勮寖鐨勬爣璁拌璦錛堝HTML銆乆ML錛夌殑鐗囨錛夌殑Web緇勪歡銆傜墖孌靛啀鍚堟垚涓涓畬鏁寸殑鏂囨。銆傛湰鏂囦粙緇嶄簡鍏充簬Java Portlet鐨凧ava Specification Request (JSR) 168瑙勮寖銆傚畠璇存槑浜嗗浣曚嬌鐢˙EA WebLogic Workshop 8.1 SP2鏉ュ垱寤篔ava Portlet錛屼互鍙?qiáng)濡備綍灏啒q欎簺portlet閮ㄧ講鍒癇EA WebLogic Portal 8.1 Sp2涓娿傛垜灝嗕粙緇嶄竴浜涘叧閿蹇碉紝濡傞棬鎴楓佹闈㈠拰portlet錛屽茍璇︾粏鎻忚堪澶氱portlet妯″紡鍜岀獥鍙g姸鎬併傛垜榪樺皢浠嬬粛濡備綍浣跨敤Workshop鏉ヨ璁°佸疄鐜般侀厤緗拰鎵цportlet銆?BR>

銆銆JSR 168瀹氫箟浜嗘湁鍏矹ava Portlet鐨勮鑼冦傞棬鎴鋒槸涓涓猈eb搴旂敤紼嬪簭鍜屼竴涓猵ortlet鐨勮仛鍚堛侾ortlet瀹瑰櫒榪愯portlet錛屽茍綆$悊瀹冧滑鐨勭敓鍛藉懆鏈熴侸SR 168瀹氫箟浜唒ortlet涓巔ortlet瀹瑰櫒涔嬮棿鐨勫綰︼紝瀹冩病鏈夊畾涔塸ortlet瀹瑰櫒涓庨棬鎴蜂箣闂寸殑濂戠害銆傞棬鎴風(fēng)殑瀹炵幇鐣欑粰浜嗛棬鎴蜂緵搴斿晢銆?BR>
銆銆BEA WebLogic闂ㄦ埛
銆銆BEA WebLogic Portal (8.1 SP2)鐨勫綋鍓嶇増鏈敮鎸佷笉鍚岀被鍨嬬殑portlet錛欽SP/HTML portlet銆丣ava PageFlow portlet銆丼truts portlet鍜孞ava portlet錛屽皢鏉ヨ繕浼?xì)鏀寔鍏朵粬portlet錛屽Web Services for Remote Portlets (WSRP)銆傛垜浠皢鐫閲嶄粙緇岼ava portlet銆?BR>
銆銆WebLogic Portal鎻愪緵浜咼SR 168涓湭鎻忚堪鐨勯棬鎴峰姛鑳斤紝鍖呮嫭浣嗕笉闄愪簬錛氫功鍜岄〉闈腑portlet鐨勭粍緇囥佸娓犻亾鏀寔鍜屼嬌鐢╯kin銆乻keleton鍜宻hell瀹氬埗銆?BR>
銆銆涓轟簡鑳藉緇х畫涓嬪幓錛屽湪榪涜涓嬩竴閮ㄥ垎涔嬪墠錛岃鍏堝畬鎴愪互涓嬪唴瀹癸細(xì)
銆銆銆路浣跨敤WebLogic Domain Configuration Wizard鍒涘緩涓涓棬鎴峰煙錛堝JSR168PortalDomain錛夈?
銆銆銆路浣跨敤WebLogic Workshop鍒涘緩涓涓嬌鐢ㄤ笂闈㈡墍寤虹珛鍩熺殑闂ㄦ埛搴旂敤紼嬪簭錛堝JSR168PortalApp錛夈?
銆銆銆路鍦ㄩ棬鎴峰簲鐢ㄧ▼搴忓唴鍒涘緩涓涓棬鎴稺eb欏圭洰錛堝JSR168PortalWebProject錛夈?
銆銆銆路鍦ㄩ棬鎴稺eb欏圭洰涓垱寤轟竴涓猈ebLogic Portal .portal鏂囦歡錛堝JSR168.portal錛夈?
銆銆銆路鍚姩鏈嶅姟鍣ㄥ疄渚嬨?

銆銆鍒涘緩鎮(zhèn)ㄧ殑絎竴涓狫ava Portlet
銆銆涓嬮潰鐨勬楠ゆ弿榪頒簡濡備綍鍒涘緩鎮(zhèn)ㄧ殑絎竴涓狫SR 168 portlet銆?BR>銆銆路鍦ㄩ棬鎴稺eb欏圭洰錛堝JSR168PortalWebProject錛変腑錛屼嬌鐢╓ebLogic Workshop涓簆ortlet錛堝叆FirstPortlet錛夊垱寤轟竴涓柊鏂囦歡澶廣?
銆銆路鍦ㄦ柊鏂囦歡澶瑰唴浣跨敤Wizard閫氳繃鍒涘緩鐩稿簲鐨?portlet鏂囦歡鍒涘緩涓涓柊portlet錛堝Firstportlet錛夈?BR>銆銆路閫夋嫨portlet綾誨瀷涓篔ava Portlet銆?
銆銆路鎸囧畾鏍囬錛堝First錛夈?
銆銆路鎸囧畾瀹氫箟鏍囩錛堝first錛夈?BR>銆銆路鎸囧畾綾誨悕縐幫紙濡俢om.malani.examples.portlets.jsr168.FirstPortlet錛夈?
銆銆路鎵撳紑闂ㄦ埛錛堝JSR168.portal錛夈?
銆銆路灝唒ortlet錛堝Firstportlet錛夋嫋鏀懼埌闂ㄦ埛涓殑欏甸潰涓婏紙濡侸SR168.portal錛夈?
銆銆路榪愯.portal鏂囦歡榪涜嫻嬭瘯銆?

銆銆鎮(zhèn)ㄧ殑絎竴涓狫SR 168 portlet宸茬粡鎴愬姛榪愯浜嗭紒浣嗗悜瀵煎湪鑳屽悗浣滀簡浜涗粈涔堝憿錛?BR>銆銆路瀹冨垱寤轟簡涓涓壒瀹氫簬WebLogic Workshop鍜學(xué)ebLogic Portal鐨?portlet鏂囦歡銆?portlet鏂囦歡鏋勬垚浜嗕笌鐗瑰畾浜嶹orkshop鍜學(xué)ebLogic Portal鐨?portal鏂囦歡鐨勫綰︺?
銆銆路鍚戝鍒涘緩浜嗕竴涓?java鏂囦歡錛堝com.malani.examples.portlets.jsr168.FirstPortlet.java錛夛紝璇ユ枃浠舵斁緗湪WEB-INF/src鐩綍涓?BR>銆銆路鍚戝鍒涘緩浜嗕竴涓猈EB-INF/portlet.xml閰嶇疆鏂囦歡錛屽茍涓簆ortlet鍦ㄦ枃浠朵腑鎻掑叆浜嗕竴涓潯鐩傝portlet鐨勬潯鐩湅涓婂幓濡備笅錛?BR>
<portlet>
<description>Description goes here</description>
<portlet-name>first</portlet-name>
<portlet-class>com.malani.examples.portlets.jsr168.FirstPortlet
</portlet-class>
<portlet-info>
<title>First</title>
</portlet-info>
</portlet>


銆銆Java Portlet綾?/B>
銆銆鍦ㄨ紺轟緥涓紝鍚戝鐢熸垚鐨凱ortlet Java鏂囦歡鎵╁睍浜唈avax.portlet.GenericPortlet綾匯侴enericPortlet綾誨疄鐜頒簡javax.portlet.Portlet鎺ュ彛銆傚浘1鏄竴涓猆nified Modeling Language (UML)綾誨浘錛屾弿榪頒簡榪欎簺鍏崇郴銆傞氳繃鐩存帴瀹炵幇portlet鎺ュ彛錛屽彲浠ョ紪鍐欎竴涓猵ortlet銆傜劧鑰岋紝GenericPortlet鏄竴涓垱寤簆ortlet鐨勬洿鏂逛究鏂規(guī)硶銆傞鍏堬紝鎴戜滑鐪嬩竴涓媝ortlet鐢熷懡鍛ㄦ湡銆乸ortlet妯″紡鍜寃indow鐘舵併?


鍥?1

銆銆Portlet鐢熷懡鍛ㄦ湡
銆銆涓轟簡鎴愬姛鍦板垱寤簆ortlet錛屾?zhèn)ㄥ繀椤婚侂妳ortlet鐢熷懡鍛ㄦ湡銆俲avax.portlet.Portlet鎺ュ彛涓殑鏂規(guī)硶瀹氫箟浜嗚鐢熷懡鍛ㄦ湡錛岃繖浜涚敓鍛藉懆鏈熸柟娉曟槸init()銆乺ender()銆乸rocessAction()鍜宒estroy()銆傚綋閮ㄧ講portlet鐨勫疄渚嬫椂璋冪敤init()鏂規(guī)硶銆傚畠鐢ㄤ簬鑾峰緱鎵闇鐨勪換浣曟槀璐佃祫婧愶紙濡傚悗鍙拌繛鎺ワ級錛屽茍鎵ц鍏朵粬涓嬈℃ф椿鍔ㄣ傚綋portlet鐨勫疄渚嬭鎾ら攢閮ㄧ講鏃訛紝浣跨敤destroy()鏂規(guī)硶鏉ラ噴鏀捐繖浜涜祫婧愩?BR>
銆銆Portlet瑙勮寖娓呮櫚鍖哄埆render璇鋒眰鍜屽姩浣滆姹傘傚浘2鎻忚堪浜唒ortlet璇鋒眰鍜屽搷搴旂殑涓涓猆ML綾誨浘銆傞棬鎴烽〉闈笂鐨剅ender璇鋒眰浼?xì)瀵艰嚧瀵规墍欏甸潰涓婄殑姣忎釜portlet涓婅皟鐢╮ender()鏂規(guī)硶錛屽綋鐢ㄦ埛鍦ㄧ壒瀹歱ortlet涓婅皟鐢ㄦ煇涓姩浣滐紙閫氬父鏄疕TML琛ㄥ崟鎻愪氦錛夋椂錛屽皢浼?xì)璋冪敤璇ortlet鐨刾rocessAction()鏂規(guī)硶銆傝繖鏍鳳紝鐢ㄦ埛鐨勫姩浣滆姹傝漿鎹負(fù)processAction()鏂規(guī)硶鐨勪竴嬈¤皟鐢ㄥ拰render()鏂規(guī)硶鐨勫嬈¤皟鐢ㄣ?/P>


鍥?2

銆銆鍥?鏄竴涓簭鍒楀浘錛岃鏄庝簡璋冪敤processAction()鏂規(guī)硶鐨勬晥鏋滐紝浠ュ強(qiáng)涓哄悓涓欏甸潰涓婄殑portlet榪涜鍚庣畫render()鏂規(guī)硶鐨勮皟鐢ㄣ傚叧浜庢洿澶氫俊鎭紝璇峰弬闃呭叧浜庡鐞嗗姩浣滅殑涓鑺傘?/P>


鍥?3

銆銆鏈変袱縐嶉噸杞界殑init()鏂規(guī)硶錛屼竴涓病鏈夊弬鏁幫紝鍙︿竴涓湁涓涓猨avax.portlet.PortletConfig綾葷殑瀹炰緥銆傛敞鎰忥細(xì)鍏充簬init(PortletConfig)鏈変竴涓壒孌婄殑caveat銆傝皟鐢╯uper.init(aPortletConfig)澶辮觸灝嗗鑷翠竴涓狽ullPointerException銆傛墍鍖呭惈鐨勬簮浠g爜紺轟緥涓殑Init portlet璇存槑浜嗚繖縐嶈涓猴紙婧愪唬鐮佸彲浠ュ湪www.sys-con.com/weblogic/source.cfm涓壘鍒幫級銆?BR>
銆銆Portlet妯″紡
銆銆JSR 168瀹氫箟浜嗕笁縐峆ortlet妯″紡錛歏IEW銆丒DIT鍜孒ELP銆備竴涓猵ortlet瀹炰緥鍦ㄤ換浣曟椂鍊欓兘鍙互鎭板閥鍦ㄤ竴縐嶃portlet妯″紡涓嬨傚叾浠栬嚜瀹氫箟portlet妯″紡錛堝閰嶇疆鍜屾簮錛夐兘鏄彲鑳界殑銆俈IEW妯″紡鏄粯璁ょ殑妯″紡銆侾ortlet瑙勮寖寤鴻EDIT妯″紡鍏佽portlet鐢ㄦ埛瀹氬埗portlet瀹炰緥錛屼互鍙?qiáng)HELP妯″紡鏄劇ず鍏充簬portlet鐨勭敤娉曚俊鎭侾ortlet蹇呴』鏀寔VIEW妯″紡錛屼絾鍦╬ortlet涓EDIT妯″紡鍜孒ELP妯″紡鐨勬敮鎸佹槸鍙夌殑銆備緥濡傦紝portlet First portlet紺轟緥涓嶆敮鎸丒DIT妯″紡鍜孒ELP妯″紡銆?BR>
銆銆window鐘舵?/B>
銆銆JSR 168瀹氫箟浜嗕笁縐峎indow鐘舵侊細(xì)NORMAL銆丮INIMIZED鍜孧AXIMIZED銆侾ortlet瀹炰緥浠諱綍鏃跺欓兘鍙互鎭板ソ鏄竴縐峸indow鐘舵併傚叾浠栬嚜瀹氫箟window鐘舵侊紙濡傚崐欏碉級涔熸槸鍙兘鐨勩傚湪NORMAL鐘舵佷笅錛宲ortlet鍗犱簡灞忓箷鍖虹殑涓灝忛儴鍒嗐傚睆騫曠姸鎬佷笌鍏朵粬portlet鍏變韓銆傚湪MINIMIZED鐘舵佷笅錛宲ortlet鐨勫唴瀹硅闅愯棌銆傚湪MAXIMIZED鐘舵佷笅錛宲ortlet鐨勫唴瀹瑰崰灞忓箷鍖虹殑澶ч儴鍒嗐傚叾浠栧叡浜悓涓欏甸潰鐨刾ortlet鍦∕AXIMIZED鐘舵佷笅琚殣钘忋備緥濡傦紝portlet First紺轟緥鏀寔鎵鏈変笁縐峸indow鐘舵併?BR>
銆銆GenericPortlet綾?/B>
銆銆鎮(zhèn)ㄥ垱寤虹殑澶у鏁皃ortlet灝嗕細(xì)鎵╁睍javax.portlet.GenericPortlet綾伙紝鑰屼笉鏄洿鎺ュ疄鐜癹avax.portlet.Portlet鎺ュ彛銆侴enericPortlet綾誨疄鐜頒簡render()鏂規(guī)硶銆傚鏋減ortlet鐨剋indow鐘舵佽鏈灝忓寲錛岄偅涔坮ender()鏂規(guī)硶涓嶈兘鍋氫換浣曚簨鎯呫傚鏋減ortlet鐨剋indow鐘舵佷笉鏄渶灝忓寲錛岄偅涔坮ender()鏂規(guī)硶璁劇疆鍦╬ortlet.xml鏂囦歡涓寚瀹氱殑鏍囬錛屽茍璋冪敤doDispatch()鏂規(guī)硶銆傛牴鎹甈ortlet妯″紡錛?doDispatch()鏂規(guī)硶閫傚綋鍦拌皟鐢╠oView()銆乨oEdit()鍜宒oHelp()鏂規(guī)硶銆傝繖鏍鳳紝鐢變簬GenericPortlet綾誨府鍔╁疄鐜皉ender()鏂規(guī)硶錛屽茍涓旀彁渚沝oView()銆乨oEdit()鍜宒oHelp()鏂規(guī)硶鏉ヨ鐩栵紝鍥犳GenericPortlet綾繪瘮Portlet鎺ュ彛鏇翠究浜庢墿灞曘?

銆銆鑰冭檻涓涓婩irst portlet紺轟緥銆侳irstPortlet綾繪墿灞曚簡GenericPortlet錛孎irstPortlet鏀瑰啓浜哾oView()鏂規(guī)硶銆?BR>
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException
{
response.setContentType("text/html");
response.getWriter().write("<p>Hello World</p>");
}


銆銆娉ㄦ剰錛氳皟鐢╯etContentType()鏂規(guī)硶鍓嶈皟鐢╣etWriter()鏂規(guī)硶浼?xì)瀵艰嚧java.lang.IllegalStateException銆?BR>
銆銆瀹炵幇Portlet妯″紡
銆銆VIEW妯″紡鏄己鍒剁殑錛屼絾EDIT鍜孒ELP妯″紡鏄彲閫夌殑銆備負(fù)浜嗗疄鐜癊DIT鍜孒ELP portlet妯″紡錛岄渶瑕佸湪portlet綾諱腑瀹炵幇閫傚綋鐨刣oEdit()鍜宒oHelp()鏂規(guī)硶銆傝鍙傝冨寘鍚湪婧愪唬鐮佺ず渚嬶紙鏈枃鐨勬簮浠g爜鍙互鍦╳ww.sys-con.com/wldj/sourcec.cfm鎵懼埌錛変腑鐨刾ortlet Mode銆傛澶栵紝蹇呴』鍦╬ortlet.xml涓涓嬮厤緗悇妯″紡錛?BR>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>edit</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>


銆銆娉ㄦ剰錛氫慨鏀筽ortlet.xml閰嶇疆鏂囦歡錛屼絾涓嶅疄鐜皃ortlet綾諱腑鐨勭浉搴旀柟娉曪紝浼?xì)瀵艰嚧javax.portlet.PortletException銆?BR>
銆銆瀹炵幇window鐘舵?/B>
銆銆JSR 168娌℃湁鎻忚堪紱佺敤window鐘舵佹敮鎸佺殑鏂規(guī)硶銆傜劧鑰岋紝W(xué)ebLogic Portal瀹炵幇浜嗗瀹冧滑鐨勭鐢ㄣ備負(fù)浜嗙鐢╬ortlet瀵箇indow鐘舵佺殑鏀寔錛岄渶瑕佸湪weblogic-portlet.xml鏂囦歡涓帓闄indow鐘舵侊細(xì)

<portlet>
<portlet-name>state</portlet-name>
<supports>
<mime-type>text/html</mime-type>
<excluded-window-state>minimized</excluded-window-state>
<excluded-window-state>maximized</excluded-window-state>
</supports>
</portlet>


銆銆璇峰弬鑰冩簮浠g爜紺轟緥涓殑portlet State銆?BR>
銆銆鍖呭惈JavaServer Pages (JSPs)
銆銆鑰冭檻portlet First鐨刣oView()鏂規(guī)硶錛岃鏂規(guī)硶鑾峰緱浜哤riter鐨勫疄渚嬶紝騫剁洿鎺ヨ緭鍑篐TML鐗囨銆傜敱浜庡縐嶅師鍥狅紙濡備負(fù)浜嗚揪鍒癑ava閫昏緫涓嶩TML瑙嗗浘琛ㄧ幇鐨勫垎紱伙級錛屽線寰涓嶆帹鑽愯緭鍑虹洿鎺ョ殑HTML鐗囨銆傛帹鑽愮殑鏂規(guī)硶鏄嬌鐢↗SP鏉ユ樉紺鴻鍥俱俻ortlet綾諱腑鐨勬柟娉曟墽琛屼笟鍔¢昏緫銆佽緗畆ender鍙傛暟浠ュ強(qiáng)鍖呭惈JSP銆備負(fù)浜嗗寘鍚竴涓壒瀹氱殑JSP錛屽簲棣栧厛鑾峰緱PortletContext銆備粠PortletContext瀹炰緥涓紝閫氳繃璋冪敤getRequestDispatcher()鏂規(guī)硶鑾峰緱涓涓狿ortletRequestDispatcher鐨勫疄渚嬨傞氳繃璋冪敤include()鏂規(guī)硶鏉ュ寘鍚獼SP銆備緥濡傦細(xì)

// execute the necessary logic here...
PortletRequestDispatcher aDispatcher =
getPortletContext().getRequestDispatcher(
"/IncludePortlet/includeView.jsp"
);
aDispatcher.include(aRequest, aResponse);


銆銆娉ㄦ剰錛氬湪鎵цrender()鏂規(guī)硶鏃訛紝portlet鍙兘鍙嬌鐢ㄤ竴涓狿ortletRequestDispatcher瀵硅薄銆?BR>銆銆璇峰弬鑰冨寘鍚湪婧愪唬鐮佷腑鐨刾ortlet Include銆侸SP欏甸潰錛堝includeView.jsp錛変笉鍖呭惈鏍笻TML鏍囩錛堝<html>銆?lt;title>鍜?lt;body>錛夛紝鍥犱負(fù)榪欎簺鏍囩鐢遍棬鎴鋒鏋舵彁渚涖侸SP欏甸潰鍙寘鍚樉紺簆ortlet鎵蹇呴渶鐨凥TML鐗囨銆?BR>
銆銆澶勭悊鍔ㄤ綔
銆銆鍦ㄤ竴涓爣鍑嗙殑Web搴旂敤紼嬪簭涓紝涓涓狧TML琛ㄥ崟鎻愪氦灝嗗鑷存墽琛屼竴浜涗笟鍔¢昏緫銆備笟鍔″鐞嗙殑緇撴灉錛岃涔堜綔涓哄睘鎬ц岃璁劇疆鍦ㄨ姹傛垨浼?xì)璇濅腑迤堣浆鍙戝Q岃涔堝寘鍚埌涓嬩竴涓狫SP銆?BR>
銆銆鍦ㄤ竴涓狫SR 168 portlet涓紝涓涓狧TML琛ㄥ崟鐨勫姩浣淯RL搴旇鏄粈涔堟牱鍛紵JSR 168瀹氫箟浜嗕竴涓狫SP鏍囩搴擄紝縐頒負(fù)portlet taglib銆侶TML琛ㄥ崟鐨勫姩浣淯RL鍙互浣跨敤actionURL portlet鏍囩鐢熸垚銆備緥濡傦紙璇峰弬鑰僨avoriteColorEdit.jsp鏂囦歡錛夛細(xì)

<form action="<portlet:actionURL/>" method="post">
...
</form>


銆銆鎻愪氦璇TML琛ㄥ崟灝嗕細(xì)瀵艱嚧璋冪敤portlet鐨刾rocessAction(ActionRequest aRequest, ActionResponse aResponse)鏂規(guī)硶銆傚儚閫氬父涓鏍鳳紝鍙互閫氳繃璋冪敤request瀵硅薄鐨刧etParameter()鏂規(guī)硶鏉ヨ幏寰楄〃鍗曞弬鏁般傛敞鎰忥細(xì)閫氳繃鎻愪氦琛ㄥ崟璋冪敤鍔ㄤ綔錛屼絾portlet涓嵈娌℃湁processAction()鏂規(guī)硶錛屽皢浼?xì)瀵艰嚧javax.portlet.PortletException銆?BR>
銆銆processAction()鏂規(guī)硶璁劇疆response瀵硅薄涓殑鍊箋備笉瑕佷嬌鐢ˋctionRequest鎴朅ctionResponse瀵硅薄鐨剆etAttribute()鏂規(guī)硶銆傚間笉浼?xì)浠巔rocessAction()浼犻掑埌render()鏂規(guī)硶錛岃屼笖鍦↗SP涓槸涓嶅彲鐢ㄧ殑銆傜浉鍙嶈浣跨敤ActionResponse瀵硅薄鐨剆etRenderParameter()鏂規(guī)硶銆傝繖浜況ender鍙傛暟灝嗗鎵鏈夊悗緇璻ender璇鋒眰鍙敤錛岃繖涓鐐逛笌鍏稿瀷鐨刉eb搴旂敤紼嬪簭璇鋒眰灞炴у緢涓嶇浉鍚屻傚吀鍨嬬殑Web application璇鋒眰灞炴у彧瀵逛簬涓涓姹傚彲鐢ㄣ傚彟涓鏂歸潰錛宺ender璇鋒眰鍙傛暟瀵逛簬璁稿鍚庣畫render璇鋒眰鍙敤銆俽ender鍙傛暟淇濇寔鍙敤鐩村埌鍊艱鍔ㄤ綔鐨勯噸鏂版墽琛屾樉寮忓湴淇敼鎴栧垹闄ゃ?BR>
銆銆鑰冭檻portlet FavoriteColor銆傚畠鍦╒IEW妯″紡鏄劇ず浜嗕竴涓敤鎴峰亸濂界殑棰滆壊錛屼絾鏄彲浠ュ湪EDIT妯″紡涓嬫洿鏀廣傚湪EDIT妯″紡涓嬫彁浜ゅ亸濂界殑棰滆壊閫夋嫨灝嗚皟鐢╬rocessAction()鏂規(guī)硶銆傝鏂規(guī)硶鑾峰緱鍋忓ソ鐨勯鑹茶姹傚弬鏁幫紝騫跺皢鍏惰緗負(fù)render鍙傛暟銆傝繖鏍鳳紝鍋忓ソ鐨勭殑棰滆壊render鍙傛暟灝嗗湪鎵鏈夊悗緇璻ender璇鋒眰涓兘鍙敤銆?BR>
銆銆鎵鍛堢幇鐨勫弬鏁版槸鎬庢牱鏄劇ず鍦↗SP涓婄殑鍛紵搴斾嬌鐢ㄦ潵鑷猵ortlet鏍囩搴撶殑defineObjects鏍囩鏉ュ畾涔塸ortlet瀵硅薄銆傝鏍囩浣縭enderRequest銆乺enderResponse鍜宲ortletConfig portlet瀵硅薄鍦ㄩ〉闈腑鍙敤銆傚弬鏁伴氳繃璋冪敤renderRequest瀵硅薄鐨刧etParameter()鏂規(guī)硶鏉ユ樉紺恒傝鍙傝冧笌鎵鍖呭惈鐨勬簮浠g爜紺轟緥涓殑favoriteColorView.jsp銆?BR>
銆銆portlet FavoriteColor涔熷睍紺轟簡鍏朵粬姒傚康銆傜涓涓槸濡備綍鍦╬rocessAction()鏂規(guī)硶涓敤緙栫▼鐨勬柟娉曟敼鍙榩ortlet妯″紡銆傝皟鐢ˋctionResponse瀵硅薄鐨剆etPortletMode()鏂規(guī)硶鏉ヤ慨鏀筽ortlet妯″紡銆傜浜屼釜姒傚康鏄浣曚嬌鐢ㄤ竴涓狧TML閾炬帴鏉ヤ慨鏀筽ortlet妯″紡銆傝閾炬帴浣跨敤鏉ヨ嚜portlet鏍囩搴撶殑renderURL鏍囩鐢熸垚銆傛牴鎹笇鏈涚殑portlet妯″紡鎸囧畾portletMode灞炴х殑鍊箋傝鍙傝冩簮浠g爜紺轟緥涓殑FavoriteColorPortlet綾誨拰favoriteColorView.jsp欏甸潰銆?

銆銆Portlet Preferences
銆銆Portlet Preferences錛圥ortlet棣栭夐」錛夋槸portlet鐨勫熀鏈厤緗暟鎹備竴涓猵reference鏄竴涓滃悕縐板拰鍊尖濆銆傚悕縐扮殑綾誨瀷鏄竴涓瓧絎︿覆錛岃屽肩殑綾誨瀷鏄瓧絎︿覆鎴栧瓧絎︿覆鏁扮粍銆侾ortlet Preference涓嶉備簬瀛樺偍浠繪剰鏁版嵁銆俻ortlet瀹瑰櫒涓簆ortlet preferences鎻愪緵鎸佷箙鎬с傚湪WebLogic Portal涓紝preference鐨勬寔涔呮у彧鍦ㄤ笅闈袱涓潯浠墮兘涓虹湡鏃舵墠璧蜂綔鐢細(xì)
銆銆路闂ㄦ埛榪愯鍦ㄦ闈腑錛岃屼笉鏄疍OT闂ㄦ埛妯″紡銆?BR>銆銆路鐢ㄦ埛宸茬粡鐧誨綍銆?BR>
銆銆妗岄潰涓嶥OT闂ㄦ埛妯″紡
銆銆鍦╓ebLogic Workshop涓垱寤?portal鏂囦歡鏃訛紝鍍忎功銆侀〉闈㈠拰portlet絳夐」閮藉彲浠ヨ鎷栨斁鍒?portal鏂囦歡涓紝.portal鏂囦歡鑳藉鐩存帴浠嶹orkshop鍐呰繍琛屻傜劧鑰岋紝鏌愪簺鍔熻兘錛屽preferences鐨勫瓨鍌紝鍦ㄨ繖縐岲OT闂ㄦ埛妯″紡涓嬭繍琛屾椂鏄笉鍙敤鐨勶紙DOT闂ㄦ埛妯″紡涔熺О涓哄崟鏂囦歡妯″紡錛圫ingle File Mode錛夛級銆?

銆銆鍏朵粬妯″紡縐頒負(fù)妗岄潰妯″紡銆傚垱寤轟竴涓棬鎴鋒椂浣跨敤Portal Administrator銆傚湪闂ㄦ埛鍐咃紝涓涓闈㈣鍒涘緩銆傚儚鍥句功銆侀〉闈㈠拰portlet絳夐」琚垱寤猴紝騫舵斁緗湪妗岄潰涓傚湪榪欑妯″紡涓嬶紝鏌愪簺鍔熻兘錛屽儚preferences鐨勫瓨鍌紝鏄彲鐢ㄧ殑錛堟闈㈡ā寮忎篃琚О涓烘祦妯″紡錛圫treamed Mode錛夛級銆?BR>
鍦ㄧ戶緇璁哄墠錛屽厛鍒涘緩涓涓闈細(xì)
銆銆鍚姩Portal Administration錛堣濡傦紝http://localhost:7001/JSR168PortalAppAdmin/錛夈備竴縐嶅惎鍔≒ortal Administration鐨勬柟娉曟槸鐩存帴浠嶹orkshop涓惎鍔ㄣ傞夋嫨Portal鑿滃崟錛岄変腑Portal Administration鑿滃崟欏廣?
銆銆路鐧誨綍榪汸ortal Administration銆?BR>銆銆路鍒涘緩涓涓柊闂ㄦ埛錛堣濡傦紝JSR168錛夈?
銆銆路鍦ㄩ棬鎴蜂腑錛屽垱寤轟竴涓柊妗岄潰錛堝d1錛夈?
銆銆路灝哃oginPortlet娣誨姞鍒版闈㈢殑涓涓〉闈腑銆?
銆銆路灝咰ontactPortlet娣誨姞鍒版闈㈢殑涓涓枃浠朵腑銆?

銆銆Portlet Preferences紺轟緥
銆銆Contact portlet婕旂ず浜哖ortlet Preferences銆侾ortlet Preferences鍙互鏄潤鎬佺殑鎴栧姩鎬佺殑銆傞潤鎬?preferences涓巔ortlet涓璧峰湪portal.xml鏂囦歡涓寚瀹氥備緥濡傦紝ContactPortlet鍏鋒湁涓涓垚涓篶ontact-preference鐨?preferences銆俢ontact-preference鐨勯粯璁ゅ間篃琚寚瀹氾細(xì)

<portlet-preferences>
<preference>
<name>contact-preference</name>
<value>Email</value>
</preference>
</portlet-preferences>


銆銆鍔ㄦ?preferences涓嶅湪portlet.xml閰嶇疆鏂囦歡涓瀹氫箟銆傚綋portlet榪愯鏃訛紝榪欎簺preferences琚瓨鍌ㄥ拰璇誨彇銆傚湪榪愯鏈熼棿錛屼竴涓猨avax.portlet.PortletPreferences鎺ュ彛鐨勫疄渚嬪寘鍚繖浜沺references銆傝瀹炰緥閫氳繃璋冪敤PortletRequest瀵硅薄鐨刧etPreferences()鏂規(guī)硶鑾峰緱銆傜壒瀹歱references鐨勫奸氳繃璋冪敤preferences瀹炰緥涓婄殑getValue()鏂規(guī)硶鏉ヨ幏寰椼?

銆銆璋冪敤preferences瀹炰緥鐨剆etValue()鏂規(guī)硶浼?xì)鏇存栴C竴涓猵references鍊箋傜劧鑰岋紝闇瑕佷竴涓澶栫殑姝ラ鏉ユ彁浜よ繖浜涗慨鏀廣俻references瀹炰緥鐨剆tore()鏂規(guī)硶琚皟鐢ㄦ潵浣縫references鎸佷箙鍖栥俻references鍙兘鍦╬rocessAction()鏂規(guī)硶涓繘琛屼慨鏀廣傚鏋滃湪processAction()鏂規(guī)硶涓病鏈夎皟鐢╯tore()鏂規(guī)硶錛屼換浣曞preferences瀹炰緥鐨勪慨鏀歸兘浼?xì)琚涪寮冦傛敞鎰忥細(xì)灝卞鍓嶉潰鎻愬埌鐨勶紝濡傛灉鐢ㄦ埛娌℃湁鐧誨綍鎴栭棬鎴峰浜嶥OT闂ㄦ埛妯″紡錛岄偅涔堣皟鐢╯tore()鏂規(guī)硶灝嗕細(xì)瀵艱嚧涓涓繍琛屾椂寮傚父銆?BR>
銆銆鍦╬ortlet鍜宻ervlet涔嬮棿鏈夊緢澶氱浉浼肩偣銆傜劧鑰岋紝瀹冧滑涔熷瓨鍦ㄧ潃閲嶈鍖哄埆銆俻ortlet瑙勮寖寤虹珛鍦╯ervlet瑙勮寖涔嬩笂銆俻ortlet瀹瑰櫒瀛樺湪浜巗ervlet瀹瑰櫒涓傚氨鍍弒ervlet閮ㄧ講鍦ㄤ竴涓猈eb搴旂敤紼嬪簭涓紝portlet涔熸槸濡傛銆係ervlet鍜學(xué)eb搴旂敤紼嬪簭浣跨敤portlet.xml鏂囦歡榪涜閰嶇疆銆備竴涓猻ervlet鍏鋒湁鏄懼紡鐨勭敓鍛藉懆鏈燂細(xì)init()銆乨oGet()銆乨oPost()絳夈傜被浼煎湴錛屼竴涓猵ortlet涔熷叿鏈夋樉寮忕殑鐢熷懡鍛ㄦ湡錛歞oView()銆乨oEdit()銆乸rocessAction()絳夈俿ervlet鍜宲ortlet綾葷殑鏂規(guī)硶蹇呴』浠ュ畨鍏ㄧ嚎紼嬬殑鏂瑰紡緙栫爜銆?BR>
銆銆鐒惰岋紝涔熷瓨鍦ㄧ潃閲嶈鐨勫尯鍒係ervlet琚厑璁歌繘琛宨nclude銆乫orward鍜宺edirect鎿嶄綔錛涚劧鑰宲ortlet鍙鍏佽榪涜include鎿嶄綔銆係ervlet鑳藉鍛堢幇涓涓畬鏁寸殑欏甸潰錛屼絾portlet鍙彁浜ら〉闈㈢墖孌點(diǎn)俻ortlet鍏鋒湁涓ユ牸瀹氫箟鐨刾ortlet妯″紡鍜學(xué)indow鐘舵侊紝榪欐柟闈笉鍍弒ervlet銆侾ortlet鍏鋒湁鏇存寮忕殑璇鋒眰錛屽render璇鋒眰鍜屽姩浣滆姹傝繘琛屽鐞嗭紝瀹冧滑涔熷叿鏈塸references銆俻ortlet騫朵笉鏄痵ervlet錛?BR>
銆銆緇撴潫璇?/B>
銆銆鏈枃閫氳繃浣跨敤涓涓畝鍗曠殑鍚戝鎻忚堪portlet鐨勫垱寤鴻屽紑濮嬶紝騫惰鏄庝簡portlet鐨勭敓鍛藉懆鏈熶互鍙?qiáng)portlet綾誨疄鐜扮殑鍐呴儴宸ヤ綔鏂瑰紡錛屾弿榪頒簡portlet.xml閰嶇疆鏂囦歡鍜岀浉搴旂殑weblogic-portlet.xml閰嶇疆鏂囦歡鐨勭粨鏋勫拰璇箟銆傚鍚勭姒傚康錛屽portlet妯″紡鍜寃indow鐘舵侊紝鏈枃涔熻繘琛屼簡瑙i噴銆傛湰鏂囨紨紺轟簡portlet鏍囩搴撶殑鐢ㄦ硶鍜宲ortlet涓殑琛ㄥ崟澶勭悊銆傛渶鍚庯紝鎴戜粙緇嶄簡濡備綍浣跨敤portletpreferences銆傜悊瑙d簡鏈枃鎵浠嬬粛鐨勮繖浜涚煡璇嗗拰姒傚康錛屾?zhèn)鍙互鍦ㄥ垱寰忓拰閮ň|茶嚜宸辯殑寮哄ぇportlet鐨勯亾璺笂鍓嶈繘浜嗐?BR>
銆銆鑷磋阿
銆銆鎰熻阿Subbu Allamaraju銆丮ax Cooper銆丼teve Ditlinger銆丏avid Lu銆丷oshni Malani鍜孉lex Toussaint錛屼粬浠粩緇嗛槄璇諱簡榪欑瘒鏂囩珷錛屽茍鎻愪緵浜嗘湁浠峰肩殑鍙嶉鎰忚銆?BR>
銆銆鍙傝冭祫鏂?/B>
銆銆路 瑕佽璁鴻繖綃囨枃绔犮佸茍鎻愰棶闂錛屼粠榪欓噷寮濮嬶細(xì) www.bartssandbox.com銆傞渶瑕佸厤璐規(guī)垚鍛樿祫鏍箋?
銆銆路 涓嬭澆銆侀槄璇籎SR 168錛?A target=_blank>www.jcp.org/en/jsr/detail?id=168
銆銆路 WebLogic Portal鏂囨。鐨勮搗濮嬬偣錛?A target=_blank>e-docs.bea.com/wlp/docs81/index.html
銆銆路 寤虹珛Workshop Help鐨凧ava Portlet閮ㄥ垎錛?A target=_blank>e-docs.bea.com/workshop/docs81/doc/en/core/index.html
銆銆路 鐢╓ebLogic Portal 8.1寮鍙慗SR 168 Portlet錛?A target=_blank>dev2dev.bea.com/products/wlportal81/articles/JSR168.jsp
銆銆路 Web Services for Remote Portlets (WSRP)瑙勮寖錛?A target=_blank>www.oasis-open.org/committees/tc_home.php?wg_abbrev=wsrp
銆銆路 灝濊瘯涓涓媁SRP錛?A target=_blank>dev2dev.bea.com/codelibrary/code/wsrp_supportkit.jsp
銆銆路 Single File Mode鍜孲treamed Rendering Mode錛?A target=_blank>鍗曞嚮榪欓噷錛?BR>銆銆路 鏈夊叧Portlet瑙勮寖涓婄殑鏂囩珷錛?BR>- 浠嬬粛Portlet瑙勮寖錛岀1閮ㄥ垎錛?BR>www.javaworld.com/javaworld/jw-08-2003/jw-0801-portlet_p.html
-浠嬬粛Portlet瑙勮寖錛岀2閮ㄥ垎錛?BR>www.javaworld.com/javaworld/jw-09-2003/jw-0905-portlet2_p.html
銆銆路 瀵笿SR 168鐧界毊涔︾殑浠嬬粛錛氬崟鍑昏繖閲岋紒
銆銆路 Java Passion Portlet婕旇絎旇錛?A target=_blank>www.javapassion.com/j2eeadvanced/Portlet4.pdf

銆銆鍏充簬浣滆?/B>
銆銆Prakash Malani鍦ㄦ灦鏋勩佽璁″拰寮鍙戦潰鍚戝璞$殑杞歡鏂歸潰鍏鋒湁騫挎硾鐨勭粡楠岋紝鏇劇粡鍦ㄥ緢澶氬簲鐢ㄩ鍩熶粠浜嬭繃杞歡寮鍙戯紝濡傚ū涔愩侀浂鍞佹満姊般侀氫俊鍜屼簰鍔ㄧ數(shù)瑙嗙瓑銆備粬瀹炶返鍜屾寚瀵肩潃寰堝棰嗗厛鐨勬妧鏈紝濡侸2EE銆乁ML鍜孹ML銆傘銆銆Prakash宸茬粡鍦ㄥ涓涓氶鍏堢殑鍑虹増鐗╀笂鍙戣〃浜嗗綃囨枃绔犮傦紙鏇村鍐呭錛?BR>
銆銆婧愪唬鐮?/B>
銆銆婧愪唬鐮?Zip鏂囦歡
銆銆鑻辨枃鍘熸枃錛?A target=_blank>http://www.sys-con.com/story/?storyid=45565&DE=1



絎ㄧ 2005-04-22 21:55 鍙戣〃璇勮
]]>
鐏扮嫄涓婇潰鍏充簬JBoss鐨勮繛鎺?/title><link>http://www.tkk7.com/kapok/archive/2005/03/30/2615.html</link><dc:creator>絎ㄧ</dc:creator><author>絎ㄧ</author><pubDate>Wed, 30 Mar 2005 09:28:00 GMT</pubDate><guid>http://www.tkk7.com/kapok/archive/2005/03/30/2615.html</guid><wfw:comment>http://www.tkk7.com/kapok/comments/2615.html</wfw:comment><comments>http://www.tkk7.com/kapok/archive/2005/03/30/2615.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/kapok/comments/commentRss/2615.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/kapok/services/trackbacks/2615.html</trackback:ping><description><![CDATA[<A >http://www.huihoo.org/jboss/</A><img src ="http://www.tkk7.com/kapok/aggbug/2615.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/kapok/" target="_blank">絎ㄧ</a> 2005-03-30 17:28 <a href="http://www.tkk7.com/kapok/archive/2005/03/30/2615.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>JBoss3.0 涓嬮厤緗拰閮ㄧ講EJB綆浠?/title><link>http://www.tkk7.com/kapok/archive/2005/03/30/2614.html</link><dc:creator>絎ㄧ</dc:creator><author>絎ㄧ</author><pubDate>Wed, 30 Mar 2005 09:19:00 GMT</pubDate><guid>http://www.tkk7.com/kapok/archive/2005/03/30/2614.html</guid><wfw:comment>http://www.tkk7.com/kapok/comments/2614.html</wfw:comment><comments>http://www.tkk7.com/kapok/archive/2005/03/30/2614.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/kapok/comments/commentRss/2614.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/kapok/services/trackbacks/2614.html</trackback:ping><description><![CDATA[     鎽樿: (by huihoo.org 璧墊櫒甯?zhaochenxi@vip.sina.com) http://www.huihoo.org/jboss/jboss3_ejb.htm 1錛嶫Boss綆浠?JBoss鏄竴涓繍琛孍JB鐨凧2EE搴旂敤鏈嶅姟鍣ㄣ傚畠鏄紑鏀炬簮浠g爜鐨勯」鐩紝閬靛驚鏈鏂扮殑J2EE瑙勮寖銆備粠JBoss欏圭洰寮濮嬭嚦浠婏紝瀹冨凡緇忎粠涓涓狤JB瀹瑰櫒鍙戝睍鎴愪負(fù)涓涓熀浜庣殑J2EE鐨勪竴涓獁eb 鎿嶄綔緋葷粺錛坥per...  <a href='http://www.tkk7.com/kapok/archive/2005/03/30/2614.html'>闃呰鍏ㄦ枃</a><img src ="http://www.tkk7.com/kapok/aggbug/2614.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/kapok/" target="_blank">絎ㄧ</a> 2005-03-30 17:19 <a href="http://www.tkk7.com/kapok/archive/2005/03/30/2614.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Jboss 婧愮爜瑙f瀽http://www.tkk7.com/kapok/archive/2005/03/29/2569.html絎ㄧ絎ㄧTue, 29 Mar 2005 01:46:00 GMThttp://www.tkk7.com/kapok/archive/2005/03/29/2569.htmlhttp://www.tkk7.com/kapok/comments/2569.htmlhttp://www.tkk7.com/kapok/archive/2005/03/29/2569.html#Feedback0http://www.tkk7.com/kapok/comments/commentRss/2569.htmlhttp://www.tkk7.com/kapok/services/trackbacks/2569.htmlhttp://blog.csdn.net/stripbolt/archive/2004/10/24/149705.aspx

JBoss鏄竴涓潪甯鎬紭縐鐨凧2EE鐨凙pplication Server,鐮旂┒
瀹冪殑婧愪唬鐮佹湁鍔╀簬鎴戜滑鏇村ソ鐨勭悊瑙2EE鐨勫悇縐嶆妧鏈?
鏈郴鍒楁嫙浠庡洓涓柟闈㈠垎鏋怞boss婧愮爜錛?
1.EJB Container瀹炵幇
2.Transaction瀹炵幇
3.Persistence Mapping
4.Client鍒癝erver绔殑Invocation

-------------------------------------------------------------------
鍏堣絎?鐐?EJB Container瀹炵幇銆?
1.1 EJB Pool
鎴戜滑鐭ラ亾錛孍JB Container 浼?xì)缁存姢涓涓狤JB姹狅紝
鍦ㄥ涓猚lient闂村叡浜紝閬垮厤棰戠箒鍒涘緩閿姣佸璞$殑寮閿銆?
璁╂垜浠潵鐪嬬湅Jboss瀹炵幇鐨凱ool:
EJB鍒咵ntityBean,MDB,Stateless/Stateful Session Bean,
鑰孞boss涓篃瀵瑰簲鐨勬湁EntityInstancePool錛孧essageDrivenInstancePool,
StatefulSessionInstancePool,StatelessSessionInstancePool.
璁╂垜浠厛浠庤繖4涓被鐨勫叡鍚屽熀綾籄bstractInstancePool鐪嬭搗錛?
class AbstractInstancePool瀹炵幇浜嗘帴鍙nstancePool錛岃鎺ュ彛鏈変互涓嬪嚑涓柟娉曪細(xì)
EnterpriseContext get() throws Exception;
void free(EnterpriseContext ctx);
void discard(EnterpriseContext ctx);
int getCurrentSize();
public int getMaxSize();
--------------------------------------------------------------------
鍏堝EnterpriseContext浣滅暘璇存槑銆侲nterpriseContext鐨勪綔鐢?
灝辨槸鎶婂叿浣撶殑EJB instance鍜屽畠鐨刴etadata鑱旂郴璧鋒潵銆?
璇ョ被絳懼悕涓猴細(xì)
public abstract class EnterpriseContext錛?
鏈?涓瓙綾伙紝EntityEnterpriseContext錛孧essageDrivenEnterpriseContext錛?
StatefulSessionEnterpriseContext錛孲tatelessSessionEnterpriseContext銆?
鍒嗗埆瀵瑰簲4縐嶇被鍨嬬殑EJB銆?
EnterpriseContext涓湁鍑犱釜閲嶈鐨勬垚鍛樺彉閲忋?
/** The EJB instance */
Object instance;
/** The container using this context */
Container con; //Container榪欎釜綾繪槸JBoss鐢ㄦ潵浠h〃瀵笶JB鎻愪緵Transaction,Security錛孭ool絳夋湇鍔$殑綾伙紝鎴戜滑鍥炲ご榪樹細(xì)鍐嶈銆?
/** Only StatelessSession beans have no Id, stateful and entity do */
Object id;

/** The transaction associated with the instance */
Transaction transaction; //Transaction錛屾垜浠笅鑺傚啀璇?

// Constructors --------------------------------------------------

public EnterpriseContext(Object instance, Container con)
{
this.instance = instance;
this.con = con;
}

public Object getInstance()
{
return instance;
}
public Container getContainer() {
return con;
}

public void setId(Object id) {
this.id = id;
}

public Object getId() {
return id;
}

public void setTransaction(Transaction transaction) {
this.transaction = transaction;
}

public Transaction getTransaction() {
return transaction;
}

/**
* Get the EJBContext object
*/
public abstract EJBContext getEJBContext(); //鐢卞瓙綾誨疄鐜?

//榪斿洖javax.ejb.EJBContext錛屾敞鎰忚繖涓狤JBContext鏄?
EJB瑙勮寖瑕佹眰鎻愪緵緇橢JB鐨凜ontext,涓嶫Boss鑷繁瀹炵幇綾籈nterpriseContext娌℃湁鍏崇郴銆?

/** The instance is being used. This locks it\'s state */
int locked = 0;
public void lock()
{
locked ++;
}

public void unlock() {
locked --;
}

public boolean isLocked() {
return locked != 0;
}
//lock榪欎釜鎴愬憳鍙橀噺琛ㄧず褰撳墠榪欎釜EJB instance鏈夋病浜哄湪鐢ㄣ?
//榪欎釜鍙橀噺鐢ㄦ潵緇橰eentrance,浠ュ強(qiáng)canPassviate鐢?
/**
* before reusing this context we clear it of previous state called
* by pool.free()
* 浠巔ool閲屽彇鍑烘潵鐨勬椂鍊欐病鏈夊叧鑱斾換浣旹JB instance鍜孴ransaction淇℃伅
* 鍦ㄨ繑榪榩ool鐨勬椂鍊欐妸榪欎簺淇℃伅娓呮帀銆?
*/
public void clear() {
this.id = null;
this.locked = 0;
this.transaction = null;
}
//-------------------------------------------------------------------------------------
protected boolean isContainerManagedTx()
{
BeanMetaData md = (BeanMetaData)con.getBeanMetaData();
return md.isContainerManagedTx();
}
//浠庡叧鑱旂殑container鎷垮嚭瀵瑰簲鐨刴etadata,鍒ゆ柇鏄惁CMT.
//娉ㄦ剰榪欓噷con鏄疌ontainer鎴愬憳鍙橀噺錛屽彲涓嶆槸浠涔堣繛鎺ワ紝榪炴帴涓鑸緝鍐欎負(fù)conn,
//鎴戜竴寮濮嬪氨鎼炴販浜?)
//BeanMetaData榪欎簺MetaData鐨勫瓙綾婚兘鏄粠xml閰嶇疆閲屽ご璇誨嚭鏉ョ殑Metadata鏋勯犵殑,
//娌′粈涔堢縐樼殑.
榪欎釜綾婚噷澶磋繕鏈変袱涓猧nner class,EJBContextImpl implements EJBContext,
UserTransactionImpl implements UserTransaction銆侲JBContextImpl絳?
璁茶В榪嘋ontainer鍐嶈錛孶serTransaction絳変笅鑺傚啀璇淬?

鐜板湪璁╂垜浠潵鐪嬬湅EnterpriseContext鐨勫嚑涓瓙綾伙細(xì)
棣栧厛綾繪瘮涓涓嬪嚑涓瓙綾葷殑鎴愬憳鍙橀噺錛?
EntityEnterpriseContext錛?
private EJBObject ejbObject;
private EJBLocalObject ejbLocalObject;
private EntityContext ctx;

StatefulSessionEnterpriseContext
private EJBObject ejbObject;
private EJBLocalObject ejbLocalObject;
private SessionContext ctx;

StatelessSessionEnterpriseContext
EJBObject ejbObject;
EJBLocalObject ejbLocalObject;
SessionContext ctx;

MessageDrivenEnterpriseContext錛?
private MessageDrivenContext ctx;
鐪嬫潵闄や簡MDB娌℃湁瀵瑰簲鐨凟JBObject/EJBLocalObject,鍏朵粬緇熺粺閮芥湁錛氾級
瀛﹁繃EJB鐨勪漢閮界煡閬擄紝鍦ㄨ娉曚笂EJB instance 鏄痠mplements
EntityBean/SessionBean/MessageDrivenBean (榪?涓猧nterface鏈変竴涓叡鍚岀殑
interface: public interface EnterpriseBean extends Serializable,
EnterpriseBean 鏄釜Marker鎺ュ彛,閲屽ご浠涔堥兘娌℃湁錛屽ソ鍍廠erializable鎺ュ彛涓鏍鳳紝鍙鏄?
瀹炵幇瀹冪殑鏄釜EJB.鑰孍ntityBean/SessionBean/MessageDrivenBean 鏈夊搴旂殑
void ejbActivate() throws EJBException, RemoteException;
void ejbLoad() throws EJBException, RemoteException;
涓浜涙柟娉曢渶瑕佸疄鐜般傦紙铏界劧甯稿父鏄┖瀹炵幇錛氾級錛岀敱瀹瑰櫒浣滀簡寰堝浜?
鑷充簬EJBObject/EJBLocalObject 鍦ㄨ娉曚笂閮芥槸闈炵洿鎺ュ疄鐜扮殑錛屼唬琛‥JB instance鏆撮湶鍑虹殑Remote/Local 鎺ュ彛銆傛棦鐒惰繖浜汦JB instance闈炵洿鎺ュ疄鐜拌繖浜涙帴鍙o紝閭d箞榪欎簺鎺ュ彛濡備綍涓庡叿浣撶殑EJB instance鐩稿叧鑱旓紝鎴戜滑璁插埌Container綾繪椂灝辯煡閬撲簡銆?
----------------------------------------------------------------------------------


EnterpriseContext鐨勫瓙綾籈ntityEnterpriseContext鐨勬瀯閫犲嚱鏁?BR>public EntityEnterpriseContext(Object instance, Container con)
throws RemoteException
{
super(instance, con);
ctx = new EntityContextImpl(); //榪欐槸EJBContextImpl鐨勫瓙綾伙紝涓嶆ョ潃璇?)
((EntityBean)instance).setEntityContext(ctx);//鐪嬬湅錛屽師鏉et...Context鏄湪榪欓噷璋冪敤鐨?/鍏跺畠instance瀹炵幇鐨勪粈涔坋jbCreate(),EJBLoad,EJBActive()鍒板簳鏄粈涔堟椂鍊?
璋冪敤鐨勫憿錛熸帴涓嬫潵鎴戜滑鎱㈡參鎵撅紝榪欏彲鏁e竷鍦ㄥ悇鍦板憿錛氾級
}
//鍏朵粬鍑犱釜瀛愮被鐨勬瀯閫犲嚱鏁板墠3琛屼篃閮藉姝わ紝鏄被浼肩殑銆?
瀵逛簬StatelessSessionEnterpriseContext鍜孧essageDrivenEnterpriseContext,绱ф帴鐨勬槸

Method ejbCreate = instance.getClass().getMethod(\"ejbCreate\", new Class[0]);
ejbCreate.invoke(instance, new Object[0]);
//鐪嬬湅錛屾潵浜嗕竴涓猠jbCreate:),瀵逛簬StatelessSessionBean錛屼竴涓婃潵灝眅jbCreate()浜唦
鎺ヤ笅鏉ョ湅鐐圭畝鍗曠殑錛氬浜嶦nterpriseContext,
鏈塸ublic abstract void discard() throws RemoteException;
瀵逛簬MessageDriven...鐨?
public void discard() throws RemoteException
{
((MessageDrivenBean)instance).ejbRemove();
}
瀵逛簬StatelessSession鐨?
public void discard() throws RemoteException
{
((SessionBean)instance).ejbRemove();
}
瀵逛簬StatefulSession...鐨?
public void discard() throws RemoteException
{
// Do nothing
}
瀵逛簬Entity....
public void discard() throws RemoteException
{
((EntityBean)instance).unsetEntityContext();
}
//discard 鏄湪AbstractInstancePool涓殑
void discard(EnterpriseContext ctx);璋冪敤鐨?

/**
* Discard an anonymous instance after invocation.
* This is called if the instance should not be reused, perhaps due to some
* exception being thrown from it.
*
* @param ctx The context to discard.
*/
public void discard(EnterpriseContext ctx)
{
ctx.discard();
}
AbstractInstancePool榪樻湁涓猣ree鏂規(guī)硶錛?
public void free(EnterpriseContext ctx) {
ctx.clear();//璁板緱ctx鍙槸娓呮帀id,transaction絳夛紝榪斿洖pool,鍑嗗澶嶇敤涔堬紵
//discard鏄湪鍙戠敓閿欒鐨勬椂鍊欙紝涓嶅笇鏈涙墿澶у獎(jiǎng)鍝嶏紝浜庢槸discard鎺夛紝
//鑰屽搴攇et()鐨刦ree鏂規(guī)硶鍙槸鎶奅nterpriseContext榪旇繕緇檖ool.
}
----------------------------------------------------------------------------------

涓撻棬瀵逛簬Stateful....Context鏈夎緗瓻JB instance鐨勫嚱鏁?
/**
* During activation of stateful session beans we replace the instance
* by the one read from the file.
*/
public void setInstance(Object instance)
{
this.instance = instance;
((SessionBean)instance).setSessionContext(ctx);
}
娉ㄦ剰鍦?縐?..Context涓紝鍙湁Stateful...Context絳懼悕
public class StatefulSessionEnterpriseContext
extends EnterpriseContext
implements Serializable
澶氫簡涓猧mplements Serializable,(鍏朵粬閮芥病鏈?,
榪欐槸涓轟簡鏀寔Activation/Passviation,Passviation鐨勬椂鍊?
鎶奅JB Instance鍐欏埌鏂囦歡涓?
鍦⊿tatefulSessionEnterpriseContext涓湁榪欐牱涓や釜鏂規(guī)硶
private void writeObject(ObjectOutputStream out)
throws IOException, ClassNotFoundException
{
// do nothing
}

private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
// do nothing
}
//璇存槑搴忓垪鍖栫殑鏃跺橲tatefulSessionEnterpriseContext鏈韓涓嶉渶瑕?
鍐欏嚭浠涔堢姸鎬侊紝鍙湁瀵瑰簲鐨凟JB instance鎵嶉渶瑕佸啓鍑虹姸鎬併?BR>
鐜板湪鏉ョ湅AbstractInstancePool鐨勬簮鐮侊紝鐢變簬鍐呭澶
灝變笉璇︾粏瑙i噴浜嗐?

鍏堢湅Abstract...Pool鐨刢reate(Object instance)鍑芥暟鐑儹韜珇
Abstract...Pool
// Protected -----------------------------------------------------
protected abstract EnterpriseContext create(Object instance)
throws Exception;
瀵笶ntity...Pool
protected EnterpriseContext create(Object instance)
throws Exception
{
return new EntityEnterpriseContext(instance, getContainer());
}
鍏朵粬3縐峆ool綾諱技銆?
鍐嶅洖澶寸湅Abstract..Pool
/** The pool data structure */
protected EnterpriseContext[] pool;
protected int currentIndex = -1;
/** The maximum number of instances allowed in the pool */
protected int maxSize = 30;
/** The minimum size of the pool */
protected int minSize = 0;
/** determine if we reuse EnterpriseContext objects i.e. if we actually do pooling */
protected boolean reclaim = false;//瀵逛簬MDB鍜孲tatelessSessionBean,榪欎釜鍙橀噺琚涓簍rue,// for MDB, we *do* pool // for SLSB, we *do* pool

ok,鐜板湪鏉ョ湅pool鐨勯噸澶存垙錛実et()/free(EnterpriseContext ctx)鍑芥暟
錛坉iscard(EnterpriseContext ctx)鍓嶉潰璁茶繃錛屼笉鍐嶉噸澶?
榪欏嚑涓嚱鏁頒篃鏄疘nterface InstancePool閲屽ご瑕佸疄鐜扮殑鎺ュ彛錛氾級
闂茶瘽灝戣錛屾潵鐪嬩唬鐮亊~
protected boolean minSizeInitialized = false;


/**
* Get an instance without identity.
* Can be used by finders,create-methods, and activation
*
* @return Context /w instance
* @exception RemoteException
*/

public EnterpriseContext get() {
//pool閲屽ご鏈変笢涓滃氨鎷垮嚭鏉?
synchronized (pool)
{
if (currentIndex > -1)
{
EnterpriseContext ctx = pool[currentIndex];
pool[currentIndex--] = null;
return ctx;
}
}

//initialize a small fixed size of instance at startup.
if (!minSizeInitialized)
{
minSizeInitialized = true;
synchronized (pool)
{
for (int i = 0; i < minSize; i++)
{
pool[++currentIndex] = create(container.createBeanClassInstance());
}
}
}

// Pool is empty, create an instance
return create(container.createBeanClassInstance());
}

/**
* Return an instance after invocation.
*
* Called in 2 cases:
* a) Done with finder method
* b) Just removed
*
* @param ctx
*/
public void free(EnterpriseContext ctx) {
ctx.clear();
synchronized (pool)
{
if (currentIndex + 1 < maxSize)
{
pool[++currentIndex] = ctx;
}
}
}
瀵逛簬Entity...Pool,浠杘verwrite浜唂ree
/**
* Return an instance to the free pool. Reset state
*
*

Called in 3 cases:
*


    *
  • Done with finder method
    *
  • Removed
    *
  • Passivated
    *

*
* @param ctx
*/
public void free(EnterpriseContext ctx)
{
// If transaction still present don\\\\\\\\\\\\\\\'t do anything (let the instance be GC)
if (ctx.getTransaction() != null)
{
return ;
}
super.free(ctx);
}

-----------------------------------------------------
鑰孲tateful....Pool鐨刦ree鏂規(guī)硶overwrite浜咥bstract...Pool鐨勶紝
public synchronized void free(EnterpriseContext ctx)
{
discard(ctx);//騫茶剢灝眃iscard鎺変笉鐢ㄤ簡~
}

鍓╀笅鐨勪笅鍥炲啀璁詫紝鍏堥鍛?涓被浣撶郴錛?
1.AbstractInstanceCache ,鏈塃ntityInstanceCache鍜孲tatefulSessionInstanceCache 瀛愮被銆傚浜嶦ntity,鐢ㄥ畠鐨?
PrimaryKey浣淐ache鐨凨ey,瀵逛簬Stateful,Jboss涔熶細(xì)浠樼粰
姣忎釜instance涓涓敮涓鏍囧畾鐨勫肩敤鏉ュ仛CacheKey.
Abstract...Cache涓嶢bstract...Pool緇撳悎浣跨敤錛屽緱鍒板ソ鐨凱erformance銆?
2.public abstract class Container,
鏈塃ntityContainer,MessageDrivenContainer,Stateful/StatelessSessionContainer
4涓瓙綾伙紝鐢ㄦ潵鎻愪緵瀵笶JB instance鐨則ransaction/security/pool絳夋湇鍔°?
//鐪嬬湅瀹冪殑鎴愬憳鍙橀噺錛屽氨鑳界寽涓ぇ姒?
/** This is the TransactionManager */
protected TransactionManager tm;

/** This is the SecurityManager */
protected AuthenticationManager sm;

/** This is the instancepool that is to be used */
protected InstancePool instancePool;
 
寮濮嬭Container,浠ュ墠璇磋繃Container鏈?縐嶅瓙綾伙紝鍒嗗埆瀵瑰簲4縐嶇被鍨嬬殑EJB.
涓涓狢ontainer鏄墍鏈塁ontainer plugins(娉?)鍜宮etadata(娉?)鐨勯泦鏁e湴錛宼he container plugins鍙互浠巆ontainer鎷垮埌metadata鍜屽叾浠朿ontainer plugins.EJB閮ㄧ講鐨勬椂鍊欎細(xì)鍒涘緩鐩稿簲鐨凜ontainer.Container鍩烘湰涓嶅仛澶浜嬶紝涓昏delegate緇檖lugins浣滀簨鎯呫?
ok,璁╂垜浠潵鐪嬬湅Container鐨勬垚鍛樺彉閲忥細(xì)
/**
* This is the new metadata. it includes information from both ejb-jar and
* jboss.xml the metadata for the application can be accessed trough
* metaData.getApplicationMetaData()
*/
protected BeanMetaData metaData;

/** This is the EnterpriseBean class */
protected Class beanClass;

/** This is the Home interface class */
protected Class homeInterface;

/** This is the Remote interface class */
protected Class remoteInterface;

/** The local home interface class */
protected Class localHomeInterface;

/** The local inteface class */
protected Class localInterface;

/** This is the TransactionManager */
protected TransactionManager tm;

/** This is the SecurityManager */
protected AuthenticationManager sm;

/** This is the realm mapping */
protected RealmMapping rm;

/** This is the bean lock manager that is to be used */
protected BeanLockManager lockManager;

/** This is the application that this container is a part of */
protected EjbModule ejbModule;
//ejbModule浣滀負(fù)涓涓崟鍏冮儴緗茬殑Module,姣斿涓涓猠jb-jar灝辨槸涓涓狹odule,
/*榪欎釜 ejb-jar閲屽ご鍙兘鏈夊涓猠ntitybean,sessionbean,閭d箞瀵逛簬 姣忎釜entitybean,sessionbean
閮戒細(xì)鏈変竴涓搴旂殑container,鑰岃繖浜涗笢涓滃叡浜竴涓猠jbModule.*/
/**
* Returns a new instance of the bean class or a subclass of the bean class.
* This factory style method is speciffically used by a container to supply
* an implementation of the abstract accessors in EJB2.0, but could be
* usefull in other situations. This method should ALWAYS be used instead
* of getBeanClass().newInstance();
*
* @return the new instance
*
* @see java.lang.Class#newInstance
*/
public Object createBeanClassInstance() throws Exception {
return getBeanClass().newInstance();
}
public Class getBeanClass()
{
return beanClass;
}

娉ㄦ剰EntityContainer overwrite浜嗚繖涓柟娉曪細(xì)
/**
* Returns a new instance of the bean class or a subclass of the bean class.
* If this is 1.x cmp, simply return a new instance of the bean class.
* If this is 2.x cmp, return a subclass that provides an implementation
* of the abstract accessors.
*
* @see java.lang.Class#newInstance
*
* @return The new instance.
*/
public Object createBeanClassInstance() throws Exception {
return persistenceManager.createBeanClassInstance();
}
鍏朵腑 persistenceManager澹版槑涓猴細(xì)
/** This is the persistence manager for this container */
protected EntityPersistenceManager persistenceManager;
//persitenceManager鍜孭ersistenceStore鎴戜滑灝嗗湪絎?閮ㄥ垎璁茶В銆?
鐜板湪鍏堢粰涓ぇ鐣ュ嵃璞★細(xì)
BMPPersistenceManager瀹炵幇
public Object createBeanClassInstance() throws Exception {
return con.getBeanClass().newInstance();
}

CMPPersistenceManager瀹炵幇
EntityPersistenceStore store;
public Object createBeanClassInstance() throws Exception
{
return store.createBeanClassInstance();
}
-------------------------------------------------------------------
ok,鎺ヤ笅鏉ョ湅鐪婥ontainer濡備綍澶勭悊Client榪囨潵鐨処nvocation銆?
涓鍒囩簿褰╁敖鍦ㄤ笅闈㈣繖涓嚱鏁?
public Object invoke(Invocation mi)錛?
//Invocation浠h〃浜咰lient绔繃鏉ョ殑璋冪敤
//Invocation閲屽ご鏈変簺鎴愬憳鍙橀噺錛屾寚鏄庝簡瑕佽皟鐢ㄧ殑Method,
//args,Transaction淇℃伅錛宲rinciple/credential絳変俊鎭?

/** Maps for MarshalledInvocation mapping */
protected Map marshalledInvocationMapping = new HashMap();

public Object invoke(Invocation mi)
throws Exception
{
Thread currentThread = Thread.currentThread();
ClassLoader callerClassLoader = currentThread.getContextClassLoader();
//淇濆瓨鍘熸潵鐨刢lassloader,鍦╢inally閲屾仮澶?

Method m = null;
Object type = null;

try
{
currentThread.setContextClassLoader(this.classLoader);(娉?錛?
// Check against home, remote, localHome, local, getHome,
// getRemote, getLocalHome, getLocal
type = mi.getType();

if(type == InvocationType.REMOTE ||
type == InvocationType.LOCAL)
{
if (mi instanceof MarshalledInvocation)
{
((MarshalledInvocation) mi).setMethodMap(
marshalledInvocationMapping);
}
return internalInvoke(mi);
}
else if(type == InvocationType.HOME ||
type == InvocationType.LOCALHOME)
{
if (mi instanceof MarshalledInvocation)
{
((MarshalledInvocation) mi).setMethodMap(
marshalledInvocationMapping);
return internalInvokeHome(mi);
}
else
{
throw new MBeanException(new IllegalArgumentException(
\\\\\\\"Unknown invocation type: \\\\\\\" + type));
}
}
finally
{
currentThread.setContextClassLoader(callerClassLoader);
}
}

----------------------------------------------------------------
MarshalledInvocation鏄疘nvocation鐨勫瓧綾伙紝浠h〃鍙互浠?
Client浼犲埌Server鐨処nvocation
public class Invocation...

public class MarshalledInvocation
extends Invocation
implements java.io.Externalizable
鑰孖nvocation鏄湪server绔殑璋冪敤閾?Interceptor閾撅紝娉?錛?
闂翠紶閫?
-------------------------------------------------------
ok,紼嶅枠鍙f皵錛屾帴涓嬫潵鐪嬬湅涓や釜Internal鐨刬nvoke,
閮芥槸abstract,鍦ㄥ瓧綾誨疄鐜?
public abstract Object internalInvokeHome(Invocation mi)
throws Exception;
public abstract Object internalInvoke(Invocation mi)
throws Exception;
鑷充簬鍏蜂綋瀹炵幇涔堬紝TO BE CONITUE鎷?)
----------------------------------------------------
娉?錛欳ontainerPlugin鍙互鏀懼湪瀹瑰櫒閲屽ご鐨勪笢涓溿?
鎺ュ彛涓篿nterface ContainerPlugin 錛?
void setContainer(Container con);
鏈塈nstancePool,InstanceCache,EJBProxyFactory/LocalProxyFactory,
EntityPersistenceManager/EntityPersistenceStore絳塒lugin
娉?錛歮etadata鎻忚堪閮ㄧ講鐨勪俊鎭紝姣斿ejb-jar.xml錛屾弿榪頒粈涔堜笢涓滄槸
entitybean,浠涔堜笢涓滄槸sessionbean,session鐨勬槸BMP/CMP絳夌瓑銆?
娉?錛?Container鐨勬垚鍛樺彉閲弍rotected ClassLoader classLoader;
鐢ㄦ潵load 榪欎釜Container閲屽ご鐨勭被鍜岃祫婧愶紝涔嬫墍浠ヨ涓撻棬璁句竴涓狢ontainer
鐨刢lassLoader鏄洜涓鴻兘浣縀JB re-deployable.(JBoss瀹氭湡鎵弿deploy鐩綍錛?
濡傛灉ejb鏇存敼灝辮繘琛宺edeploy,濡傛灉ejb鍒犻櫎灝眜ndeploy)
娉?錛?Jboss浼?xì)寰忕珛涓涓狪nterceptor 閾撅紝Invocation緇忚繃閾句紶閫掋?
姣斿鏈塃ntityInterceptor錛孲ecurityInterceptor錛孴ransactionInterceptor錛?
InvokerInterceptor錛屼竴涓涓涓紝姣忎釜Interceptor瀵瑰綋鍓岻nvocation榪涜涓浜涘鐞?
錛屾瘮濡傛鏌ユ潈闄愶紝浜嬬墿絳夌瓑錛岀劧鍚庝紶緇欎笅涓涓狪nterceptor澶勭悊(榪欐槸Filter and Pipe妯″紡浜嗭紝涔熺畻鏄疉OP鎷墌錛屽埆浜鴻
JBoss 榪欎釜Interceptor瀹炵幇灞炰簬AOP鏂硅█鐗瑰埆閲嶏細(xì)錛夈?
鎵鏈夌殑Interceptor閮芥槸鐜?
Object invokeHome(Invocation mi) throws Exception;
鍜孫bject invoke(Invocation mi) throws Exception;
鍦ㄨ嚜宸眎nvoke鐨勬渶鍚庯紝
緇忚繃鎵鏈夌殑Interceptor涔嬪悗錛岃皟鐢ㄤ笅涓涓?
鐪嬬湅AbstractInterceptor鐨勭己鐪佸疄鐜幫細(xì)
public abstract class AbstractInterceptor
implements Interceptor

public Object invokeHome(final Invocation mi) throws Exception {
//do sth.
return getNext().invokeHome(mi);
}
public Object invoke(final Invocation mi) throws Exception {
//do sth.
return getNext().invoke(mi);
}
鍦ㄧ粡榪囬噸閲岻nterceptor涔嬪悗
鏈鍚庡埌杈綞JB Instance 璋冪敤浣犺鐨勯偅涓柟娉曘?BR>
鍏跺疄瀹炵幇寰堢畝鍗曪細(xì)
public Object internalInvokeHome(Invocation mi) throws Exception
{
return getInterceptor().invokeHome(mi);
}

public Object internalInvoke(Invocation mi) throws Exception
{
// Invoke through interceptors
return getInterceptor().invoke(mi);
}

public Interceptor getInterceptor()
{
return interceptor;
}
protected Interceptor interceptor;
//榪欐槸Container寤虹珛鐨処nterceptor閾劇殑澶翠竴涓紝浠庤繖閲岃皟璧穨
鍐嶆潵鐪嬬湅 void addInterceptor(Interceptor in);榪欎釜鍑芥暟
鍦↖nterceptor閾炬渶鍚庡啀鎸備竴涓狪nterceptor
public void addInterceptor(Interceptor in)
{
if (interceptor == null)
{
interceptor = in;
}
else
{
Interceptor current = interceptor;
while (current.getNext() != null)
{
current = current.getNext();
}

current.setNext(in);
}
}
------------------------------------------------------------------------
闄勫甫鍐嶆彁涓涓媝ool鍜宑ache
/** This is the instance cache for this container */
protected InstanceCache instanceCache;

/** This is the instancepool that is to be used */
protected InstancePool instancePool;
/** This is the instancepool that is to be used */
protected InstancePool instancePool;
-------------------------------------------------------------
public void setInstanceCache(InstanceCache ic)
{
if (ic == null)
throw new IllegalArgumentException(\\\"Null cache\\\");

this.instanceCache = ic;
ic.setContainer(this);
}

public InstanceCache getInstanceCache()
{
return instanceCache;
}
public void setInstancePool(InstancePool ip)
{
if (ip == null)
throw new IllegalArgumentException(\\\"Null pool\\\");

this.instancePool = ip;
ip.setContainer(this);
}
-----------------------------------------------------------------------
ok,鐜板湪璁╂垜浠潵鐪嬬湅Container閮藉EJB Instance鏆撮湶鍑烘潵鐨?
鏂規(guī)硶閮戒綔浜嗕簺浠涔堬紝榪樻湁濡備綍璋冪敤EJB Instance鐨勬柟娉?
榪欓噷鏈夐噸瑕佺殑2涓狹ap
/**
* These are the mappings between the home interface methods and the
* container methods.
* 鎵鏈塇ome 鏂規(guī)硶鏄犲皠閮藉瓨榪欓噷
*/
protected Map homeMapping = new HashMap();

/**
* These are the mappings between the remote/local interface methods and the
* bean methods.
* 鎵鏈塃JBObject鏂規(guī)硶鏄犲皠閮藉瓨榪欓噷
*/
protected Map beanMapping = new HashMap();
--------------------------------------------------------------------------
class ContainerInterceptor
extends AbstractContainerInterceptor
//AbstractContainerInterceptor鍩烘湰涓婁粈涔堥兘涓嶅仛錛屼笉鐢ㄧ湅
//ContainerInterceptor浠h〃Container setup鐨処nterceptor璋冪敤
//閾劇殑鏈鍚庝竴涓紝鍒拌繖閲屼綘灝變細(xì)鐪嬪埌浠栬皟鐢ㄤ簡浣犵殑EJB Instance鐨勬柟娉?
{
public Object invokeHome(Invocation mi) throws Exception
{
// Invoke and handle exceptions
Method miMethod = mi.getMethod();
Method m = (Method) homeMapping.get(miMethod);
if (m.getDeclaringClass().equals(EntityContainer.class))
{
try
{
return m.invoke(EntityContainer.this, new Object[] { mi });
}
catch (Exception e)
{
rethrow(e);
}
}
else // Home method
{
try
{
return m.invoke(((EnterpriseContext) mi.getEnterpriseContext()).getInstance(), mi.getArguments());
}
catch (Exception e)
{
rethrow(e);
}
}

// We will never get this far, but the compiler does not know that
throw new org.jboss.util.UnreachableStatementException();
}

public Object invoke(Invocation mi) throws Exception
{
// Get method
Method miMethod = mi.getMethod();
Method m = (Method) beanMapping.get(miMethod);
if( m == null )
{
String msg = \\\"Invalid invocation, check your deployment packaging\\\"
+\\\", method=\\\"+miMethod;
throw new EJBException(msg);
}

// Select instance to invoke (container or bean)
if (m.getDeclaringClass().equals(EntityContainer.class))
{
// Invoke and handle exceptions
try
{
return m.invoke(EntityContainer.this, new Object[]{ mi });
}
catch (Exception e)
{
rethrow(e);
}
}
else
{
// Invoke and handle exceptions
try
{
return m.invoke(((EnterpriseContext) mi.getEnterpriseContext()).getInstance(), mi.getArguments());
}
catch (Exception e)
{
rethrow(e);
}
}

// We will never get this far, but the compiler does not know that
throw new org.jboss.util.UnreachableStatementException();
}
}

//鍙互鐪嬪埌錛屼袱涓狹ap浣滀簡涓槧灝勶紝Map鐨凨ey涓?
鍦ㄤ綘鎯寵璋冪敤鐨凟JB instance鏂規(guī)硶錛寁alue涓哄疄闄?
瀹炵幇鐨勬柟娉曪紝鍙兘灝辨槸EJB instance鏈韓瀹炵幇鐨勬柟娉曪紝
鎴栬呮槸瀹瑰櫒甯繖瀹炵幇鐨?姣斿CMP 涓璦bstract get/set鏂規(guī)硶錛?
鍙兘瀹瑰櫒甯繖瀹炵幇).
浠庤繖閲屼篃鍙互鐪嬪嚭鏉ワ紝JBoss涓昏鏄繚瀛樹簡鏂規(guī)硶鏄犲皠鏉ュ鐞?
EJBObject/EJBLocalObject 鐨勮皟鐢ㄨ姹?
鑰屽叾浠栦竴浜汮2EE AS鏄氳繃鍔ㄦ佺敓鎴怑JBObject/EJBLocalObject
鍜屼綘鐨凟JB Instance鐨勫瓧綾繪潵瀹炵幇鐨勶紙鑰孞Boss灝辯畻鍦–MP2.0
閲屽姩鎬佺敓鎴愪簡涓涓笢涓滐紝閭d篃涓嶆槸EJB Instance鐨勫瓙綾?銆?/DIV>
 
ok,鍩烘湰寮勬槑鐧戒簡Container鐨勫師鐞嗕箣鍚庯紝鎴戜滑鏉ョ湅鐪?
鍒板簳Container鐨勪竴浜涘垵濮嬪寲鎿嶄綔
Container綆楁槸涓欏規(guī)湇鍔★紝
JBoss鍦╠eploy/undeploy/redeploy鏃朵細(xì)璋冪敤
涓嶴ervice鐩稿叧鐨勫嚑涓嚱鏁幫細(xì)
protected void createService() throws Exception {}
protected void startService() throws Exception {}
protected void stopService() throws Exception {}
protected void destroyService() throws Exception {}
璁╂垜浠粠EntityContainer鐪嬭搗錛?

protected void createService() throws Exception
{
// Associate thread with classloader
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClassLoader());

try
{
// Acquire classes from CL
//浠巑etadata鎷垮埌Home/Remote鐨凜lass
if (metaData.getHome() != null)
homeInterface = classLoader.loadClass(metaData.getHome());
if (metaData.getRemote() != null)
remoteInterface = classLoader.loadClass(metaData.getRemote());

// Call default init
// 璋冪敤Container閲屽ご鐨凜reateService,鎴戜滑鍥炲ご鍐嶇湅
super.createService();

//寤虹珛鍒氭墠鎵璇寸殑涓や釜Method鏄犲皠Map
setupBeanMapping();
setupHomeMapping();

// Map the interfaces to Long
setupMarshalledInvocationMapping();

// Initialize pool
instancePool.create();
// Try to register the instance pool as an MBean
try
{
ObjectName containerName = super.getJmxName();
Hashtable props = containerName.getKeyPropertyList();
props.put(\\\"plugin\\\", \\\"pool\\\");
ObjectName poolName = new ObjectName(containerName.getDomain(), props);
server.registerMBean(instancePool, poolName);
}
catch(Throwable t)
{
log.debug(\\\"Failed to register cache as mbean\\\", t);
}

// Init instance cache
instanceCache.create();
// Try to register the instance cache as an MBean
try
{
ObjectName containerName = super.getJmxName();
Hashtable props = containerName.getKeyPropertyList();
props.put(\\\"plugin\\\", \\\"cache\\\");
ObjectName cacheName = new ObjectName(containerName.getDomain(), props);
server.registerMBean(instanceCache, cacheName);
}
catch(Throwable t)
{
log.debug(\\\"Failed to register cache as mbean\\\", t);
}


for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); )
{
String invokerBinding = (String)it.next();
EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding);
ci.create();
}



// Init persistence
persistenceManager.create();

// Initialize the interceptor by calling the chain
Interceptor in = interceptor;
while (in != null)
{
in.setContainer(this);
in.create();
in = in.getNext();
}
readOnly = ((EntityMetaData)metaData).isReadOnly();
}
finally
{
// Reset classloader
Thread.currentThread().setContextClassLoader(oldCl);
}
}



protected void startService() throws Exception
{
// Associate thread with classloader
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClassLoader());

try
{
// Call default start
super.startService();

// Start container invokers
for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); )
{
String invokerBinding = (String)it.next();
EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding);
ci.start();
}

// Start instance cache
instanceCache.start();

// Start persistence
persistenceManager.start();

// Start the instance pool
instancePool.start();

// Start all interceptors in the chain
Interceptor in = interceptor;
while (in != null)
{
in.start();
in = in.getNext();
}
}
finally
{
// Reset classloader
Thread.currentThread().setContextClassLoader(oldCl);
}
}

protected void stopService() throws Exception
{
// Associate thread with classloader
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClassLoader());

try
{
//Stop items in reverse order from start
//This assures that CachedConnectionInterceptor will get removed
//from in between this and the pm before the pm is stopped.
// Stop all interceptors in the chain
Interceptor in = interceptor;
while (in != null)
{
in.stop();
in = in.getNext();
}

// Stop the instance pool
instancePool.stop();


// Stop persistence
persistenceManager.stop();

// Stop instance cache
instanceCache.stop();

// Stop container invoker
for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); )
{
String invokerBinding = (String)it.next();
EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding);
ci.stop();
}

// Call default stop
super.stopService();
}
finally
{
// Reset classloader
Thread.currentThread().setContextClassLoader(oldCl);
}
}

protected void destroyService() throws Exception
{
// Associate thread with classloader
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClassLoader());

try
{
// Destroy container invoker
for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); )
{
String invokerBinding = (String)it.next();
EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding);
ci.destroy();
}

// Destroy instance cache
instanceCache.destroy();
instanceCache.setContainer(null);
try
{
ObjectName containerName = super.getJmxName();
Hashtable props = containerName.getKeyPropertyList();
props.put(\\\"plugin\\\", \\\"cache\\\");
ObjectName cacheName = new ObjectName(containerName.getDomain(), props);
server.unregisterMBean(cacheName);
}
catch(Throwable ignore)
{
}

// Destroy persistence
persistenceManager.destroy();
persistenceManager.setContainer(null);

// Destroy the pool
instancePool.destroy();
instancePool.setContainer(null);
try
{
ObjectName containerName = super.getJmxName();
Hashtable props = containerName.getKeyPropertyList();
props.put(\\\"plugin\\\", \\\"pool\\\");
ObjectName poolName = new ObjectName(containerName.getDomain(), props);
server.unregisterMBean(poolName);
}
catch(Throwable ignore)
{
}

// Destroy all the interceptors in the chain
Interceptor in = interceptor;
while (in != null)
{
in.destroy();
in.setContainer(null);
in = in.getNext();
}

MarshalledInvocation.removeHashes(homeInterface);
MarshalledInvocation.removeHashes(remoteInterface);

// Call default destroy
super.destroyService();
}
finally
{
// Reset classloader
Thread.currentThread().setContextClassLoader(oldCl);
}
}
------------------------------------------------------------
protected void setupBeanMapping() throws Exception
{
try {
if (remoteInterface != null)
{
Method[] m = remoteInterface.getMethods();
setupBeanMappingImpl( m, \\\"javax.ejb.EJBObject\\\" );
}
if (localInterface != null)
{
Method[] m = localInterface.getMethods();
setupBeanMappingImpl( m, \\\"javax.ejb.EJBLocalObject\\\" );
}
}
catch (Exception e)
{
// ditch the half built mappings
homeMapping.clear();
beanMapping.clear();

throw e;
}
}

private void setupBeanMappingImpl( Method[] m, String intfName )
throws Exception
{
for (int i = 0; i < m.length; i++)
{
if (!m.getDeclaringClass().getName().equals(intfName))
{
// Implemented by bean
beanMapping.put(m, beanClass.getMethod(m.getName(), m.getParameterTypes()));
}
else
{
// Implemented by container
beanMapping.put(m, getClass().getMethod(m.getName(),
new Class[] { Invocation.class }));
}
}
}
private void setupHomeMappingImpl(Method[] m,
String finderName,
String append)
throws Exception
{
// Adrian Brock: This should go away when we don\\\'t support EJB1x
boolean isEJB1x = metaData.getApplicationMetaData().isEJB1x();

for (int i = 0; i < m.length; i++)
{
String methodName = m.getName();
try
{
try // Try home method
{
String ejbHomeMethodName = \\\"ejbHome\\\" + methodName.substring(0,1).toUpperCase() + methodName.substring(1);
homeMapping.put(m, beanClass.getMethod(ejbHomeMethodName, m.getParameterTypes()));

continue;
}
catch (NoSuchMethodException ignore) {} // just go on with other types of methods


// Implemented by container (in both cases)
if (methodName.startsWith(\\\"find\\\"))
{
homeMapping.put(m, this.getClass().getMethod(finderName, new Class[] { Invocation.class }));
}
else if (methodName.equals(\\\"create\\\") ||
(isEJB1x == false && methodName.startsWith(\\\"create\\\")))
{
homeMapping.put(m, this.getClass().getMethod(\\\"create\\\"+append, new Class[] { Invocation.class }));
beanMapping.put(m, this.getClass().getMethod(\\\"postCreate\\\"+append, new Class[] { Invocation.class }));
}
else
{
homeMapping.put(m, this.getClass().getMethod(methodName+append, new Class[] { Invocation.class }));
}
}
catch (NoSuchMethodException e)
{
throw new NoSuchMethodException(\\\"Could not find matching method for \\\"+m);
}
}
}

protected void setupHomeMapping() throws Exception
{
try {
if (homeInterface != null)
{
Method[] m = homeInterface.getMethods();
setupHomeMappingImpl( m, \\\"find\\\", \\\"Home\\\" );
}
if (localHomeInterface != null)
{
Method[] m = localHomeInterface.getMethods();
setupHomeMappingImpl( m, \\\"findLocal\\\", \\\"LocalHome\\\" );
}

// Special methods

// Get the One on Handle (getEJBObject), get the class
Class handleClass = Class.forName(\\\"javax.ejb.Handle\\\");

// Get the methods (there is only one)
Method[] handleMethods = handleClass.getMethods();

//Just to make sure let\\\'s iterate
for (int j=0; j {
//Get only the one called handle.getEJBObject
if (handleMethods[j].getName().equals(\\\"getEJBObject\\\"))
{
//Map it in the home stuff
homeMapping.put(handleMethods[j],
this.getClass().getMethod(\\\"getEJBObject\\\",
new Class[] {Invocation.class}));
}
}
}
catch (Exception e)
{
// ditch the half built mappings
homeMapping.clear();
beanMapping.clear();

throw e;
}
}



絎ㄧ 2005-03-29 09:46 鍙戣〃璇勮
]]> 主站蜘蛛池模板: 亚洲天堂中文字幕| 亚洲精品乱码久久久久久V| 成人免费视频69| 亚洲色无码国产精品网站可下载| 四虎永久精品免费观看| 久久免费美女视频| 中文字幕乱码亚洲无线三区| 国产亚洲情侣一区二区无| 人成午夜免费视频在线观看| 狠狠躁狠狠爱免费视频无码| 亚洲乱码无限2021芒果| 亚洲人成网站色在线入口| 在线日本高清免费不卡| 免费福利资源站在线视频| 久久综合亚洲色HEZYO社区| 四虎国产精品免费视| 最近中文字幕国语免费完整 | 亚洲AV无码乱码国产麻豆穿越| 我们的2018在线观看免费高清| 国产A∨免费精品视频| 亚洲综合中文字幕无线码| 国产亚洲婷婷香蕉久久精品 | 亚洲最大在线视频| 亚洲精品无码专区久久久| 全免费a级毛片免费看不卡| 久久久久久影院久久久久免费精品国产小说 | 免费大黄网站在线观看| jjizz全部免费看片| 国产一二三四区乱码免费| 亚洲丰满熟女一区二区哦| 亚洲精品美女久久久久| 亚洲国产另类久久久精品小说| 国产乱子伦精品免费无码专区 | 亚洲第一中文字幕| 亚洲五月综合缴情在线观看| 在线视频免费国产成人| 中文字幕无码成人免费视频| 777成影片免费观看| 日韩免费在线视频| 在线观看特色大片免费网站| 一级做a爱过程免费视|