ebook img

Java Magazine 2016 01-02 PDF

30.3 MB·English
by  Oracle
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Java Magazine 2016 01-02

JAVA 9 MODULARITY 59 | GOSU LANGUAGE 65 | KUMULUZEE 80 BEHIND THE UI WRITING WEB APPS JANUARY/FEBRUARY 2016 15 SPRING BOOT: FAST, EASY WEB APPLICATIONS 23 OMNIFACES: COMPREHENSIVE JSF UTILITY 31 JAX-RS 2.0: THE LITTLE-USED FEATURES 41 LONG-LIVED SERVER CONNECTIONS ORACLE.COM/JAVAMAGAZINE //table of contents / 23 31 41 47 15 FIRST STEPS WITH OMNIFACES: JAX-RS 2.0: LONG PUSHING SPRING BOOT MAKING JSF USING ALL THE POLLING WITH DATA IN BOTH A LOT EASIER GOODNESS ASYNCHRONOUS DIRECTIONS By Josh Long SERVLETS WITH By Anghel Leonard By Abhishek Gupta The new Spring WEBSOCKETS Solve many day-to-day Understanding the By Henry Naftulin framework brings JSF problems with client API, filters, The reliable workhorse By Danny Coward long-awaited ease a single, integrated interceptors, and other of client/server Build on WebSockets’ of development utility library. useful REST features communications is long-lasting connec- to web apps. the easy-to-use tions to create a simple fallback when other chat app methods don’t work. COVER ART BY I-HUA CHEN 03 59 72 89 From the Editor Path to Java 9 Containers Fix This The Rise and Fall of Languages in 2015 An Early Look at Java 9 Modules Using Multiple Docker Containers By Simon Roberts Our latest code challenges 06 By Ben Evans By Arun Gupta Preparing for modularity—the biggest Assemble a cluster of Docker containers Letters to the Editor 40 change by far in the next release of Java and run a Java EE app—without a lot of Comments, questions, suggestions, Java Proposals of Interest housekeeping. and kudos 65 JEP 254: Compact Strings JVM Languages 80 08 71 Gosu: A Modern, Down-to-Earth Microservices Events User Groups Language for the JVM KumuluzEE: Building Upcoming Java conferences and events Manchester Java Community Microservices with Java EE By Scott McKinney 11 A low-ceremony language used in 93 By Tilen Faganel and Matjaz B. Juric Java Books enterprise apps offers an extraordinarily Develop self-contained microservices Contact Us Reviews of two Java tutorials flexible, yet static, type system. with standard Java EE APIs using the Have a comment? Suggestion? Want to open source KumuluzEE framework. submit an article proposal? Here’s how. 01 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2016 EDITORIAL PUBLISHING Editor in Chief Publisher 7 Billion Andrew Binstock Jennifer Hamilton +1.650.506.3794 Managing Editor Associate Publisher and Audience Claire Breen Development Director Copy Editors Karin Kinnear +1.650.506.1985 Karen Perkins, Jim Donahue Audience Development Manager Section Development Jennifer Kurtz Michelle Kovac Technical Reviewers ADVERTISING SALES Stephen Chin, Reza Rahman Tom Cometa [email protected] Devices Run Java Advertising Sales Assistant DESIGN Cindy Elhaj +1.626.396.9400 x 201 Senior Creative Director Mailing-List Rentals Francisco G Delgadillo Contact your sales representative. Design Director RESOURCES Richard Merchán Oracle Products Senior Designer +1.800.367.8674 (US/Canada) Arianna Pucherelli Oracle Services Designer +1.888.283.0591 (US) Jaime Ferrand Senior Production Manager ATMs, Smartcards, POS Terminals, Blu-ray Players, Sheila Brennan Production Designer Kathy Cygnarowicz Set Top Boxes, Multifunction Printers, PCs, Servers, Routers, Switches, Parking Meters, Smart Meters, Lottery Systems, Airplane Systems, IoT Gateways, ARTICLE SUBMISSION If you are interested in submitting an article, please email the editors. Programmable Logic Controllers, Optical Sensors, SUBSCRIPTION INFORMATION Subscriptions are complimentary for qualified individuals who complete the subscription form. Wireless M2M Modules, Access Control Systems, MAGAZINE CUSTOMER SERVICE [email protected] Phone +1.847.763.9635 Medical Devices, Building Controls, Automobiles… PRIVACY Oracle Publishing allows sharing of its mailing list with selected third parties. If you prefer that your mailing address or email address not be included in this program, contact Customer Service. Copyright © 2016, Oracle and/or its affiliates. All Rights Reserved. No part of this publication may be reprinted or otherwise reproduced without permission from the editors. JAVA MAGAZINE IS PROVIDED ON AN “AS IS” BASIS. ORACLE EXPRESSLY DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING FROM YOUR USE OF OR RELIANCE ON ANY INFORMATION PROVIDED HEREIN. Opinions expressed by authors, editors, and interviewees—even if they are Oracle employees—do not reflect the views of Oracle. The #1 Development Platform information is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Oracle and Java are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Java Magazine is published bimonthly at no cost to qualified subscribers by Oracle, 500 Oracle Parkway, MS OPL-3A, Redwood City, CA 94065-1600. 02 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2016 //from the editor / The Rise and Fall of Languages in 2015 An unusually good year for Java and JVM languages F or the last few years, in my first editorial of data extracted from GitHub, the popular host the new year, I’ve looked at how programming for open source and private projects; Open Hub, languages fared during the previous calendar year. which surveys all active open source projects; and Despite the general perception that changes in Google Trends. Each measure quantifies different language popularity are slow-moving affairs, pro- things, and it’s important to look at the data in gramming languages often suffer sudden declines context before determining what useful informa- (Objective-C) or enjoy unexpected surges (Java, as tion it provides. I’ll explain in a moment). The most widely used By most measures, Java had a banner year. measure of popularity is the TIOBE Index, which TIOBE just named Java Language of the Year for counts searches for languages and normalizes 2015 because it enjoyed the greatest jump of any the results to a percentage of the total number of language in terms of percentage of searches. searches. Whether web searches are an accurate TIOBE attributes this surge to the use of Java on proxy for popularity is a point of some conten- Android. I believe this is true, but it’s only part of tion; however, the TIOBE Index has one significant the story. The rapid adoption of Java 8 certainly advantage: it provides data for the index going contributed, too. Java’s surge definitively lays to back 15 years. This makes it possible to identify rest the trend of click-bait articles inquiring “Is multiyear trends easily. Java Dead?” in which pundits invariably concluded Good analysis of language popularity neces- after lots of explanation that it’s not dead. sarily relies on additional sources. I also rely on GitHub is a good way to measure popularity PHOTOGRAPH BY BOB ADLER/GETTY IMAGES 03 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2016 //from the editor / among younger programmers. years in order to move out of the the most interesting trend, which Here, too, Java is hot. It cur- margins. I’m curious to see if it appears in multiple indexes, rently sits behind only JavaScript will cross this chasm. Several is that JavaScript’s popularity in popularity. This represents a years ago, the biggest complaints appears to have peaked. A few remarkable ascent. GitHub ini- about Scala were the binary years ago, its ubiquity on front tially rose to popularity in the incompatibility of new releases, ends (both web and mobile) and Ruby community. In 2008, Java slow compile times, and lan- the advent of Node.js suggested was the seventh most popular guage complexity. Today, the last that it might become the new language on GitHub; Ruby was two concerns remain important universal programming language first. Java’s ascent of five posi- obstacles. Meanwhile, languages (see Atwood’s Law). But limita- tions in the intervening years such as Kotlin, which is viewed tions of the language make it is unmatched. During the same by many as a direct competitor, difficult to use on large-scale period, no programming lan- are putting pressure on Scala. So projects. The result has been guage has managed to rise more is Java indirectly. Scala’s claim to the growth of JavaScript trans- than two slots. I expect its popu- fame is that it enables developers piling alternatives such as Dart, larity to continue due to Java’s to mix object-oriented (OO) and CoffeeScript, and TypeScript. Of ubiquity on the cloud (every functional paradigms. But Java 8 these, I personally most admire major cloud provider supports introduced functional program- TypeScript, which also appears it) and its central role in the ming elements, which, while to be gaining the most traction Internet of Things. far more modest than Scala’s, among developers. I’ll be curi- Among third-party JVM lan- might induce businesses think- ous to see whether the approval guages, the only two entrants ing of looking to Scala for its of the ECMAScript 6 standard to make it into the TIOBE top functional-OO hybrid qualities to (also known as ECMAScript 2015) 50 or to be ranked by Open Hub stay put. in June of last year will improve are Groovy (#17) and Scala (#30). Developers who prefer the func- JavaScript’s popularity. We’ll On TIOBE, Groovy had a banner tional paradigm will be pleased check in next year. year. It’s hard to know the cause to know that TIOBE expects that Language features and projec- of this, although progress in the Clojure, with its Lisp-like syn- tions of future language adoption chief complaint against it— tax and currently sitting in third are among the most enjoyable performance—has surely helped. place among JVM languages, will discussions in programming. Let In open source projects, Scala soon advance to the honor roll me know if you have different has the upper hand in popular- of top 50 languages. Meanwhile, views from mine. ity. This suggests that Groovy is other functional languages, such Andrew Binstock, Editor in Chief more popular in business con- as Haskell and Erlang, both broke [email protected] texts, which is a transition that into the top 40 spots. @platypusguy Scala must make in the next few In non-JVM languages, perhaps 04 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2016 AOT Compilation Has Come to Java 8 Excelsior JET 11 supports Java SE 8 and JavaFX 8 on all desktop platforms. Try It Now Registration-Free, 90-Days Trial Download //letters to the editor / More JavaFX and Introductory Unreasonable Effectiveness of the DRE would be 90 percent. Articles Static Analysis,” September/ The current US average for Java Magazine used to run arti- October 2015 issue, page 3). You DRE is about 92 percent, but top cles for developers new to Java were kind enough to quote some projects can get up to 99.5 per- in every issue. In addition, there of the statistics I published ear- cent. This average value is based were occasional articles on lier. Let me make some comments on both pretest removal and JavaFX. Is it possible to continue and add some more information. the six normal test stages used publishing such articles? Static analysis is among the —Marius Claassen most effective forms of defect TECHNIQUE DEFECT removal, and also fairly inexpen- REMOVAL Editor Andrew Binstock responds: sive and fairly rapid. It can be used SEPTEMBER/OCTOBER 2015 RATE Thanks for your note. Readers’ sug- for both development and also for FORMAL INSPECTIONS 87% gestions about what to cover more removing latent bugs in legacy frequently are very helpful to us. applications. As you pointed out, STATIC ANALYSIS 55% We will be resuming the beginner false positives are much lower EXTERNAL BETA TEST > 1,000 52% series in the next issue, and it should today than they were 10 years CLIENTS become a regular feature. Michael ago. I think static analysis should SYSTEM TEST—CERTIFIED TESTERS 46% Kölling—the author of the previous become a standard software qual- INFORMAL PEER REVIEWS 45% series on introductory topics—will be ity method that is used on just SYSTEM TEST—UNCERTIFIED 36% the author. His focus will be on lan- about 100 percent of all software DEVELOPERS guage features, especially the dark applications, with one caveat—the corners where unexpected or unusual tool is simply not available for FUNCTION TEST 35% behaviors are found. many languages except the 30 or COMPONENT TEST 32% You might have seen in the so most popular ones. UNIT TEST 30% September/October issue that we However, its effectiveness is covered TestFX, a way of testing undeniable. Table 1 shows the EXTERNAL BETA TEST < 1,000 28% CLIENTS JavaFX apps. And we do have a cou- approximate defect removal effi- DESK CHECK 27% ple of additional JavaFX articles in ciency (DRE) values for a sample the pipeline. If we see an increase in of pretest removal and for test PAIR PROGRAMMING 22% demand for JavaFX articles, we will stages. The DRE metric was devel- ACCEPTANCE TEST 17% cover the topic even more. oped by IBM circa 1973 as a tool REGRESSION TEST 14% for validating the effectiveness of How Effective Is Static inspections. It is a simple metric. PERFORMANCE TEST 12% Analysis? If developers find 90 bugs and a Table 1. Defect removal efficiency (in Thank you for your editorial on customer reports 10 bugs in the descending order) for pretest and test techniques the value of static analysis (“The first three months of use, then 06 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2016 //letters to the editor / for most software (unit test, function test, regression test, performance test, system test, and acceptance test). Of course, some critical software—such as medical devices and weapons systems— might use more than 12 test stages and, therefore, exceed 99 percent in DRE. DRE is only half of the IBM quality metric set. The other half was “defect potential” or the sum of the bugs found in many sources. Today, defect poten- tial is measured using function point metrics because “lines of code” isn’t a useful measure for requirements and design bugs. The current US average is about 4.5 bugs per function point, which represents the total of all bugs found in requirements, architecture, design, code, user documents, and “bad fixes” or new bugs in bug repairs. Once again, thank you for a good article. I hope this additional informa- tion will be helpful. —Capers Jones VP and CTO, Namcook Analytics LLC Contact Us We welcome comments, suggestions, grumbles, kudos, article proposals, and chocolate chip cookies. All but the last two might be edited for publication. If your note is private, please indicate this in your message. Please write to us at [email protected]. For other ways to reach us, see the last page of this issue. 07 ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2016 //events / Topconf Linz presentations. Featured tracks FEBRUARY 1–3 include HTML5 and JavaScript, LINZ, AUSTRIA Java SE/Java EE/Spring, and This conference focuses on data and integration. new ways to manage mobile, Apache Hadoop Innovation Java, cloud, front end, security, Summit and more. Workshops include FEBRUARY 18–19 sketching web and app inter- SAN DIEGO, CALIFORNIA faces, microservices and event With presentations from more sourcing with Spring Boot, and than 25 hands-on industry software management in a speakers, topics covered will lean and agile world. include MapReduce and Spark, Jfokus building privacy-protected FEBRUARY 8–10 data systems, scalable data STOCKHOLM, SWEDEN curation, best practices, and Jfokus has run for eight years architectural considerations for and is the largest annual Hadoop applications. Java developer conference Mobile World Congress in Sweden. Conference topics FEBRUARY 22–25 include Java SE and Java EE, JavaLand MARCH 8–10 Voxxed Days Berlin BARCELONA, SPAIN the inner mechanics of the BRÜHL, GERMANY JANUARY 27–29 This industry-leading event JVM, front end and web, This annual conference is a gathering of BERLIN, GERMANY mobile, continuous delivery focuses on in-depth analysis of Java enthusiasts, developers, architects, Sharing the Devoxx philoso- and DevOps, the IoT, cloud and present and future trends in the strategists, and project administrators. phy that content comes first, big data, future and trends, mobile industry. The 2016 MWC Session topics for 2016 include contain- Voxxed Days events see both alternative JVM languages, conference program features ers and microservices, core Java and JVM internationally renowned and and agile development. tracks on the IoT, smart cities, languages, enterprise Java and the cloud, local speakers converge. Berlin digital finance, and more. DevNexus 2016 front end and mobile, IDEs and tools, and topics include Java compo- Embedded World 2016 the Internet of Things (IoT). After lectures nent design with Spring 4.3; FEBRUARY 15–17 FEBRUARY 23–25 on the first day of the conference, attend- microservices with Java, Spring ATLANTA, GEORGIA NUREMBERG, GERMANY ees get exclusive use of Phantasialand and Boot, and Spring Cloud; DevNexus is a conference The 14th annual gathering of its rides and attractions. and simple REST APIs with drawing 1,700 developers, with embedded system developers Dropwizard and Swagger. 6 workshops, 12 tracks, and 120 08 PHOTOGRAPH BY RACHEL TITIRIGIA/FLICKR ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2016 //events / QCon London jDays MARCH 7–9 MARCH 8–9 LONDON, ENGLAND GOTHENBURG, SWEDEN QCon is designed for techni- jDays is a Java developer con- cal team leads, architects, ference covering Java/Java EE, engineering directors, and architecture, security, DevOps, project managers who influ- cloud and microservices, testing, ence innovation in their teams. JavaScript, IoT trends, methodolo- Topics include what to expect in gies, and tools. Java 9 and Spring 5, containers CITCON in production, microservices for LATE MARCH (DATE TO BE ANNOUNCED) mega-architectures, full-stack PERTH, AUSTRALIA JavaScript, and data science and machine learning methods. CITCON, the Continuous Integra- tion and Testing Conference, is EclipseCon 2016 a worldwide series of free “Open will explore the latest develop- Testing Java EE Applications Using MARCH 7–10 Spaces” events for developer- ments, define trends, and once Arquillian, by Reza Rahman, and RESTON, VIRGINIA testers, tester-developers, and again present the key areas of Hybrid Mobile Development with EclipseCon is all about com- anyone else with an interest in focus for future developments. Apache Cordova and Java EE 7, by munity. Contributors, adopters, continuous integration and the This is where hardware, soft- Ryan Cuprak. extenders, service providers, type of testing that goes along ware, and system development Riga Dev Day consumers, and business and with it. engineers come together to turn MARCH 2–4 research organizations gather to the next milestones of the IoT RIGA, LATVIA share their expertise and learn Have an upcoming confer- into reality. from each other. Topics this year ence you’d like to add to our This event is a joint project by include an introduction to the listing? Send us a link and a ConFoo Google Developer Group Riga, Java Eclipse Che next-generation description of your event at FEBRUARY 24–26 User Group Latvia, and Oracle User Java IDE, hawkBit and soft- least four months in advance at MONTREAL, QUEBEC, CANADA Group Latvia. By and for software ware updates for the IoT, a faster [email protected]. We’ll developers, Riga Dev Day focuses ConFoo is a multitechnology con- index for Java, and Java 9 support include as many as space permits. on 25 of the most-relevant topics ference for web developers, fea- in Eclipse. and technologies for that audi- turing about 150 presentations ence. Tracks include JVM and web by popular international speak- development, databases, DevOps, ers. Past sessions have included and case studies. 09 PHOTOGRAPH BY BOBISTRAVELING/FLICKR ORACLE.COM/JAVAMAGAZINE ////////////////////////////////// JANUARY/FEBRUARY 2016

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.