Home Page Icon
Home Page
Table of Contents for
Index
Close
Index
by Thomas Alexandre
Scala for Java Developers
Scala for Java Developers
Table of Contents
Scala for Java Developers
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Programming Interactively within Your Project
Advantages of using Scala for Java projects
More concise and expressive
Increased productivity
Natural evolution from Java
Better fit for asynchronous and concurrent code
Learning Scala through the REPL
Declaring val/var variables
Defining classes
Explaining case classes
Operations on collections
Transforming collections containing primitive types
Collections of more complex objects
Filter and partition
Dealing with tuples
Introducing Map
Introducing the Option construct
A glimpse at pattern matching
The map method
Looking at String Interpolation
The groupBy method
The foldLeft method
Summary
2. Code Integration
Creating a REST API from an existing database
The sample database
Setting up a Maven project
Creating JPA entities and REST web services
Running and testing the project
Adding a unit test in Java
Adding a test in Scala
Setting up Scala within a Java Maven project
Scala and Java collaboration
Converting between collection types
JavaBean-style properties
Scala and Java object orientation
Scala traits as enhanced Java interfaces
Declaring objects
Introducing companion objects
Handling exceptions
Differences in style between Java and Scala code
Adjusting the code layout
Naming conventions
Summary
3. Understanding the Scala Ecosystem
Inheriting Java Integrated Development Environments (IDEs)
Building with Simple Build Tool (SBT)
Getting started with SBT
Creating a sample project
Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
Creating a web application that runs on a servlet container
Using sbt-assembly to build a single .jar archive
Formatting code with Scalariform
Experimenting with Scala Worksheets
Working with HTTP
Scala's for comprehension
Taking advantage of Typesafe Activator
Creating an application based on activator templates
The REPL as a scripting engine
Summary
4. Testing Tools
Writing tests with ScalaTest
BDD-style testing
Functional testing
Mocking with ScalaMock
Testing with ScalaCheck
Summary
5. Getting Started with the Play Framework
Getting started with the classic Play distribution
Getting started with the Typesafe Activator
Architecture of a Play application
Visualizing the framework stack
Exploring the request-response lifecycle
Handling a request in the controller
Rendering the view
Playing with authentication
Practical tips when using Play
Debugging with Play
Dealing with version control
Summary
6. Database Access and the Future of ORM
Integrating an existing ORM – Hibernate and JPA
Making JPA available in Scala
Dealing with persistence in the Play Framework
A simple example using Anorm
Replacing ORM
Learning about Slick
Scaffolding a Play application
Importing test data
Visualizing the database in the H2browser
Exploring the code behind the app generation
Limitations of the playcrud utility
Summary
7. Working with Integration and Web Services
Binding XML data in Scala
Running scalaxb from a SOAP web service
Working with XML and JSON
Manipulating XML
Manipulating JSON
Using Play JSON
Handling Play requests with XML and JSON
Mocking Play responses with JSON
Calling web services from Play
Summary
8. Essential Properties of Modern Applications – Asynchrony and Concurrency
The pillars of Concurrency
The Async library – SIP-22-Async
Combining web services
Combining services without await
Getting started with Akka
Understanding the Actor model
Switching behavior
Supervising actors to handle failure
Testing actor systems
Exploring further with Akka
Summary
9. Building Reactive Web Applications
Describing reactive applications
Handling streams reactively
Understanding Iteratees in Play
Adapting Enumerator with Enumeratee
Experimenting with WebSockets and Iteratees in Play
Learning from activator templates
Reactive stocks
Reactive real-time search
The Play-Akka-Angular-WebSocket template
Playing with Actor Room
Summary
10. Scala Goodies
Exploring MongoDB
Entering Casbah
Applying MapReduce transformations
Scratching the surface of Big Data
Introducing DSLs in Scala
Observing internal DSLs
Tackling external DSLs through parser combinators
Introducing Scala.js
Final tips
Copying and pasting in the REPL
Timing code execution in the REPL
Summary
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Summary
Index
A
Abstract Syntax Tree (AST) /
Using Play JSON
activator templates
about /
Learning from activator templates
reactive stocks /
Reactive stocks
reactive real-time search /
Reactive real-time search
Play-Akka-Angular-WebSocket template /
The Play-Akka-Angular-WebSocket template
actor-in-a-box /
Understanding the Actor model
Actor model
about /
Understanding the Actor model
ActorRef object /
Understanding the Actor model
Actor Room
about /
Playing with Actor Room
actors
about /
Understanding the Actor model
supervising. to handle failure /
Supervising actors to handle failure
ActorSystem object /
Understanding the Actor model
actor systems
testing /
Testing actor systems
Akka
about /
Getting started with Akka
Actor model /
Understanding the Actor model
switching behavior /
Switching behavior
actor systems, testing /
Testing actor systems
documentation, URL /
Exploring further with Akka
akka.Main class /
Switching behavior
Algebird
about /
Scratching the surface of Big Data
anonymous functions /
Filter and partition
Anorm /
A simple example using Anorm
appendToFile() function /
Timing code execution in the REPL
apply method /
Understanding Iteratees in Play
assert statement /
Converting between collection types
AST (Abstract Syntax Tree) /
Mocking with ScalaMock
async() method /
The Async library – SIP-22-Async
Async library
about /
The Async library – SIP-22-Async
web services combining, async{}/await{} used /
Combining web services
web services combining, without await{} /
Combining services without await
async { <expression> } construct /
The Async library – SIP-22-Async
async{}/await{}
used, for combining web services /
Combining web services
async{}/await{} mechanism /
The Async library – SIP-22-Async
authentication
about /
Playing with authentication
await() method /
The Async library – SIP-22-Async
,
Combining services without await
await { <expression returning a Future> } construct /
The Async library – SIP-22-Async
B
Backus-Naur Form (BNF) /
Tackling external DSLs through parser combinators
BDD-style testing
about /
BDD-style testing
BookstoreSpec.scala class /
Binding XML data in Scala
C
Casbah
about /
Entering Casbah
Casbah Scala toolkit
URL /
Exploring MongoDB
case word /
Explaining case classes
classic Play distribution
URL, for downloading /
Getting started with the classic Play distribution
about /
Getting started with the classic Play distribution
close() method /
Timing code execution in the REPL
coll collection /
Entering Casbah
collections
operations /
Operations on collections
containing primitive types, transforming /
Transforming collections containing primitive types
of complex objects /
Collections of more complex objects
collections, complex objects
about /
Collections of more complex objects
filter and partition /
Filter and partition
tuples /
Dealing with tuples
map /
Introducing Map
option construct /
Introducing the Option construct
pattern matching /
A glimpse at pattern matching
map method /
The map method
String Interpolation /
Looking at String Interpolation
groupBy method /
The groupBy method
foldLeft method /
The foldLeft method
collection types /
Converting between collection types
companion /
Declaring objects
companion objects /
Introducing companion objects
Concurrency
about /
The pillars of Concurrency
controller, Play application
request, handling /
Handling a request in the controller
Converter.convert method /
Testing with ScalaCheck
copy and paste feature, REPL /
Copying and pasting in the REPL
copy method /
Explaining case classes
CustomerTest class /
Making JPA available in Scala
D
DAO (Data Access Object) class /
Making JPA available in Scala
database
existing database, REST API creating from /
Creating a REST API from an existing database
sample database /
The sample database
Domain Specific Language (DSL)
about /
Building with Simple Build Tool (SBT)
drop method /
Transforming collections containing primitive types
DSLs
about /
Introducing DSLs in Scala
internal DSLs /
Observing internal DSLs
external DSLs, tackling through parser combinators /
Tackling external DSLs through parser combinators
E
Either class /
The Async library – SIP-22-Async
ElasticSearch
URL /
Reactive real-time search
ElasticSearchActor actor /
Reactive real-time search
Enumeratee
defining /
Adapting Enumerator with Enumeratee
Enumerator
about /
Understanding Iteratees in Play
adapting, with Enumeratee /
Adapting Enumerator with Enumeratee
exceptions
handling /
Handling exceptions
expectMsg() method /
Testing actor systems
expects method /
Mocking with ScalaMock
external DSLs
tackling, through parser combinators /
Tackling external DSLs through parser combinators
F
f(param) function /
Timing code execution in the REPL
filter method /
Filter and partition
,
A glimpse at pattern matching
filterNot method /
Filter and partition
find method /
Entering Casbah
findOne{} method /
Entering Casbah
flatMap /
Summary
foldLeft method /
The foldLeft method
,
Understanding Iteratees in Play
foldRight method /
Understanding Iteratees in Play
for comprehension construct /
Scala's for comprehension
forURL method /
Learning about Slick
framework stack, Play application
visualizing /
Visualizing the framework stack
functional testing
about /
Functional testing
Futures and Promises
URL /
The pillars of Concurrency
future{} method /
The Async library – SIP-22-Async
G
getByName method /
Making JPA available in Scala
GoldCustomer class /
Scala traits as enhanced Java interfaces
greetPrinter /
Understanding the Actor model
groupBy method /
The groupBy method
Groupon service /
Working with HTTP
H
H2-browser database
visualizing /
Visualizing the database in the H2browser
HDFS
about /
Scratching the surface of Big Data
HelloAkkaScala object /
Understanding the Actor model
help() function /
Timing code execution in the REPL
hot swapped /
Visualizing the framework stack
HQL (Hibernate Query Language) /
Replacing ORM
HTTP
about /
Working with HTTP
for comprehension /
Scala's for comprehension
I
implicit c parameter /
A simple example using Anorm
Inbox object /
Understanding the Actor model
index() method /
Exploring the request-response lifecycle
index method /
Playing with authentication
Input.Empty
about /
Understanding Iteratees in Play
Input.EOF
about /
Understanding Iteratees in Play
Input[E]
about /
Understanding Iteratees in Play
insert command /
Entering Casbah
IntelliJ
about /
Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
internal DSLs /
Observing internal DSLs
Iteratees
about /
Understanding Iteratees in Play
,
Experimenting with WebSockets and Iteratees in Play
J
Java
unit testing, adding /
Adding a unit test in Java
and Scala code, in style differences /
Differences in style between Java and Scala code
code layout, adjusting /
Adjusting the code layout
naming conventions /
Naming conventions
JavaBean-style properties /
JavaBean-style properties
Java IDEs
about /
Inheriting Java Integrated Development Environments (IDEs)
Java Maven project
Scala, setting up /
Setting up Scala within a Java Maven project
Jfokus /
Summary
JPA
URL /
Making JPA available in Scala
JPA-annotated Scala
URL /
Making JPA available in Scala
JPA entities
creating /
Creating JPA entities and REST web services
JPQL (Java Persistence Query Language) /
Replacing ORM
JsArray /
Using Play JSON
JsBoolean /
Using Play JSON
JsError object /
Calling web services from Play
JsNull /
Using Play JSON
JsNumber /
Using Play JSON
JsObject /
Using Play JSON
JSON
manipulating /
Manipulating JSON
Play requests, handling with /
Handling Play requests with XML and JSON
Play responses, mocking with /
Mocking Play responses with JSON
JSPs (JavaServer Pages) /
Rendering the view
JsString /
Using Play JSON
JsValue type /
Using Play JSON
JUnit /
Adding a unit test in Java
L
lambdas /
More concise and expressive
Language entity /
Making JPA available in Scala
Location field /
Better fit for asynchronous and concurrent code
LogEntryProducerActor actor /
Reactive real-time search
LoggingReceive call /
Playing with Actor Room
LoggingReceive object /
Switching behavior
login method /
Playing with authentication
M
Macros /
Mocking with ScalaMock
main() method /
Introducing Scala.js
MainSearchActor actor /
Reactive real-time search
map
about /
Introducing Map
map method
about /
The map method
MapReduce /
Scala's for comprehension
MapReduce jobs
URL /
Scratching the surface of Big Data
MapReduce transformations
applying /
Applying MapReduce transformations
Maven project
setting up /
Setting up a Maven project
mocking
with ScalaMock /
Mocking with ScalaMock
MongoDB
exploring /
Exploring MongoDB
URL /
Exploring MongoDB
Casbah /
Entering Casbah
MapReduce transformations, applying /
Applying MapReduce transformations
mongod daemon /
Entering Casbah
N
naming conventions /
Naming conventions
nbsbt plugin /
Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
NEScala /
Summary
not only SQL (NoSQL) /
Exploring MongoDB
O
onComplete() method /
The Async library – SIP-22-Async
option construct
about /
Introducing the Option construct
ORM
about /
Integrating an existing ORM – Hibernate and JPA
replacing /
Replacing ORM
P
-paste command /
Combining web services
param argument /
Timing code execution in the REPL
parser combinators
URL /
Tackling external DSLs through parser combinators
partition method /
A glimpse at pattern matching
pattern matching
about /
A glimpse at pattern matching
Play
web services, calling from /
Calling web services from Play
Play-Akka-Angular-WebSocket template
about /
The Play-Akka-Angular-WebSocket template
play-json library /
Calling web services from Play
Play application
architecture /
Architecture of a Play application
framework stack, visualizing /
Visualizing the framework stack
request-response lifecycle, exploring /
Exploring the request-response lifecycle
controller request, handling /
Handling a request in the controller
view, rendering /
Rendering the view
Play application, scaffolding
about /
Scaffolding a Play application
test data, importing /
Importing test data
H2-browser database, visualizing /
Visualizing the database in the H2browser
app generation code, exploring /
Exploring the code behind the app generation
playcrud utility, limitations /
Limitations of the playcrud utility
playcrud utility
limitations /
Limitations of the playcrud utility
Play Framework
using, tips /
Practical tips when using Play
debugging /
Debugging with Play
version control /
Dealing with version control
persistence /
Dealing with persistence in the Play Framework
example, Anorm used /
A simple example using Anorm
Play JSON
about /
Using Play JSON
Play requests
handling, with XML /
Handling Play requests with XML and JSON
handling, with JSON /
Handling Play requests with XML and JSON
Play responses
mocking, with JSON /
Mocking Play responses with JSON
Play responses
mocking, with JSON /
Mocking Play responses with JSON
publish-local command /
Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
R
reactive applications
about /
Describing reactive applications
Reactive Manifesto
URL /
Describing reactive applications
ReactiveMongo project
URL /
Applying MapReduce transformations
reactive real-time search
about /
Reactive real-time search
reactive stocks
about /
Reactive stocks
react to events
about /
Describing reactive applications
react to failure
about /
Describing reactive applications
react to load
about /
Describing reactive applications
react to users
about /
Describing reactive applications
receive() method /
Understanding the Actor model
,
Supervising actors to handle failure
Receiver actor /
Playing with Actor Room
reduce method /
Naming conventions
remove{} method /
Entering Casbah
REPL /
Better fit for asynchronous and concurrent code
as scripting engine /
The REPL as a scripting engine
copy and paste feature /
Copying and pasting in the REPL
timing code execution /
Timing code execution in the REPL
request-response lifecycle, Play application
exploring /
Exploring the request-response lifecycle
require() assertion /
Switching behavior
REST API
creating, from existing database /
Creating a REST API from an existing database
sample database /
The sample database
Maven project, setting up /
Setting up a Maven project
JPA entities, creating /
Creating JPA entities and REST web services
REST web service, creating /
Creating JPA entities and REST web services
project, testing /
Running and testing the project
project, running /
Running and testing the project
REST web service
creating /
Creating JPA entities and REST web services
ResultSet object /
A simple example using Anorm
run method /
Understanding Iteratees in Play
S
@ sign /
Rendering the view
SBT
about /
Building with Simple Build Tool (SBT)
sample project, creating /
Creating a sample project
Eclipse project, importing /
Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
IntelliJ /
Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
web application, creating /
Creating a web application that runs on a servlet container
single .jar archive building, sbt-assembly used /
Using sbt-assembly to build a single .jar archive
code, formatting with Scalariform /
Formatting code with Scalariform
sbt-assembly
using, to build single .jar archive /
Using sbt-assembly to build a single .jar archive
sbt-idea plugin /
Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
sbteclipse plugin /
Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
,
Writing tests with ScalaTest
,
Binding XML data in Scala
Scala
learning, through REPL /
Learning Scala through the REPL
test, adding /
Adding a test in Scala
setting up, within Java Maven project /
Setting up Scala within a Java Maven project
JPA availability /
Making JPA available in Scala
XML data, binding /
Binding XML data in Scala
DSLs /
Introducing DSLs in Scala
Scala.io /
Summary
Scala.js
about /
Introducing Scala.js
scala.util.Try class /
Handling exceptions
Scala and Java collaboration
about /
Scala and Java collaboration
collection types /
Converting between collection types
JavaBean-style properties /
JavaBean-style properties
object orientation /
Scala and Java object orientation
enhanced Java interfaces /
Scala traits as enhanced Java interfaces
objects, declaring /
Declaring objects
companion objects /
Introducing companion objects
exceptions, handling /
Handling exceptions
ScalaCheck
testing with /
Testing with ScalaCheck
Scaladays /
Summary
Scala dispatch library
URL /
Working with HTTP
Scala events /
Summary
Scala eXchange /
Summary
Scala for Java projects
advantages /
Advantages of using Scala for Java projects
,
More concise and expressive
,
Increased productivity
,
Better fit for asynchronous and concurrent code
Scala Improvement Process (SIP) /
The pillars of Concurrency
ScalaMock
mocking with /
Mocking with ScalaMock
URL /
Mocking with ScalaMock
Scala REPL (Read-Eval-Print-Loop) /
Better fit for asynchronous and concurrent code
about /
Learning Scala through the REPL
var variables, declaring /
Declaring val/var variables
val variables, declaring /
Declaring val/var variables
classes, defining /
Defining classes
case classes /
Explaining case classes
Scalariform
code, formatting with /
Formatting code with Scalariform
ScalaTest
about /
Writing tests with ScalaTest
BDD-style testing /
BDD-style testing
functional testing /
Functional testing
ScalaTest class /
Writing tests with ScalaTest
Scala Worksheets
about /
Experimenting with Scala Worksheets
scalaxb
running, from SOAP web service /
Running scalaxb from a SOAP web service
scalaxb library /
Binding XML data in Scala
Selenium tool
URL /
Functional testing
Server Side Events (SSE) /
Reactive real-time search
Simple Build Tool (SBT) /
Setting up Scala within a Java Maven project
single .jar archive
building, sbt-assembly used /
Using sbt-assembly to build a single .jar archive
singleOpt method /
A simple example using Anorm
Slick framework
benefits /
Replacing ORM
about /
Learning about Slick
SOAP web service
scalaxb, running from /
Running scalaxb from a SOAP web service
social security number (ssn) /
Declaring val/var variables
Spark
about /
Scratching the surface of Big Data
Spring
URL /
Making JPA available in Scala
square() method /
Introducing Scala.js
static keyword /
Declaring objects
StockActor
about /
Reactive stocks
streams
handling /
Handling streams reactively
String Interpolation
about /
Looking at String Interpolation
StringSpecification test /
Testing with ScalaCheck
SummingBird
about /
Scratching the surface of Big Data
system.actorOf() method /
Understanding the Actor model
T
TAB completion /
Defining classes
test
adding /
Adding a test in Scala
test-only command /
Writing tests with ScalaTest
testing
BDD-style testing /
BDD-style testing
functional testing /
Functional testing
timeAndLogged() function /
Timing code execution in the REPL
timedAndLogged() function /
Timing code execution in the REPL
timedAndLogged() method /
Timing code execution in the REPL
timing code execution, REPL /
Timing code execution in the REPL
TravelAgent object /
Switching behavior
tuples /
Dealing with tuples
Type Inference /
Declaring val/var variables
Typesafe Activator
about /
Taking advantage of Typesafe Activator
,
Getting started with the Typesafe Activator
application creating, based on activator templates /
Creating an application based on activator templates
Typesafe page
URL /
Better fit for asynchronous and concurrent code
U
unit test
adding, in Java /
Adding a unit test in Java
using() function /
Timing code execution in the REPL
using() method /
Timing code execution in the REPL
V
view, Play application
rendering /
Rendering the view
VIPCustomer class /
Scala traits as enhanced Java interfaces
W
-wrap() method /
Timing code execution in the REPL
web application
creating /
Creating a web application that runs on a servlet container
web services
calling, from Play /
Calling web services from Play
Web Services Description Language (WSDL) /
Running scalaxb from a SOAP web service
WebSocket.async[JsValue] method /
The Play-Akka-Angular-WebSocket template
WebSockets
about /
Experimenting with WebSockets and Iteratees in Play
with keyword /
Scala traits as enhanced Java interfaces
X
XML
manipulating /
Manipulating XML
Play requests, handling with /
Handling Play requests with XML and JSON
XML data
binding /
Binding XML data in Scala
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset