買這商品的人也買了...
-
$650$514 -
$880$695 -
$780CMMI: Guidelines for Process Integration and Product Improvement (Harcover)
-
$760$600 -
$590$466 -
$1,740$1,653 -
$560$476 -
$2,390$2,271 -
$2,220$2,109 -
$480$379 -
$750$593 -
$780$616 -
$490$382 -
$990$782 -
$490$417 -
$2,550$2,423 -
$650$507 -
$1,078Operating System Principles, 7/e(IE) (美國版ISBN:0471694665-Operating System Concepts, 7/e) (平裝)
-
$620$558 -
$650$507 -
$680$666 -
$450$356 -
$950Assembly Language for Intel-Based Computers, 5/e (IE) (美國版ISBN:0132383101)
-
$774Concepts of Programming Languages, 8/e(美國版ISBN: 0321493621)
-
$520$411
商品描述
Description:
You are a Java developer. You are asked to add a simple feature to your application. But "simple" can be deceiving: you have to make many changes, in locations which can be difficult to find.
If this sounds familiar, you want to know about Java reflection. With reflection, you can work smarter by designing flexible applications to which you can easily add likely new requirements. Then, with a few code changes in easy-to-find places, you've got the job done. Reflection adds a new dimension to your programming skills. It will boost your effectiveness.
Java Reflection in Action starts from the basics. It gradually builds a complete understanding, adding as it goes reflective concepts illustrated with many small examples that are useful in real applications.
In a subplot, the book follows a programmer, George, as he tackles common but difficult tasks. In each case, George finds flexible, reflective solutions that replace the usual hard-coded ones. The power of reflection becomes clear through his story.
Table of Contents:
preface xiii
acknowledgments xv
about this book xvii
about the title xx
about the cover illustration xxi
- 1 A few basics 1
- Reflection's value proposition 3
- Enter George the programmer 4
- Choosing reflection 5 - Programming a reflective solution 6
- Examining running programs 8
- Finding a method at runtime 10
- Representing types with class objects 12
- Representing primitive types 13 - Representing interfaces 13 - Representing array types 14
- Understanding method objects 14
- Using dynamic invocation 15 - Using primitives with dynamic invocation 16 - Avoiding invocation pitfalls 17
- Diagramming for reflection 19
- Navigating the inheritance hierarchy 20
- Introspecting the inheritance hierarchy 22 - Exposing some surprises 23 - Another reflective circularity 24
- Summary 26
- 2 Accessing fields reflectively 27
- Serializing objects 28
- Serializing to XML 29 - Choosing reflection 30 - Designing serialization with reflection 30
- Finding fields at runtime 31
- Understanding field objects 33
- Getting and setting field values 34
- Examining modifiers 35
- Introducing Member 36 - Interface introspection pitfall 37 - Introspecting for instance variables 37
- Accessing nonpublic members 38
- Working with arrays 40
- Serialization: putting it all together 41
- Serializing each component 43 - Serializing instance variables 43
- Using reflective serialization 45
- Summary 48
- 3 Dynamic loading and reflective construction 49
- George's deployment problem 50
- Designing with patterns 51 - Programming a reflective solution 52 - Enhancing the factory method with reflection 54 - Combining - benefits of delegation and reflection 54
- Loading classes dynamically 55
- Basics of forName 55 - Getting array classes 56 - Primitives and forName 56
- Constructing objects reflectively 57
- Reflective construction basics 57 - Using constructor objects 57 - Constructing arrays reflectively 59
- Designing for dynamic loading 60
- Disadvantages of reflective construction with arguments 61 - Initializing through an interface 62
- Implementing deserialization 63
- Initiating deserialization 64 - Constructing the instances 65 - Restoring the object structure 66
- George's serialization: limitations 69
- No interaction with readObject or writeObject 69 - No handling of final instance variables 70 - Only no-argument constructors 70 - No handling of illegal XML characters 70 - Performance 71
- Summary 71
- 4 Using Java's dynamic proxy 73
- Working with proxies 74
- George's tracing problem 76
- Exploring Proxy 77
- Understanding invocation handlers 79 - Handling the methods of Object 80
- Implementing a tracing proxy 81
- A note on factories 84
- Chaining proxies 86
- Structuring invocation handlers for chaining 86 - Implementing a synchronized proxy 88 - Chaining the two proxies 89
- Stubbing interfaces for unit testing 90
- Examining stubs 90 - Design for stubbing with Proxy 91 - Implementation of stubbing with Proxy 93
- Generating SOAP remote proxies 99
- Pitfalls of using Proxy 103
- Summary 105
- 5 Call stack introspection 107
- George's logging problem 108
- Performing call stack introspection 111
- Logging with call stack introspection 112
- Pitfalls 114
- Class invariant checking 115
- Summary 120
- 6 Using the class loader 121
- George's test problem 122
- Essentials of ClassLoader 123
- Understanding the delegation model 123 - Programming a simple class loader 127 - Reinitializing static fields: a solution 128
- Multiple namespaces 130
- Dynamic class replacement 132
- Designing for replacement 132 - Implementing replacement 134 - Simplifying assumptions 137
- Additional considerations 138
- Security 139 - Don't reinvent the wheel 139 - Modifying bytecode in a class loader 140 - When not to invent a specialized class loader 140 - Additional examples 141 - Endorsed Standards - Override 142
- Summary 142
- 7 Reflective code generation 143
- Reflective code generation 143
- Generating HelloWorld.java 145
- Class-to-class transformation framework 147
- C2C 148 - Args 152 - C2CConstructor 154 - C2CTransformation 157
- Example: extent management 159
- C2IdentitySubclassOfC and its subclasses 168
- UQueue 170
- Using the framework 173
- Relation to Aspect-Oriented Programming 175
- Summary 176
- 8 Design patterns 179
- Singleton 181
- Decorator class-to-class transformations 187
- Proxy (again) 197
- Another composition feature 201
- Problematic issues in writing class-to-class transformations 201
- Summary 204
- 9 Evaluating performance 207
- Evaluating performance 207
- Categorizing performance impact 209
- Using microbenchmarks 210
- Benchmarking two ways to use Proxy 214
- Understanding Amdahl's Law 218
- Applying Amdahl's Law 221
- Summary 223
- 10 Reflecting on the future 225
- Looking forward: Java 1.5 226
- JSR 14-Generics 227 - JSR 175-Annotation Facility 229 - JSR 201-Language extensions 234 - Impact of Java 1.5 on reflective code 235
- Looking forward: competition for Java reflection 236
- C# 236 - Python 236 - Smalltalk 236 - CLOS 237 - Ruby 237 - Perl 237
- Looking forward: Aspect-Oriented Programming 237
- Looking forward: your career 238
appendix A Reflection and metaobject protocols 241
appendix B Handling compilation errors in the "Hello world!" program 253
appendix C UML 256
glossary 258
references 260
index 267
商品描述(中文翻譯)
描述:
您是一名 Java 開發人員。您被要求為您的應用程式添加一個簡單的功能。但「簡單」可能會讓人誤解:您需要在難以找到的位置進行許多更改。
如果這聽起來很熟悉,您想了解 Java 反射。透過反射,您可以更聰明地工作,設計靈活的應用程式,讓您可以輕鬆添加可能的新需求。然後,只需在易於找到的地方進行幾個代碼更改,您就完成了工作。反射為您的程式設計技能增添了新的維度,將提升您的工作效率。
《Java 反射實戰》從基礎開始,逐步建立完整的理解,隨著進展添加反射概念,並用許多小範例來說明,這些範例在實際應用中非常有用。
在一個副情節中,這本書跟隨一位程式設計師喬治,當他處理常見但困難的任務時。在每個案例中,喬治找到靈活的反射解決方案,取代了通常的硬編碼解決方案。透過他的故事,反射的力量變得清晰可見。
目錄:
前言 xiii
致謝 xv
關於本書 xvii
關於書名 xx
關於封面插圖 xxi
1 一些基礎 1
反射的價值主張 3
程式設計師喬治登場 4
選擇反射 5 - 編寫反射解決方案 6
檢查運行中的程式 8
在運行時查找方法 10
用類對象表示類型 12
表示原始類型 13 - 表示介面 13 - 表示數組類型 14
理解方法對象 14
使用動態調用 15 - 使用原始類型進行動態調用 16 - 避免調用陷阱 17
為反射繪製圖表 19
導航繼承層次結構 20
檢查繼承層次結構 22 - 揭示一些驚喜 23 - 另一個反射的循環 24
總結 26
2 反射性地訪問字段 27
序列化對象 28
序列化為 XML 29 - 選擇反射 30 - 使用反射設計序列化 30
在運行時查找字段 31
理解字段對象 33
獲取和設置字段值 34
檢查修飾符 35
介紹成員 36 - 介面反思陷阱 37 - 反思實例變量 37
訪問非公共成員 38
處理數組 40
序列化:整合所有內容 41
序列化每個組件 43 - 序列化實例變量 43
使用反射序列化 45
總結 48
3 動態加載和反射構造 49
喬治的部署問題 50
使用模式設計 51 - 編寫反射解決方案 52 - 使用反射增強工廠方法 54 - 結合委派和反射的好處 54
動態加載類 55
forName 的基本知識 55 - 獲取數組類 56 - 原始類型和 forName 56
反射性地構造對象 57
反射構造的基本知識 57 - 使用構造函數對象 57 - 反射性地構造數組 59
為動態加載設計 60
反射構造的缺點 61 - 通過介面初始化 62
實現反序列化 63
啟動反序列化 64 - 構造實例 65 - 恢復對象結構 66
喬治的序列化:限制 69
與 readObject 或 writeObject 無互動 69 - 不處理最終實例變量 70 - 只有無參構造函數 70 - 不處理非法 XML 字符 70 - 性能 71
總結 71
4 使用 Java 的動態代理 73
處理代理 74
喬治的追蹤問題 76
探索 Proxy 77
理解調用處理器 79 - 處理 Object 的方法 80
實現追蹤代理 81
關於工廠的說明 84
鏈接代理 86
為鏈接結構調用處理器 86 - 實現同步代理 88 - 鏈接兩個代理 89
為單元測試建立接口 90
檢查存根 90 - 使用 Proxy 設計存根 91 - 使用 Proxy 實現存根 93
生成 SOAP 遠程代理 99
使用 Proxy 的陷阱 103
總結 105
5 調用堆棧反思 107
喬治的日誌問題 108
執行調用堆棧反思 111
使用調用堆棧反思進行日誌記錄 112
陷阱 114
類不變性檢查 115
總結 120
6 使用類加載器 121
喬治的測試問題 122
ClassLoader 的基本知識 123
理解委派模型 123 - 編寫簡單的類加載器 127 - 重新初始化靜態字段:一個解決方案 128
多個命名空間 130
動態類替換 132
為替換設計 132 - 實現替換 134 - 簡化假設 137
其他考量 138
安全性 139 - 不要重複造輪子 139 - 在類加載器中修改字節碼 140 - 何時不應發明專用類加載器 140 - 其他範例 141 - 認可的標準 - 覆蓋 142
總結 142
7 反射性代碼生成 143
反射性代碼生成 143
生成 HelloWorld.java 145
類到類轉換框架 147
C2C 148 - Args 152 - C2CConstructor 154 - C2CTransformation 157
範例:範圍管理 159
C2IdentitySubclassOfC 及其子類 168
UQueue 170
使用該框架 173
與面向方面編程的關係 175
總結 176
8 設計模式 179
單例 181
裝飾者類到類轉換 187
代理(再次) 197
另一個組合特性 201
編寫類到類轉換的問題 201
總結 204
9 性能評估 207
評估性能 207
分類性能影響 209
使用微基準 210
基準測試兩種使用 Proxy 的方式 214
理解阿姆達爾法則 218
應用阿姆達爾法則 221
總結 223
10 反思未來 225
展望未來:Java 1.5 226
JSR 14-泛型 227 - JSR 175-註解設施 229 - JSR 201-語言擴展 234 - Java 1.5 對反射代碼的影響 235
展望未來:Java 反射的競爭 236
C# 236 - Python 236 - Smalltalk 236 - CLOS 237 - Ruby 237 - Pe