Making Java Groovy

By Ken Kousen


Making Java Groovy is a pragmatic instruction manual for builders who are looking to mixture Groovy into their daily paintings with Java. It starts off through introducing the foremost alterations among Java and Groovy—and how one can use them on your virtue. Then, it courses you step by step via life like improvement demanding situations, from net purposes to internet prone to computing device functions, and exhibits how Groovy makes them more uncomplicated to place into creation.

About this Book

You don't want the entire strength of Java if you end up writing a construct script, an easy method software, or a light-weight internet app—but that is the place Groovy shines brightest. This dependent JVM-based dynamic language extends and simplifies Java so that you can pay attention to the duty handy rather than dealing with minute info and pointless complexity.

Making Java Groov is a pragmatic advisor for builders who are looking to reap the benefits of Groovy of their paintings with Java. It starts off by means of introducing the major ameliorations among Java and Groovy and the way to take advantage of them for your virtue. Then, you will specialize in the events you face on a daily basis, like eating and developing RESTful internet companies, operating with databases, and utilizing the Spring framework. you will additionally discover the good Groovy instruments for construct techniques, trying out, and deployment and write Groovy-based domain-specific languages that simplify Java improvement.

Written for builders acquainted with Java. No Groovy event required.

Purchase of the print booklet features a unfastened booklet in PDF, Kindle, and ePub codecs from Manning courses.

What's Inside

  • Easier Java
  • Closures, developers, and metaprogramming
  • Gradle for builds, Spock for testing
  • Groovy frameworks like Grails and Griffon

About the Author

Ken Kousen is an autonomous advisor and coach focusing on Spring, Hibernate, Groovy, and Grails.

Table of Contents

    PART 1: in control WITH GROOVY
  1. Why upload Groovy to Java?
  2. Groovy by means of example
  3. Code-level integration
  4. Using Groovy good points in Java
  6. Build processes
  7. Testing Groovy and Java projects
  8. PART three: GROOVY within the actual WORLD
  9. The Spring framework
  10. Database access
  11. RESTful net services
  12. development and trying out internet applications

Show description

Quick preview of Making Java Groovy PDF

Similar Java books

Mastering Lambdas: Java Programming in a Multicore World (Oracle Press)

The Definitive advisor to Lambda Expressions learning Lambdas: Java Programming in a Multicore international describes how the lambda-related gains of Java SE eight will permit Java to fulfill the demanding situations of next-generation parallel architectures. The booklet explains the way to write lambdas, and the way to take advantage of them in streams and in assortment processing, offering code examples all through.

Mastering JavaFX 8 Controls (Oracle Press)

Layout and set up High-Performance JavaFX Controls convey cutting-edge purposes with visually gorgeous UIs. getting to know JavaFX eight Controls offers transparent directions, targeted examples, and ready-to-use code samples. how you can paintings with the newest JavaFX APIs, configure UI parts, immediately generate FXML, construct state-of-the-art controls, and successfully practice CSS styling.

Data Abstraction and Problem Solving with Java: Walls and Mirrors (3rd Edition)

The 3rd version of info Abstraction and challenge fixing with Java: partitions and Mirrors employs the analogies of partitions (data abstraction) and Mirrors (recursion) to coach Java programming layout strategies, in a manner that starting scholars locate obtainable. The e-book has a student-friendly pedagogical method that conscientiously bills for the strengths and weaknesses of the Java language.

Java Software Solutions: Foundations of Program Design (7th Edition)

Java software program strategies teaches a beginning of programming suggestions to foster well-designed object-oriented software program. Heralded for its integration of small and massive lifelike examples, this around the globe best-selling textual content emphasizes construction strong problem-solving and layout talents to write down top of the range courses.

Additional resources for Making Java Groovy

Show sample text content

SplitEachLine(',') { line -> int identification = line[0]. toInteger() double stability = line[1]. toDouble() accounts[id] = new Account(id:id,balance:balance) } nextId = accounts?. keySet(). max() ? : zero nextId++ soiled = fake } every one account is saved as undeniable textual content, with a comma keeping apart the identity from the stability. analyzing debts makes use of the splitEachLine procedure that takes arguments: the delimiter (a comma for that reason) and a closure that defines what to do with the ensuing record. The closure says to parse the identity and stability into the right kind facts varieties, instantiate an account with the ensuing values, and reserve it within the map. Then i must set the nextId variable to 1 greater than the max of the IDs used up to now, which supplies me a chance to exploit the cool Elvis operator. 10 ultimately, simply because this technique refreshes the cache, i will be able to set the soiled flag to fake. The corresponding way to write out the debts is proven subsequent: void writeAccountsToFile() { accountsFile. withWriter { w -> bills. every one { identification, account -> w. println("$id,$account. balance") } } soiled = actual } The withWriter technique is from the Groovy JDK and is further to the java. io. dossier category. It presents an output author wrapped round the dossier that closes immediately whilst the closure argument completes. The closure writes the identity and stability of every account to a unmarried line within the dossier, separated via a comma. simply because this technique adjustments the dossier, it units the soiled flag to actual in order that the category is familiar with the cache has to be refreshed. nine 10 That’s one other refined seize. The syntax for Java generics compiles in Groovy, yet simply because you declared a List doesn’t suggest you can’t upload circumstances of String, Date, or worker that allows you to. In Groovy, reflect on the widely used announcement as not anything greater than documentation. I don’t fairly exit of my method to locate excuses to exploit the cool Elvis operator, yet I don’t cross them up after they current themselves both. 148 bankruptcy 6 checking out Groovy and Java initiatives With these equipment in position, the following directory indicates the total DAO implementation. directory 6. 20 the full FileAccountDAO implementation, in Groovy type FileAccountDAO implements AccountDAO { def accountsFile Map bills = [:] deepest static int nextId boolean soiled inner most void readAccountsFromFile() { accountsFile. splitEachLine(',') { line -> int identification = line[0]. toInteger() double stability = line[1]. toDouble() accounts[id] = new Account(id:id,balance:balance) } nextId = accounts?. keySet(). max() ? : zero nextId++ soiled = fake } inner most void writeAccountsToFile() { accountsFile. withWriter { w -> money owed. each one { identification, account -> w. println("$id,$account. balance") } } soiled = real } @Override Account findAccountById(int identification) { if (dirty) readAccountsFromFile() go back accounts[id] } @Override Collection findAllAccounts() { if (dirty) readAccountsFromFile() go back money owed. values() } Refresh the cache if valuable @Override int createNewAccount(double stability) { int newId = nextId++ accounts[newId] = new Account(id:newId,balance:balance) writeAccountsToFile() go back newId; } @Override void deleteAccount(int identification) { money owed.

Download PDF sample

Rated 4.16 of 5 – based on 10 votes