日期:2014-05-16  浏览次数:21063 次

AspectJ鍒囧叆鐐硅娉曡瑙?杞?

杞浇鑷?http://blog.csdn.net/is_zhoufeng/article/details/7821396

6.5聽 AspectJ鍒囧叆鐐硅娉曡瑙?/h2>

6.5.1聽 Spring AOP鏀寔鐨凙spectJ鍒囧叆鐐规寚绀虹

聽聽聽聽聽聽 鍒囧叆鐐规寚绀虹鐢ㄦ潵鎸囩ず鍒囧叆鐐硅〃杈惧紡鐩殑锛岋紝鍦⊿pring AOP涓洰鍓嶅彧鏈夋墽琛屾柟娉曡繖涓€涓繛鎺ョ偣锛孲pring AOP鏀寔鐨凙spectJ鍒囧叆鐐规寚绀虹濡備笅锛?/p>

聽 聽 聽 聽 聽execution锛?/strong>鐢ㄤ簬鍖归厤鏂规硶鎵ц鐨勮繛鎺ョ偣锛?/p>

聽 聽 聽 聽 聽within锛?/strong>鐢ㄤ簬鍖归厤鎸囧畾绫诲瀷鍐呯殑鏂规硶鎵ц锛?/em>

聽 聽 聽 聽 聽this锛?/strong>鐢ㄤ簬鍖归厤褰撳墠AOP浠g悊瀵硅薄绫诲瀷鐨勬墽琛屾柟娉曪紱娉ㄦ剰鏄疉OP浠g悊瀵硅薄鐨勭被鍨嬪尮閰嶏紝杩欐牱灏卞彲鑳藉寘鎷紩鍏ユ帴鍙d篃绫诲瀷鍖归厤锛?/em>

聽 聽 聽 聽 聽target锛?/strong>鐢ㄤ簬鍖归厤褰撳墠鐩爣瀵硅薄绫诲瀷鐨勬墽琛屾柟娉曪紱娉ㄦ剰鏄洰鏍囧璞$殑绫诲瀷鍖归厤锛岃繖鏍峰氨涓嶅寘鎷紩鍏ユ帴鍙d篃绫诲瀷鍖归厤锛?/em>

聽 聽 聽 聽 聽args锛?/strong>鐢ㄤ簬鍖归厤褰撳墠鎵ц鐨勬柟娉曚紶鍏ョ殑鍙傛暟涓烘寚瀹氱被鍨嬬殑鎵ц鏂规硶锛?/em>

聽 聽 聽 聽 聽@within锛?/strong>鐢ㄤ簬鍖归厤鎵€浠ユ寔鏈夋寚瀹氭敞瑙g被鍨嬪唴鐨勬柟娉曪紱

聽 聽 聽 聽 聽@target锛?/strong>鐢ㄤ簬鍖归厤褰撳墠鐩爣瀵硅薄绫诲瀷鐨勬墽琛屾柟娉曪紝鍏朵腑鐩爣瀵硅薄鎸佹湁鎸囧畾鐨勬敞瑙o紱

聽 聽 聽 聽 聽@args锛?/strong>鐢ㄤ簬鍖归厤褰撳墠鎵ц鐨勬柟娉曚紶鍏ョ殑鍙傛暟鎸佹湁鎸囧畾娉ㄨВ鐨勬墽琛岋紱

聽 聽 聽 聽 聽@annotation锛?/strong>鐢ㄤ簬鍖归厤褰撳墠鎵ц鏂规硶鎸佹湁鎸囧畾娉ㄨВ鐨勬柟娉曪紱

聽 聽 聽 聽 聽bean锛?/strong>Spring AOP鎵╁睍鐨勶紝AspectJ娌℃湁瀵逛簬鎸囩ず绗︼紝鐢ㄤ簬鍖归厤鐗瑰畾鍚嶇О鐨凚ean瀵硅薄鐨勬墽琛屾柟娉曪紱

聽 聽 聽 聽 聽reference pointcut锛?/strong>琛ㄧず寮曠敤鍏朵粬鍛藉悕鍒囧叆鐐癸紝鍙湁@ApectJ椋庢牸鏀寔锛孲chema椋庢牸涓嶆敮鎸併€?/em>

聽聽聽聽聽聽 AspectJ鍒囧叆鐐规敮鎸佺殑鍒囧叆鐐规寚绀虹杩樻湁锛?call銆乬et銆乻et銆乸reinitialization銆乻taticinitialization銆乮nitialization銆乭andler銆乤dviceexecution銆亀ithincode銆乧flow銆乧flowbelow銆乮f銆丂this銆丂withincode锛涗絾Spring AOP鐩墠涓嶆敮鎸佽繖浜涙寚绀虹锛屼娇鐢ㄨ繖浜涙寚绀虹灏嗘姏鍑篒llegalArgumentException寮傚父銆傝繖浜涙寚绀虹Spring AOP鍙兘浼氬湪浠ュ悗杩涜鎵╁睍銆?/p>

6.5.1聽 鍛藉悕鍙婂尶鍚嶅垏鍏ョ偣

聽聽聽聽聽聽 鍛藉悕鍒囧叆鐐瑰彲浠ヨ鍏朵粬鍒囧叆鐐瑰紩鐢紝鑰屽尶鍚嶅垏鍏ョ偣鏄笉鍙互鐨勩€?/p>

聽聽聽聽聽聽 鍙湁@AspectJ鏀寔鍛藉悕鍒囧叆鐐癸紝鑰孲chema椋庢牸涓嶆敮鎸佸懡鍚嶅垏鍏ョ偣銆?/p>

濡備笅鎵€绀猴紝@AspectJ浣跨敤濡備笅鏂瑰紡寮曠敤鍛藉悕鍒囧叆鐐癸細

6.5.2聽聽聽聽聽聽聽 锛涚被鍨嬪尮閰嶈娉?/h3>

棣栧厛璁╂垜浠潵浜嗚В涓婣spectJ绫诲瀷鍖归厤鐨勯€氶厤绗︼細

聽 聽 聽 聽 聽*锛氬尮閰嶄换浣曟暟閲忓瓧绗︼紱

聽 聽 聽 聽 聽..锛氬尮閰嶄换浣曟暟閲忓瓧绗︾殑閲嶅锛屽鍦ㄧ被鍨嬫ā寮忎腑鍖归厤浠讳綍鏁伴噺瀛愬寘锛涜€屽湪鏂规硶鍙傛暟妯″紡涓尮閰嶄换浣曟暟閲忓弬鏁般€?/p>