Introducing Play Framework (eBook)
XVI, 192 Seiten
Apress (Verlag)
978-1-4842-5645-9 (ISBN)
Enter the world of rapid web application development. This gentle introduction to Play covers all you need to know: it carefully introduces the background concepts before diving into examples, making learning Play 2 enjoyable (it includes the latest Play framework version 2.8).
Introducing Play Framework is crisp, up-to-the-point, and full of valuable information. You will find chapters covering the basics of Play, the sbt build system, the Ebean ORM, web services using Play, production deployment, cache, and more with actual pragmatic code snippets for common tasks.
After reading and using this book, you'll be able to build and deploy Java-based web applications with the Play framework.
What You Will Learn
- Use the Play framework to do rapid Java-based web application development
- Work with Play controllers and Play views
- Create web services using JSON and XML
- Persist data and access databases
- Use Play modules Carry out asynch programming
- Cache, deploy, and work with code snippets in Play
Who This Book Is For
Those with at least some prior experience with Java.
Enter the world of rapid web application development. This gentle introduction to Play covers all you need to know: it carefully introduces the background concepts before diving into examples, making learning Play 2 enjoyable (it includes the latest Play framework version 2.8).Introducing Play Framework is crisp, up-to-the-point, and full of valuable information. You will find chapters covering the basics of Play, the sbt build system, the Ebean ORM, web services using Play, production deployment, cache, and more with actual pragmatic code snippets for common tasks.After reading and using this book, you'll be able to build and deploy Java-based web applications with the Play framework. What You Will Learn Use the Play framework to do rapid Java-based web application development Work with Play controllers and Play views Create web services using JSON and XML Persist data and access databases Use Play modules Carry out asynch programming Cache, deploy, and work with code snippets in Play Who This Book Is ForThose with at least some prior experience with Java.
Table of Contents 5
About the Author 10
About the Technical Reviewer 11
Preface 12
Chapter 1: Getting Started with Play 2 14
Getting Ready 14
Installation 14
Prerequisites 15
Installing sbt 15
Installing conscript 15
Installing Giter8 16
Setting Up Play 17
Using Play Example Projects 17
Using sbt 19
Installing a Java Project Using sbt 20
Installing a Scala Project Using sbt 20
Creating Your First Project 21
app 22
conf 23
build.sbt 24
project 24
public 24
lib 24
test 25
Configuring Play to Work with Your Preferred IDE 25
Setting Up in Eclipse 25
Setting Up in IntelliJ 28
Hello World Application 30
Configuration 32
Controller and View 35
View 37
Controller 37
Enhancing the View 39
Testing Play Applications 40
Testing Views 41
Testing Controllers 42
Chapter 2: Build System 45
Scala Build Tool/Simple Build Tool 45
Core Principles 45
Benefits of sbt 46
Project Structure 47
Using sbt 48
Setting Definition 51
Resolvers 54
Complete build.sbt 54
Complete plugins.sbt 55
Quick Recap of SBT Commands 55
Chapter 3: Play Controllers and HTTP Routing 57
MVC Programming Model 57
Model 58
View 60
Controller 60
HTTP Routing 60
Static Definition 62
Dynamic Parts in a URL 62
Passing Fixed Values 64
Optional Parameters 65
Application Configuration Using application.conf 65
Controllers 66
Finishing the Bookshop Controller 68
saveComment Method 70
Testing the saveComment Action 71
Models 72
Scoped Objects 73
Session Scope 74
Flash Scope 76
Chapter 4: Play Views and Templating with Scala 77
Composite Views 78
Designing a General Template 80
Code Snippets Templating Basics 81
Comments 82
Template Parameters 82
Import Statement 83
Iterating a List 84
Iterating a Map 84
If Blocks 85
Escaping Dynamic Contents 86
Chapter 5: Concurrency and Asynchronous Programming 87
What Is Concurrency? 88
Executor 88
Example 1: Using Runnable 90
Example 2: Using Callable 92
Asynchronous Programming with Play 94
Writing an Asynchronous App 95
Configuring Asynchronous Scheduled Jobs 96
Akka Basics 96
Chapter 6: Web Services, JSON, and XML 99
Consuming Web Services 100
Processing Large Responses 103
Handling JSON 106
Consuming JSON Request 106
Producing a JSON Response 109
Handling XML 110
Example 1: Simple XML Parsing 111
Example 2: XML Parsing Using JAXB 112
Chapter 7: Accessing Databases 117
Configuring Database Support 117
Working with an ORM 121
ORM Concepts 121
Key Terms 123
One to Many 123
Many to One 123
Many to Many 123
Relationship Direction 123
Configuring JPA 125
Using Ebean in Play 130
Ebean Query 132
Common Select Query Constructs in Ebean 137
where() 137
eq() 137
like() 137
orderBy() 137
findUnique() 138
findList() 138
LIMIT {max rows} [ OFFSET {first row} ] 138
The Query Interface 138
Using RawSql 140
Relationships in Ebean 142
Chapter 8: Complete Example 144
Chapter 9: Using Play Modules 168
Creating a Module 169
Third-Party Modules 172
Chapter 10: Application Settings and Error Handling 173
Filters 174
Action Composition 178
Error Handlers 180
Client Errors 180
Server Errors 180
How Global Settings Were Done Before Play 2.6.x 182
Chapter 11: Working with Cache 185
Configuring Caffeine 185
Adding Caffeine to a Project 186
Configuring EhCache 187
Using the Cache API 187
Chapter 12: Production Deployment 192
Configuring Apache httpd for Play 193
Load Balancing Using mod_proxy_balancer 193
Configuring Play with Nginx 194
Index 196
Erscheint lt. Verlag | 6.3.2020 |
---|---|
Zusatzinfo | XVI, 192 p. 16 illus. |
Sprache | englisch |
Themenwelt | Mathematik / Informatik ► Informatik ► Programmiersprachen / -werkzeuge |
Mathematik / Informatik ► Informatik ► Web / Internet | |
Schlagworte | Akka • Code • Development • Framework • Java • MVC • Play • Play 2 • Play Framework 2 • programming • Scala • Software • source • Web • Web Development |
ISBN-10 | 1-4842-5645-X / 148425645X |
ISBN-13 | 978-1-4842-5645-9 / 9781484256459 |
Haben Sie eine Frage zum Produkt? |
Größe: 2,6 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich