1. Trang chủ
  2. » Công Nghệ Thông Tin

Programming Groovy dynamic productivity for the java developer phần 1 docx

31 262 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 31
Dung lượng 233,48 KB

Nội dung

[...]... 10 .6 Accessing Microsoft Excel 16 4 16 5 16 6 16 7 16 8 16 9 16 9 11 Working with Scripts and Classes 11 .1 The Melting Pot of Java and Groovy 11 .2 Running Groovy 11 .3 Using Groovy Classes from Groovy 11 .4 Using Groovy Classes from Java 11 .5 Using Java Classes from Groovy 11 .6 Using Groovy Scripts from Groovy 11 .7... 11 .7 Using Groovy Scripts from Java 11 .8 Ease of Integration 17 2 17 2 17 3 17 4 17 5 17 6 17 8 18 0 18 2 III MOPping Groovy 18 3 12 Exploring Meta-Object Protocol (MOP) 18 4 12 .1 Groovy Object 18 5 12 .2 Querying Methods and Properties 19 0 12 .3 Dynamically... II Using Groovy 14 0 8 Exploring the GDK 14 1 8 .1 Object Extensions 14 1 8.2 Other Extensions 14 7 9 Working with XML 15 5 9 .1 Parsing XML 15 5 9.2 Creating XML 16 0 10 Working with Databases 10 .1 Connecting to a Database 10 .2 Database Select 10 .3 Transforming Data to XML 10 .4 Using DataSet 10 .5 Inserting... Objects 19 2 13 Intercepting Methods Using MOP 19 4 13 .1 Intercepting Methods Using GroovyInterceptable 19 4 13 .2 Intercepting Methods Using MetaClass 19 7 11 CONTENTS 14 MOP 14 .1 14.2 14 .3 14 .4 14 .5 14 .6 Method Injection and Synthesis Injecting Methods Using Categories Injecting Methods Using ExpandoMetaClass Injecting Methods into Specific Instances Method Synthesis Using methodMissing... love Groovy Groovy is dynamic, and it is optionally typed If you’ve enjoyed the benefits of other dynamic languages such as Smalltalk, Python, JavaScript, and Ruby, you can realize those in Groovy If you had looked at Groovy 1. 0 support for metaprogramming, it probably left you desiring for more Groovy has come a long way since 1. 0, and Groovy 1. 5 has pretty decent metaprogramming capabilities For instance,... Synthesis Using ExpandoMetaClass Synthesizing Methods for Specific Instances 202 203 208 212 214 219 222 15 MOPping Up 224 15 .1 Creating Dynamic Classes with Expando 224 15 .2 Method Delegation: Putting It All Together 227 15 .3 Review of MOP Techniques 2 31 16 Unit Testing and Mocking 16 .1 Code in This Book and Automated Unit Tests 16 .2... Appendix B, on page 296, gather together all the references to web articles and books cited throughout this book 1. 5 Who Is This Book For? This book is for developers working on the Java platform It is better suited for programmers (and testers) who understand the Java language fairly well Other developers who understand programming in other languages can use this book as well, but they should supplement... (Section 2 .1, Getting Groovy, on the preceding page) Installing Groovy on Windows If you have the one-click installer for Windows, run it, and follow the instructions If you downloaded the binary distribution package, unzip it Move the groovy- 1. 5.4 directory to a desired location .1 For instance, on my Windows system, I have it in the C:\programs \groovy directory The next step is to set the GROOVY_ HOME... advantage of dynamic capabilities and metaprogramming and being productive at the same time meant leaving behind the Java platform (After all, you use these features to be productive and can’t let them slow you down, right?) That is not the case anymore Languages such as Groovy and JRuby are dynamic and run on the JVM They allow you to take full advantage of both the rich Java platform and dynamic language... 240 2 41 244 248 249 2 51 253 254 17 Groovy Builders 17 .1 Building XML 17 .2 Building Swing 17 .3 Custom Builder Using Metaprogramming 17 .4 Using BuilderSupport 17 .5 Using FactoryBuilderSupport 260 260 264 265 268 272 18 Creating DSLs in Groovy 18 .1 Context 18 .2 Fluency 18 .3 Types . . . . 16 9 11 Working with Scripts and Classes 17 2 11 .1 The Melting Pot of Java and Groovy . . . . . . . . . . . 17 2 11 .2 Running Groovy . . . . . . . . . . . . . . . . . . . . . . . 17 3 11 .3 Using. Using Groovy Classes from Groovy . . . . . . . . . . . . 17 4 11 .4 Using Groovy Classes from Java . . . . . . . . . . . . . 17 5 11 .5 Using Java Classes from Groovy . . . . . . . . . . . . . 17 6 11 .6. Philosopher, 31 B.C. (Verse 426 from Thirukural, a collection of 13 30 noble couplets) Contents Foreword 14 1 Introduction 16 1. 1 Why Dynamic Languages? . . . . . . . . . . . . . . . . . 16 1. 2 What’s Groovy?

Ngày đăng: 12/08/2014, 23:22

TỪ KHÓA LIÊN QUAN