W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
如果您不想手動(dòng)創(chuàng)建本地spans,則可以使用@NewSpan
批注。另外,我們提供了@SpanTag
批注以自動(dòng)方式添加標(biāo)簽。
現(xiàn)在我們可以考慮一些用法示例。
@NewSpan void testMethod();
在不帶任何參數(shù)的情況下對(duì)方法進(jìn)行注釋會(huì)導(dǎo)致創(chuàng)建一個(gè)新的跨度,其名稱(chēng)等于帶注釋的方法名稱(chēng)。
@NewSpan("customNameOnTestMethod4") void testMethod4();
如果您在批注中提供值(直接或通過(guò)設(shè)置name
參數(shù)),則創(chuàng)建的跨度將提供的值作為名稱(chēng)。
// method declaration @NewSpan(name = "customNameOnTestMethod5") void testMethod5(@SpanTag("testTag") String param); // and method execution this.testBean.testMethod5("test");
您可以將名稱(chēng)和標(biāo)簽結(jié)合在一起。讓我們專(zhuān)注于后者。在這種情況下,帶注釋的方法的參數(shù)運(yùn)行時(shí)值的值將成為標(biāo)記的值。在我們的示例中,標(biāo)記鍵為testTag
,標(biāo)記值為test
。
@NewSpan(name = "customNameOnTestMethod3") @Override public void testMethod3() { }
您可以在類(lèi)和接口上都放置@NewSpan
批注。如果您重寫(xiě)接口的方法并為@NewSpan
批注提供一個(gè)不同的值,則最具體的將獲勝(在這種情況下,將設(shè)置customNameOnTestMethod3
)。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: