عرض عملي: بناء @Timed مصغّر باستخدام وكيل
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
build an annotation-driven interceptor; prepares MID-009-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Define
@Timed(RUNTIME, METHOD) and an interfacePriceServicewith an implementation. - Write a
Proxy.newProxyInstancehandler that checks the annotation on the target method and logs elapsed time. - Call through the proxy; see the timing log.
- Planned mistake: annotate only the interface method and read the annotation from the implementation class (not found). Fix: look up the annotation on the target class method (and note Spring's own lookup rules).
- Add an internal call between two methods; show it is not timed (self-invocation).
- Discuss reflection cost and caching
Methodlookups.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.