web 2.0 fundamentals : with ajax, development tools, and ... · pdf file8.6.2 google orkut 281...
TRANSCRIPT
WEB 2.0Fundamentalswith Ajax, Development Tools, and Mobile Platfori
Oswald Campesato
Kevin Nilson
JONES AND BARTLETT PUBLISHERS
Sudbury, Massachusetts
BOSTON TORONTO LONDON SINGAPORE
Contents
Acknowledgments XXI
Biographies of Book Contributors XXV
Preface XXXIII
Chapter 1 Introduction 1
1.1 Information About This Book 2
1.1.1 Why Should You Buy This Book? 2
1.1.2 Why Are There Two Social Networking Chapters? 2
1.1.3 Why Are There Three Cloud Computing Chapters? 3
1.1.4 Why Does This Book Use the DojoToolkit andjQuery?
1.1.5 Versions of Software and Tools in This Book 4
1.1.6 Appendices with Web 2.0 URLs 4
1.1.7 Web 2.0 Topics That are Omitted fromThis Book 4
1.1.8 The URLs in This Book 5
1.1.9 Is This Book Only for Developers? 6
1.1.10 Do You Discuss the Best Web 2.0 Tools? 6
1.2 Web 2.0 in Our Lives 7
1.3 What Is Web 2.0? 9
1.3.1 Pioneers in Web 2.0 9
1.3.2 The Shift from Web 1.0 toWeb 2.0 10
1.3.3 Is Web 2.0 Overrated? 11
1.3.4 Advantages/Disadvantages ofWeb 2.0 12
1.3.5 Early EnablingTechnologies ofWeb 2.0 12
1.4 Popular Web 2.0 Products andTools 15
1.4.1 Flickr 15
1.4.2 YouTube 16
VIII CONTENTS
1.4.3 Twitter 16
1.4.4 Yelp 18
1.4.5 Del.icio.us 18
1.4.6 SlideShare 18
1.5 The Current Web 2.0 Landscape 19
1.5.1 Ajax (Formerly Called AJAX) 19
1.5.2 ProductivityTools 21
1.5.3 Development Tools and IDEs 22
1.5.4 Social Networks 23
1.5.5 Mash-Ups 26
1.5.6 Cloud Computing 28
1.5.7 Semantic Technology 33
1.5.8 Advanced Project with GWT 35
1.5.9 Comet: "Reverse Ajax" 36
1.5.10 Mobile Applications 36
1.6 What AboutWeb 3.0? 37
1.7 Summary 38
Chapter 2 Landscape of the Web 39
2.1 Coding Guidelines 40
2.2 HTML/JavaScript Examples 41
2.2.1 JavaScript Strings and Arrays 42
2.2.2 Handling Mouse Events 44
2.2.3 Regular Expressions and String Manipulations2.2.4 HTML Frame Elements 48
2.2.5 HTML IFrame Elements 48
2.2.6 Design Patterns and Best Practices 50
2.3 Cascading Style Sheets (CSS) 50
2.3.1 Basic CSS Examples 51
2.3.2 Object-Oriented CSS (OOCSS) 54
2.4 HTML and Document Object Model (DOM) 55
2.4.1 HTML DOM andJavaScriptDOM 56
2.4.2 Managing Nodes and Elements 56
2.4-3 Dojo and jQuery Syntax 60
2.4.4 Distributed DOM 61
2.5 Browser Plug-Ins 61
2.5.1 SVG Plug-In 62
2.5.2 Silverlight Plug-In 65
2.5.3 Adobe Flash 66
2.6 Assorted JavaScript Technologies and Tools 69
2.6.1 Google Caja 69
CONTENTS IX
2.6.2 ECMAScript for XML (E4X) 69
2.6.3 RaphaelJavaScript Library 70
2.7 HTML5: Browser Support and Code Samples 71
2.7.1 The HTML5 Canvas Element 72
2.7.2 Google Chrome 75
2.8 Summary 76
Chapter 3 JSON and XML 79
3.1 Introducing the Concept ofJSONAnd XML 79
3.1.1 XPath, XQuery, XSlt, and XML Documents 83
3.2 Working with JSON 86
3.3 AjaxTool Kits Working with JSON 88
3.3.1 Dojo and JSON 89
3.3.2 jQuery and JSON 90
3.3.3 Working with XML 90
3.3.4 Understanding Simple API for SML (SAX) 102
3.4 Advantages and Disadvantages ofJSON and XML 116
3.4.1 Advantages and Disadvantages ofJSON 116
3.4.2 Advantages and Disadvantages of XML 117
3.5 HTML and SGML versus XML 119
3.6 YAML and Comma SeparatedValues (CSV) as Alternatives to JSON and XML 120
3.6.1 YAML 120
3.6.2 CSV 121
3.7 Advanced Example with Dojo and JSON 121
3.8 Summary 125
Chapter 4 Ajax 127
4.1 Introducing the Concept ofAjax 127
4.2 A Brief History ofAjax 129
4.2.1 IFrames 130
4.3 XMLHttpRequest (XHr) 134
4.4 Ajax via Ajax Libraries 136
4.4.1 Ajax via Dojo 136
4.4.2 Ajax via jQuery 137
4.5 Ajax Working withJSON Using Dojo 138
4.5.1 AjaxWorking with JSON injQuery 139
4.6 Limitations ofAjax 140
4.7 Adoption ofAjax 141
4.7.1 Disadvantages ofAjax 142
4.7.2 Advantages ofAjax 142
4.8 Comparison of Existing Ajax Libraries 143
X CONTENTS
4.8.1 Dojo 143
4.8.2 ExtJS 143
4.8.3 GWT 143
4.8.4 jQuery 143
4.8.5 Prototype Script.aculo.us 144
4.8.6 SmartClient 144
4.8.7 SproutCore 144 •
4.8.8 Tibco GI 144
4.8.9 YUI 144
4.8.10 Understanding theTerms 144
4.9 Comprehensive Ajax Project 144
4.10 Advanced Ajax 157
4.11 Summary 158
Chapter 5 Productivity and Testing Tools 159
5.1 Which Tools Are Best? 160
5.2 Google Wave 162
5.2.1 Google Wave Features 163
5.3 Yahoo Pipes 164
5.3.1 A SimpleYahoo Pipe 165
5.3.2 UsingYQL inYahoo Pipes 166
5.4 Dapper 168
5.4.1 Creating a Simple Dapp 169
5.5 Assorted Open Source Tools from Google 169
5.5.1 Google Gears 170
5.5.2 Google Native Client 170
5.5.3 Google 03D 172
5.5.4 Google Ajax, Playground, and Sandbox
5.5.5 Google Innovation 173
5.6 Miscellaneous ProductivityTools 174
5.7 Twitter 176
5.7.1 InvokingTwitter APIs 177
5.8 The MIT Simile Project 179
5.9 Web 2.0 Applications and Product Suites 181
5.9.1 Google Apps 182
5.9.2 Zoho 183
5.10 BuildAutomation and TestingTools 184
5.10.1 Apache Ant 185
5.10.2 A Simple build.xml File 185
5.10.3 Maven 188
5.10.4 Other BuildTools 189
CONTENTS XI
5.10.5 JUnit 190
5.10.6 OtherTesting Tools 191
5.11 BenchmarkingTools 191
5.11.1 Faban 192
5.12 Source Code Management Tools 192
5.12.1 How to Use Mercurial 194
5.12.2 Web Containers and Servers 196
5.13 Using DTrace for Web 2.0 Applications 197
5.13.1 DTrace Fundamentals 198
5.14 Industry Perspective and Business Focus 201
5.14.1 HowWillYahoo Pipes Evolve During the Next SeveralYears? 203
5.15 Summary 205
Chapter 6 Debugging Tools 207
6.1 Introducing the Concept ofDebugging 207
6.2 Integrated Development Environments (IDES) 208
6.2.1 Eclipse 209
6.2.2 Adobe Flash Builder 4 210
6.2.3 SUNNetBeans 211
6.2.4 Oracle JDeveloper 211
6.2.5 InteUiJIDEA 211
6.2.6 Aptana Studio 212
6.3 Rich Internet Applications (RJA) 212
6.3.1 Adobe AIR 212
6.3.2 SUNJavaFX 212
6.4 Firebug 215
6.4.1 Inspect and Edit HTML and CSS 215
6.4.2 Monitor Network Activity 217
6.4.3 Debug and Profile JavaScript 218
6.4.4 Find Errors 219
6.4.5 Exploring the DOM 220
6.4.6 Execute JavaScript on the Fly 220
6.4.7 Log from JavaScript 221
6.5 Firebug Lite 221
6.6 Venhnan 222
6.7 Firefox Web Developer Add-On 222
6.8 JSLint 225
6.9 JsUnit 225
6.10 Selenium 226
6.11 Wireshark 226
6.12 Google Gadgets 227
XII CONTENTS
6.13 Summary 232
Chapter 7 The Facebook Platform 233
7.1 Social Networking 234
7.2 Facebook 235
7.2.1 Facebook Features and Services 236
7.2.2 Facebook Applications 238
7.2.3 Facebook Core Components 242
7.2.4 Facebook Integration with Other Products 246
7.3 SUNZembly 260
7.3.1 Zembly Features 261
7.3.2 Zembly Applications andTools 261
7.3.3 ZemblyWeb Gateway API 262
7.4 Bebo 265
7.5 Identity Management forWeb 2.0 Applications 266
7.5.1 Key Technologies 266
7.5.2 Conclusions 269
7.6 Summary 269
8.1 The OpenSocial Landscape 272
8.2 OpenSocial Markup Language (OSML) 273
8.2.1 OpenSocial Tags 273
8.2.2 OpenSocial Templates 274
8.3 OpenSocial Gadgets 275
8.3.1 Creating and Submitting OpenSocial Gadgets 276
8.3.2 Google Gadgets and OtherTools 277
8.4 The OpenSocial Technology Stack 277
8.5 OpenSocial Applications in Eclipse 278
8.5.1 A Basic OSDE Application 279
8.6 OpenSocial and MajorVendors 279
8.6.1 Yahoo Application Platform (YAP) and OpenSocial 280
8.6.2 Google Orkut 281
8.7 Google Friend Connect (GFC) 281
8.7.1 GFC APIs 282
8.7.2 GFC Gadgets 283
8.8 Apache Shindig 285
8.8.1 Building Apache Shindig 285
8.8.2 OpenSocial Java Client 289
8.8.3 Display Friends in Shindig 289
8.8.4 Compiling the Sample Shindig Code 293
8.9 Integrated OpenSocial Sample Application 294
Chapter 8 The OpenSocial Platform 271
CONTENTS XIII
8.9.1 Working with OpenSocial: Our Findings 301
8.10 Summary 304
Chapter 9 Mash-Ups and Search Technology 305
9.1 Mash-Ups 306
9.1.1 Consumer and Enterprise Mash-Ups 308
9.1.2 Design Patters and Best Practices 310
9.2 Mash-Up Tools and Products 311
9.2.1 IBM Mash-Up Center 311
9.2.2 WS02 312
9.2.3 Intel Mash Maker 314
9.2.4 Denodo Technologies 315
9.2.5 JackBe 316
9.2.6 Yahoo BOSS Mash-Up Framework 319
9.2.7 Consumer Mash-Ups and Online Tools 320
9.3 Search Technology 323
9.3.1 Google Search Tools 324
9.3.2 Yahoo Search Tools 327
9.3.3 Open Source SearchTools 328
9.4 Search-Related Engines 333
9.4.1 Microsoft Bing 333
9.4.2 Google Caffeine 335
9.4.3 Hakia 336
9.4.4 Kosmix 337
9.4.5 Yebol 337
9.5 Industry Perspective and Business Focus 338
9.5.1 Background 338
9.5.2 Mash-Ups,Web 2.0, and Beyond 339
9.5.3 Products and Resources 341
9.5.4 Implementation 343
9.5.5 Conclusions 344
9.6 Summary 345
Chapter 10 Cloud Computing Part I 347
10.1 What Is Cloud Computing? 348
10.1.1 Public, Private, and Hybrid Clouds 350
10.1.2 Questions to Ask Cloud Computing Vendors 352
10.1.3 The Software Platform Infrastructure (SPI) 353
10.2 Amazon Web Services (AWS) 356
10.2.1 Amazon EC2 357
10.2.2 Amazon S3 358
10.2.3 Amazon SimpleDB 359
XIV CONTENTS
10.2.4 Amazon CloudFront 361
10.2.5 Amazon SQS 362
10.2.6 AlexaWeb Information Service (AWIS) 362
10.2.7 Amazon Elastic Map Reduce 363
10.2.8 Creating Amazon EC2 Applications 364
10.3 IBM Cloud Labs 365
10.3.1 IBM and Amazon Partnership 366
10.4 Google App Engine (GAE) 366
10.4.1 Assessing GAE forYour Company 367
10.4.2 Upcoming GAE Features and Pricing Structure 368
10.4.3 Google Bigtable 368
10.4.4 Installing the GAE SDK for Python 370
10.4.5 A "Hello, World" Example in Python 370
10.4.6 Uploading Applications to GAE 371
10.4.7 "Fusion Tables" Database 371
10.5 Windows Azure 372
10.5.1 Windows Azure Features and .NET Services 373
10.5.2 SQL Azure 374
10.5.3 Windows Azure Development 376
10.6 Yahoo Cloud Computing 377
10.6.1 Yahoo MObStor 377
10.6.2 Yahoo Sherpa 378
10.7 Other Cloud Computing Initiatives 378
10.8 Industry Perspective 379
10.8.1 Economy of the Cloud and How to Get Started 379
10.9 Summary 384
Chapter 11 Cloud Computing Part II 385
11.1 Midsize Cloud Computing Vendors 386
11.1.1 Appistry 386
11.1.2 Engine Yard 387
11.1.3 GoGrid 388
11.1.4 Joyent 389
11.1.5 Longjump 389
11.1.6 Rackspace 390
11.1.7 RightScale 390
11.1.8 GridGain 392
11.1.9 iCloud 392
11.2 Cloud Computing Integrated Applications 393
11.2.1 NetSuite 393
11.2.2 SalesForce 394
CONTENTS XV
11.3 Cloud Computing and Open Source 395
11.3.1 Apache Open Source Projects 395
11.3.2 Sector/Sphere 399
11.3.3 UCB Elastic Utility Computing Architecture for Linking Your Programs to
Useful Systems (EUCALYPTUS) 400
11.3.4 Cloud Computing in the Scientific Community 400
11.3.5 Other Cloud Computing Initiatives 401
11.3.6 Cloud Computing and Databases 402
11.3.7 Cloud Computing Editors and IDEs 407
11.3.8 Ubuntu and Cloud Computing 409
11.3.9 Cloud Organizations and Cloud Manifesto 410
11.3.10 MonitoringTools 411
11.4 Alternatives to Cloud Computing 412
11.4.1 Oracle Coherence 412
11.4.2 Terracotta 416
11.4.3 Virtualization Software 419
11.5 Business Focus 420
11.5.1 What are the major benefits of cloud computing? 420
11.5.2 What are the major downsides ofcloud computing? 421
11.5.3 Which companies/verticals benefit the most from cloud computing? 421
11.5.4 What are the major use cases for cloud computing? 421
11.5.5 What is the state of the adoption of cloud computing today? 422
11.5.6 What are the issues that prevent widespread adoption of cloud computing? 422
11.5.7 What are the technical challenges in developing/deploying apps in the
cloud? 422
11.5.8 How will cloud computing evolve in the next few years? 423
11.5.9 How would you compare virtualization and cloud computing? 423
11.5.10 What will beVMware's strategy on cloud computing in the next few
years? 423
11.6 Summary 424
Chapter 12 XMLJava, and GAE 425
12.1 Java-XML BindingTools 426
12.1.1 JAXB:Java-XML Bindings 427
12.1.2 Castor:Java-XML Binding Support 431
12.1.3 OtherJava-XML Binding Tools 433
12.2 Java and Google App Engine (GAE) 433
12.2.1 Language and Framework Support 435
12.2.2 JavaApplications for GAE in Eclipse 438
12.2.3 The Structure of GAE Java Applications 441
12.2.4 Creating a GoogleWave Robot in Eclipse 442
XVI CONTENTS
12.2.5 Starting the GAE Server 443
12.3 Java and GAE Code Samples 444
12.3.1 AJSP Example 444
12.3.2 A Java Servlet Example 446
12.3.3 Google Wave, GAE, and Twitter 448
12.3.4 Create an Eclipse Project 449
12.3.5 GAEJDO 449
12.3.6 GAEJPA 456
12.4 Java/GAE Clouds and Alternatives 459
12.4.1 Stax 459
12.4.2 GigaSpaces 462
12.4.3 jClouds 463
AJava AppEngine Integrated Example 463
Summary 475
12.5
12.6
Chapter 13 Semantic Technology 477
13.1 The Semantic Web and Semantic Technology 478
13.1.1 The Semantic Technology Landscape 479
13.1.2 Taxonomies, Ontologies, and Folksonomies 481
13.1.3 RDF, RDFS, OWL, DARPAAgent Markup Language (DAML), and
SPARQL 483
13.1.4 Semantic Technology Tools 496
13.2 OpenCalais 502
13.2.1 The CalaisViewer 503
13.2.2 A Simple OpenCalais Example 504
13.2.3 OpenCalais Code Samples 506
13.2.4 OpenCalaisTools 508
13.3 Expert System 509
13.4 Truevert 510
13.5 Semantic Technology from Commercial Vendors 510
13.5.1 Oracle Semantic Technology 510
13.5.2 IBM Semantic Technology 511
13.5.3 Microsoft SemanticTechnology 512
13.5.4 Altova Semantic Technology 512
13.5.5 Franz Semantic Technologies 513
13.5.6 TopBraid 514
13.6 Other Projects,Tools, and Products 515
13.6.1 Open Source RDF-based Projects 515
13.7 Comments AboutWeb 3.0 516
13.8 Industry Perspective 518
13.8.1 What is your"definition" ofWeb 2.0? Web 3.0? 518
13.8.2 How will Semantic Technology evolve during the next several
years? 519
CONTENTS XVM
13.8.3 How will OpenCalais influence Semantic Technology? 519
13.8.4 What are the important differences (and similarities) between
OpenCalais and other Semantic Technology products? 520
13.8.5 Where are the opportunities for creating successful Semantic Technology-
applications? 520
13.8.6 What advice do you have for developers who want to create successful Semantic
Technology applications? What technical and nontechnical skills do they need
to acquire? 520
13.8.7 What advice do you have for people who want to create start-ups? 521
13.9 Summary 521
Chapter 14 Web 2.0 Comprehensive Project 523
14.1 Chapter Overview 523
14.1.1 Project Overview 523
14.2 Google Web Toolkit (GWT) 525
14.3 Meetup Networking Code 526
14.4 JFXTRASJAVAFX Raffle Tool Background 548
14.5 JFXTRASJAVAFX Raffle Tool Code 548
14.5.1 Building the JUG Spinner UI 550
14.5.2 CallingWeb Services from JavaFX 555
14.6 Summary 558
Comet 559
Introducing the Concept ofComet 559
15.1.1 Polling 560
15.1.2 Long Polling 565
15.1.3 Streaming 569
15.1.4 Server-SideThreading Concerns 570
CometD 570
15.2.1 CometD andJavaScript 571
15.2.2 Publish and Subscribe fromJavaScript 571
15.2.3 Publish and Subscribe fromJava 572
15.2.4 HTTPServletRequest 573
15.2.5 Security Policy 574
15.2.6 Channel, Queue, and Client Listeners 574
15.2.7 Conclusion 576
Orbited 576
15.3.1 Integration 577
15.3.2 Architecture 577
15.3.3 Details 577
15.3.4 Orbited Is Not a Message Queue 578
15.3.5 Goals and Strengths of the Orbited Project 579
XVIII CONTENTS
15.4 Industry Perspective of Comet by Michael Carter 580
15.5 Summary 583
Chapter 16 Mobile Development Part 1 585
16.1 The Mobile Landscape 587
16.1.1 Initial Costs for Mobile-Based Development 587
16.1.2 Web Technologies for Mobile Devices 588
16.1.3 Design Patterns and Best Practices 591
16.2 Apple iPhone 592
16.2.1 Quick Platform Overview 593
16.2.2 Overview ofiPhone Applications 594
16.2.3 iPhone Applications for Mobile Devices 597
16.2.4 iPhone Web Applications 601
16.2.5 Apple iPhone and Third-Party Tools 601
16.3 Google Android 603
16.3.1 Quick Platform Overview 603
16.3.2 Overview ofAndroid Applications 604
16.3.3 A Simple AndroidApplication 606
16.3.4 Google Android Tool Integration 612
16.4 Palm 613
16.4.1 Quick Overview of WebOS and Mojo 614
16.4.2 Overview of Palm Applications 614
16.4.3 A Simple Palm Pre Application 615
16.5 Industry Perspective 619
16.6 Summary 620
Chapter 17 Mobile Development Part 2 621
17.1 Samsung 622
17.1.1 Quick Platform Overview 623
17.2 J2ME 625
17.2.1 Quick Platform Overview 625
17.2.2 A Simple J2ME Application 626
17.3 RIM Blackberry 629
17.3.1 Quick Platform Overview 629
17.3.2 A Simple Blackberry Application 629
17.4 Nokia 631
17.4.1 Nokia Mobile Applications 631
17.5 JavaFX 1.2 for Mobile Applications 633
17.5.1 A Simple JavaFX Mobile Application 633
17.6 MonoTouch 638
17.6.1 MonoTouch Features 638
17.6.2 A Simple MonoTouch Application 639
CONTENTS XIX
17.7 Motorola 641
17.7.1 Overview of Motorola Mobile Applications 641
17.7.2 A Motorola Mobile Application 642
17.7.3 Motorola and J2ME 644
17.7.4 Motorola and Android 645
17.8 Verizon Joint Innovation Lab (JIL) Mobile 648
17.8.1 Verizon Mobile Applications in Eclipse 648
17.9 Other Development Tools for Mobile Devices 649
17.9.1 Appcelerator 649
17.9.2 Cross-Platform DevelopmentTools 652
17.10 Companies for Mobile Development 653
17.11 Mobile Trends in Other Technologies 654
17.12 Summary 655
Chapter 18 Epilogue: The Future of the Web 657
18.1 Current MajorTrends 657
18.1.1 Mobile Technology 658
18.1.2 HTML5 659
18.1.3 The Real-TimeWeb 659
18.1.4 Semantic Technology 659
18.2 Start-Up Innovators 660
18.3 Vincent Lauria 660
18.3.1 Can you tell us about your background? 660
18.3.2 What project(s) are you currently working on? 660
18.3.3 How did you adjust your business as a result? 661
18.3.4 What significant changes do you think will happen in the Web in the
next few years, and what will be the effect on start-ups? 661
18.3.5 How will this change in the near future? 662
18.3.6 What key factors should be considered when engaging in a new start-up? 662
18.3.7 What hard lessons have you learned that you wish you knew earlier? 663
18.3.8 What are the primary factors for start-up success? 663
18.4 Future Trends for the Web 663
18.4.1 Andres Almiray 665
18.4.2 SiamakAshrafi 667
18.4.3 Stephen Chin 669
18.4.4 Aleksandar Gargenta 671
18.4.5 TedGoddard 672
18.4.6 ChettHaase 676
18.4.7 Yehuda Katz 677
18.4.8 Van Riper 678
18.4.9 AlexRussel 680
18.4.10 Dylan Schiemann 682
XX CONTENTS
18.4.11 GregWilkins 685
18.4.12 Monica Anderson 687
18.5 Final Thoughts 689
18.5.1 Web-Based Technology and Society 689
18.5.2 Everyone Is Connected 689
18.5.3 TransitiveTrust 690
18.5.4 Perfect Information for Everyone 691
18.5.5 Intelligent Agents 691
18.5.6 Web 3.0 and Beyond 692
18.6 Summary 693
Trademark Acknowledgments 695
GNU License 705
Lesser GNU License 708
Index 709