Typical enterprises use dozens, hundreds, and sometimes even thousands of applications, components, services, and databases. Many of them are custom built in-house or by third parties, some are bought, others are based on open source projects, and the origin of a few—usually the most critical ones—is completely unknown. A lot of applications are very old, some are fairly new, and seemingly no two of them were written using the same tools. They run on heterogeneous operating systems and hardware, use databases and messaging systems from various vendors, and were written in different programming languages. See how to glue these disparate applications together using popular technologies such as: LDAP, Oracle, and MySQL XML Documents and DTDs Sockets, HTTP, and REST XML/RPC, SOAP, and others ...and more. If you're on the hook to integrate enterprise-class systems together, the tips and techniques in this book will help. Following this book's tips and techniques, readers learn how to glue disparate enterprise-class systems together using Enterprise Integration. Enterprise Integration with Ruby......Page 1 Contents......Page 6 Foreword......Page 8 1 Introduction......Page 9 1.1 What Is Enterprise Software?......Page 10 1.3 Why Ruby?......Page 11 1.5 PragBouquet......Page 13 1.6 Acknowledgments......Page 14 2 Databases......Page 16 2.1 The Coupon Application......Page 17 Exploring the Environment......Page 18 Determine the Winners......Page 19 Enhancing Flexibility......Page 23 Respecting Customer Privacy......Page 25 Joining Forces......Page 27 The Fruits of Our Labor......Page 31 2.2 Database Interface (DBI)......Page 33 2.3 Object-Relational Mappers......Page 36 ActiveRecord Basics......Page 41 What Do We Have in Stock?......Page 49 Validation......Page 54 Migrating Database Schemas......Page 55 Conclusion......Page 58 2.4 Lightweight Directory Access Protocol (LDAP)......Page 59 An Address Book for PragBouquet Customers......Page 63 Ruby/LDAP......Page 69 ActiveLDAP......Page 78 3 Processing XML......Page 87 3.1 A Short XML Reminder......Page 89 Should I Use Elements or Attributes?......Page 90 To Score Well......Page 91 Generating XML Documents Using Raw Strings......Page 92 Generating XML Documents with REXML......Page 97 Builder......Page 99 3.3 Processing XML Documents......Page 103 XML Processing with REXML......Page 104 Tree Parsing......Page 105 REXML Stream Parsing......Page 110 But It’s Not Standard......Page 117 XPath......Page 123 XML Processing with XmlSimple......Page 132 3.4 Validating XML Documents......Page 135 xmllint......Page 138 Conclusion......Page 139 3.5 Are There Alternatives to XML?......Page 140 Comma-Separated Values (CSV)......Page 141 Processing Comma-Separated Values......Page 142 Properties Files......Page 144 Fixed-Length Records......Page 145 YAML Ain’t Markup Language (YAML)......Page 147 4 Low-Ceremony Distributed Applications......Page 153 4.1 “I’d Rather Use a Socket”......Page 154 The PragBouquet Status Monitor......Page 155 Status Monitor Clients......Page 158 Adding Better Persistence......Page 163 Sending E-mails......Page 164 Waking Up the Operator......Page 167 The Other Side of HTTP......Page 174 Some WEBrick Details......Page 176 It Can Always Be Easier......Page 179 WEBricklet......Page 181 Hiding Little Secrets......Page 183 5.1 Another Day, Another Protocol......Page 187 XML-RPC in Less Than Eight Minutes......Page 189 xmlrpc4r......Page 193 5.2 We Will Take No REST, Will We?......Page 197 Refactoring the Stock Class API......Page 208 A Look Under the Hood of SOAP......Page 210 SOAP the Hard Way......Page 213 Web Services Description Language......Page 216 SOAP Headers......Page 221 Conclusion......Page 228 5.4 CORBA, RMI, and Friends......Page 229 The SMS Server Again......Page 230 The CORBA Client......Page 234 Bridging the Gap......Page 236 CORBA Is Coming Home.........Page 241 C++ CORBA Services......Page 242 Distributed Ruby (dRuby)......Page 243 6.1 Internationalization and Localization......Page 248 Character Sets and Encodings......Page 249 jcode......Page 254 ICU4R......Page 256 International I/O......Page 259 Date and Time Formats......Page 261 Managing Message Text......Page 263 Conclusion......Page 268 Logging with Logger......Page 269 Logging to Files......Page 270 The Log Line Format......Page 271 Logging with Log4r......Page 272 Loggers......Page 274 Formatters......Page 276 Outputters......Page 279 Configuration......Page 280 Performance Considerations......Page 286 6.3 Creating Daemons and Services......Page 287 Unix Daemons......Page 288 Windows Services......Page 289 6.4 Build and Deployment Process......Page 294 Deploying with setup.rb......Page 295 Underprivileged?......Page 299 Shipping the Status Monitor......Page 302 RubyGems......Page 307 6.5 Project Automation with Rake......Page 311 Rakefiles......Page 312 Tasks and Actions......Page 315 File Lists......Page 321 6.6 Testing Legacy Applications......Page 322 Conclusion......Page 328 A Resources......Page 329 Index......Page 330 Enterprise Integration with Ruby 1 Contents 6 Foreword 8 1 Introduction 9 1.1 What Is Enterprise Software? 10 1.2 What Is Enterprise Integration? 11 1.3 Why Ruby? 11 1.4 Who Should Read This Book? 13 1.5 PragBouquet 13 1.6 Acknowledgments 14 2 Databases 16 2.1 The Coupon Application 17 Exploring the Environment 18 Determine the Winners 19 Enhancing Flexibility 23 Respecting Customer Privacy 25 Joining Forces 27 The Fruits of Our Labor 31 2.2 Database Interface (DBI) 33 2.3 Object-Relational Mappers 36 ActiveRecord Basics 41 What Do We Have in Stock? 49 Validation 54 Migrating Database Schemas 55 Conclusion 58 2.4 Lightweight Directory Access Protocol (LDAP) 59 An Address Book for PragBouquet Customers 63 Ruby/LDAP 69 ActiveLDAP 78 3 Processing XML 87 3.1 A Short XML Reminder 89 Should I Use Elements or Attributes? 90 3.2 Generating XML Documents 91 To Score Well 91 Generating XML Documents Using Raw Strings 92 Generating XML Documents with REXML 97 Builder 99 3.3 Processing XML Documents 103 XML Processing with REXML 104 Tree Parsing 105 REXML Stream Parsing 110 But It’s Not Standard 117 XPath 123 XML Processing with XmlSimple 132 3.4 Validating XML Documents 135 xmllint 138 Conclusion 139 3.5 Are There Alternatives to XML? 140 Comma-Separated Values (CSV) 141 Generating Comma-Separated Values 142 Processing Comma-Separated Values 142 Properties Files 144 Fixed-Length Records 145 YAML Ain’t Markup Language (YAML) 147 4 Low-Ceremony Distributed Applications 153 4.1 “I’d Rather Use a Socket” 154 The PragBouquet Status Monitor 155 Status Monitor Clients 158 Adding Better Persistence 163 Sending E-mails 164 4.2 Remote Procedure Calls Using HTTP 167 Waking Up the Operator 167 The Other Side of HTTP 174 Some WEBrick Details 176 It Can Always Be Easier 179 WEBricklet 181 Hiding Little Secrets 183 5 Distributed Applications with RPC 187 5.1 Another Day, Another Protocol 187 XML-RPC in Less Than Eight Minutes 189 xmlrpc4r 193 5.2 We Will Take No REST, Will We? 197 5.3 SOAP 208 Refactoring the Stock Class API 208 A Look Under the Hood of SOAP 210 SOAP the Hard Way 213 Web Services Description Language 216 SOAP Headers 221 Conclusion 228 5.4 CORBA, RMI, and Friends 229 The SMS Server Again 230 The CORBA Client 234 Bridging the Gap 236 CORBA Is Coming Home... 241 C++ CORBA Services 242 Distributed Ruby (dRuby) 243 6 Tools and Techniques 248 6.1 Internationalization and Localization 248 Character Sets and Encodings 249 jcode 254 Unicode 256 ICU4R 256 International I/O 259 Date and Time Formats 261 Managing Message Text 263 Conclusion 268 6.2 Logging 269 Logging with Logger 269 Log Levels 270 Logging to Files 270 The Log Line Format 271 Logging with Log4r 272 Loggers 274 Formatters 276 Outputters 279 Configuration 280 Performance Considerations 286 6.3 Creating Daemons and Services 287 Unix Daemons 288 Windows Services 289 6.4 Build and Deployment Process 294 Deploying with setup.rb 295 Underprivileged? 299 Shipping the Status Monitor 302 RubyGems 307 6.5 Project Automation with Rake 311 Rakefiles 312 Tasks and Actions 315 File Lists 321 Conclusion 322 6.6 Testing Legacy Applications 322 Conclusion 328 A Resources 329 Index 330 Typical enterprises use dozens, hundreds, and sometimes even thousands of applications, components, services, and databases. This book teaches you how to glue disparate enterprise-class systems together using Enterprise Integration techniques. Enterprise Integration with Ruby - выпущенная Pragmatic Programmers книга об интеграционных решения на языке Ruby в масштабе предприятий На infanata не видел ни одной книги по Ruby - решил начать традицию