BOPF的這些determination,其方法不須要application developer本身去調用,而是被BOPF框架經過調用interface method的方式被調用。
Spring MVC的@RequestMapping工做原理相似,但實現方式稍稍高級點,用的是Java的反射。app
ProductPageController這個類的productDetail方法加上了@RequestMapping, 參數是:框架
當我點了product list上某個product的image想進入detail page時:url
這個包含了p的url就會被Spring MVCdelegate到我經過@RequestMapping註冊的controller class上。從debugger裏能看出個人controller class已經被成功地determine出來了。因此從本質上講,@RequestMapping和在ABAP裏經常使用的把CLAS名字配到表裏的方法其目的都同樣:註冊,只是Annotation更加優雅和簡便一點而已。spa
掃描原理見我博客:
A simulation of Java Spring dependency injection annotation @Inject in ABAP.
How does component-scan work in Spring Framework
How does @Autowired work in Spring framework
要執行的方法名字在這:debug
最後這個方法經過反射在line 497行被調用。3d
注意在Java裏,每一個類的每一個方法的元數據均可以被sun.reflect.MethodAccessor的一個實例來描述,而ABAP裏反射的granularity只到Class level,只有CL_ABAP_CLASSDESCR,沒有CL_ABAP_CLASS_METHODDESCR!component
要獲取更多Jerry的原創文章,請關注公衆號"汪子熙":blog