Hiển thị các bài đăng có nhãn Book Review. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Book Review. Hiển thị tất cả bài đăng

Thứ Ba, 15 tháng 1, 2013

Book Review: GateIn Cookbook

I recently accepted an invitation to provide a review of a relatively recently released (publication date is listed as November 2012) Packt Publishing book called GateIn Cookbook. This book is, as its name implies, about the JBoss/eXo collaborative GateIn Portal. The cover of the book offers "quick answers to common problems" and describes its contents as "over 60 recipes for building portals with GateIn." Although I am familiar with the portal concept and looked at them in some detail several years ago, it has been a while since I've seriously considered portal technology and I looked forward to reading a book on GateIn.

Including index, preface, table of contents, introductory pages, etc., GateIn Cookbook is nearly 400 pages and is written by three authors: Ken Finnigan ("Technical Lead of the JBoss Portlet Bridge project and a member of the GateIn Development team" at JBoss), Luca Stancapiano, and Piergiorgio Lucidi (Sourcesense).

The Preface

The Preface of GateIn Cookbook states that the book provides "a quick approach to building portals" and is written for "anyone who needs to administer or develop applications on GateIn." According to the Preface, the reader will benefit from familiarity with Java and REST and should have access to one of the three major operating systems (Linux, Mac OX S, Windows), JDK 1.6, Eclipse IDE (to use Eclipse-based JBoss tools, but other Maven-supporting IDEs can be used as well with GateIn and most of the recipes will be workable with any modern Java IDE), Apache Subversion ("latest version"), Apache Maven ("latest version"), and "GateIn Portal 3.2.0 and beyond" to run examples provided in GateIn Cookbook.

Chapter 1: Getting Started

As its title suggests, Chapter 1 is about getting started with GateIn. It seems that "cookbooks" used to assume introductory knowledge and focused on more intermediate and advanced recipes. More recently, it seems to have become more customary for the initial chapters of cookbooks to have more introductory material. I think this is an advantage because it allows the read to use the same book to learn enough basics to start using the new technology.

Chapter 1 introduces GateIn with this description:

GateIn is a portal framework dedicated to implementing highly customizable portal solutions with a powerful set of components based on well-known and adopted open source technologies and standards based on the Java web technologies.

Chapter 1 covers installation of GateIn from a binary package for application/web server-specific bundles for three major versions of JBoss (5.x, 6.x, 7.x), two major versions of Tomcat (6.x, 7.x), and Jetty 6.x. Most of the recipes in the book focus on Tomcat and JBoss AS 6 or 7. Another section of Chapter 1 describes building GateIn from source code retrieved using Subversion and built using Maven.

A recipe in Chapter 1 discusses use of eXo JCR as a JSR 170 Java content repository and PicketLink IDM as a "a common identity model for Identity Management operations." That section also looks at replacing the provided HypersonicSQL database with an Oracle database and with a MySQL database via JDBC driver configuration.

Chapter 1 of GateIn Cookbook has one non-trivial error that I noticed. The authors write that the reader can determine whether the JDK is installed (as opposed to the JRE only being installed I imagine) by running java -version and looking at which version of the JVM is returned by default. Specifically, they state that the presence of the "String Client" indicates the JDK is not installed and the presence of the "String Server" indicates that the JDK is installed. This is not correct.

Chapter 2: Managing Portal Contents Using the GUI

The second chapter discusses GateIn administration using GateIn's "default administration tools" using the graphical dashboard. The covered administrative tasks include creating a portal instance, removing a portal instance, allowing public access to the portal, changing portal layout, creating and removing page instances within a portal, and using/contrasting portlets and gadgets in a portal instance. Not surprisingly for a chapter on graphical administration, this chapter is full of screen snapshots.

Chapter 3: Managing Portal Contents Using XML

The third chapter covers similar material as the second chapter, but demonstrates administration via XML and command-line tooling rather than graphical tooling. Reading Chapters 2 and 3 helps one to see how much easier the graphical interface is than the XML, which seems to me to quickly become unwieldy as the XML files get large.

Chapter 4: Managing Portal Users

The fourth chapter of GateIn Cookbook is about user administration and covers recipes related to creating users, removing users, managing memberships, managing groups, and assigning users to groups. Other recipes in this chapter cover LDAP integration, use of OpenSSO, and use of Simple and Protected GSSAPI Negotiation Mechanism.

Chapter 5: Securing Portal Contents

Chapter 5 of GateIn Cookbook "discusses the configurations aimed at providing security features to portals and all the related components." While Chapter 4 covered authentication, Chapter 5 covers authorization. Its recipes include securing portals, securing pages, securing portlets, and securing applications.

Chapter 6: Developing Portlets

Chapter 6 introduces portlets and the Portlet 2.0 specification (JSR 286) and uses JavaServer Pages (JSP) as the primary view technology. The chapter outlines the basics of applying portlets and summarizes the "three main parts to a portlet": a portlet class, view technology (JSP), and deployment descriptor. Recipes in this chapter also cover multiple ways of communicating between portlets and localizing portlets.

Chapter 7: Developing Using Components API

The seventh chapter of GateIn Cookbook introduces the GateIn-provided "web framework named WebUI (Web User Interface)" and describes it as "similar to JSF because it is based on components." The chapter also mentions that "GateIn has about 400 components provided by WebUI." The chapter shows use of XML for configuration or alternative annotations for configuration. Other recipes include use of Groovy templates and embedding JavaScript in portlets.

Chapter 8: Migrating from Existing Portals

GateIn Cookbook's eighth chapter covers migration from an existing portal to GateIn and introduces JSR 329 ("Portlet 2.0 Bridge for JavaServerTM Faces 1.2 Specification"). One recipe in this chapter focuses on migration from JBoss Portal to GateIn and another recipe focuses on migration of a Liferay portlet to GateIn.

Chapter 9: Managing Gadgets

The ninth chapter of GateIn Cookbook introduces Gadgets and outlines the advantages of Gadgets. The recipes of this chapter make use of Google Gadgets. This is another image-heavy chapter showing different gadgets in place.

Chapter 10: Frameworks in a Portal

The tenth chapter of GateIn Cookbook discussed integration of frameworks with portal development and specifically focuses on use of JavaServer Faces (JSF). Other recipes also cover use of jQuery and RichFaces 4 with portlets.

Chapter 11: Managing Portal Resources with the Management Component

Chapter 11 introduces the management component and describes its purpose as "[enabling] portal resources to be managed over common interfaces such as RESTful Service interfaces, Command Line Interfaces (CLI), and portlets." The CRaSH-based tool CLI tool is demonstrated in a recipe as is exporting a page via a RESTful interface.

Chapter 12: Managing Documents Using External ECM Systems

The final chapter of GateIn Cookbook discusses "Creating a portlet" to integrate with four "Enterprise Content Management (ECM) systems": JBoss ModeShape, Apache JackRabbit, Alfresco using Spring WebScripts, and a Content Management Interoperability Services (CMIS) repository.

Conclusion

I only had a cursory knowledge of portals and portlets before reviewing GateIn Cookbook, but definitely feel more comfortable with those concepts after reviewing this book. It provides general information on portals and portlets with specific focus on implementing portals with GateIn. There are numerous screen snapshots and lots of code (mostly XML, but also Java, Groovy, JavaScript, and more). If I find myself using the GateIn Portal for my next application, GateIn Cookbook would be a good book to have on hand. I found my previous experience with Java, XML, and REST to be useful in more quickly understanding thebook's contents.

Thứ Năm, 9 tháng 8, 2012

Book Review: Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications

As I described in an earlier post, Packt Publishing invited me to review the book Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications. In this post, I provide a review of the strengths and weaknesses of this book along with an idea of the type of person who would gain the most from reading this book. Before doing that, I summarize the recipes covered in each chapter.

Chapter 1

The first chapter of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications covers portions of the Java EE specification that are changing names or being removed from the Java EE specification altogether before moving onto brief introductions of new things being added to the Java EE specification. The chapter covers the "pruning" of "old APIs" such as JAX-RPC (renamed JAX-WS), JAXR, entity EJB (replaced by JPA), JSR 77, and JSR 88.

New Java EE 6 features introduced briefly in this first chapter include JSR 175 and JSR 250 annotations, JSR 299 and JSR 330 Context Dependency Injection (CDI), EJB 3.1, Java Persistence API 2.0, JAX-RS 1.1, Servlet 3.0, JavaServer Faces 2.0, Bean Validation 1.0, and Profiles.

Chapter 2

The second chapter of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications provides more detailed coverage of JPA 2.0 introduced in the initial chapter. The chapter begins with more coverage of @CollectionTable and includes a couple recipes with quite a bit of code to demonstrate new JPA 2.0 functionality.

This second chapter also discusses profiling with JPA 2.0 and provides recipes using YourKit and IntelliJ IDE. This was probably my least favorite chapter in the book.

Chapter 3

Chapter 3 of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications is on "Security" and begins with an introduction of basic security-related terminology. The chapter also introduces GlassFish and Tomcat before covering authentication with Java EE. The chapter then moves onto authorization and specifying security settings via annotations. Significant attention is aid in this chapter to signing Java JARs before inclusion of a recipe on configuring Linux firewalls used with Tomcat.

The third chapter concludes with recipes on obfuscating and minimizing Java compiled code. I really like the example Groovy/Gradle script and equivalent Ant XML that show how to create an obfuscated JAR using yGuard. Another recipe demonstrates use of Yahoo's YUI Compressor to minimize JavaScript and CSS code size.

Chapter 4

Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications's fourth chapter is on "Enterprise Testing Strategies," a topic that can be a little tricky at times. The first recipe in this chapter demonstrates "how to attach a remote debugger process to a Maven build running outside of the IDE." This is another recipe that features Gradle in part of its example.

Another recipe in Chapter 4 examines use of DBUnit and JUnit with Enterprise Java applications. Each tool is introduced and I like the simple graphic that cleanly articulates the JUnit lifecycle.

The fourth chapter's examples build on examples introduced in the second chapter. The author starts by covering static imports of JUnit and Hamcrest classes.

Another recipe of Chapter 4 focuses on mocking and highlights use of Mockito and PowerMock. For the recipe on "testing HTTP endpoints," Selenium is the tool of choice. soapUI is used for the recipe on testing web services (JAX-WS and JAX-RS). The final recipe of the chapter builds on this and provides another great example of using Groovy in the development process.

Chapter 5

The fifth chapter of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications is on "Extending Enterprise Applications" and talks about use of Groovy, Jython, Scala, AspectJ, and "two standard Java EE 6 extensions" (CDI Decorators and Interceptors) with enterprise Java.

The recipe in this chapter on Groovy explains the scope of coverage: "we will not cover all the inner-workings of the Groovy language and all the benefits from this JVM language, but we will cover how to integrate Groovy into a new or existing Enterprise Application and how to use Groovy for unit testing." The Groovy recipe introduces GMaven and shows use of Groovy with Maven, Ant, and unit testing Java applications.

A recipe in Chapter 6 centered on Jython demonstrates "using Jython to create a Java Servlet and access Java classes from within the Jython script dynamically." The recipe focused on Scala, like the recipes in the same chapter on Groovy and Jython, starts with use of Maven. The recipe on Scala demonstrates using Scala for Java unit testing.

The recipe "Weaving AspectJ advice into Enterprise Applications" begins with descriptions of key aspect-oriented programming terms such as aspects, cross-cutting concerns, advice, pointcut, weaving, and joinpoint. This recipe briefly shows how to use AspectJ at compilation time. The next recipe, "Weaving AspectJ advice into existing libraries," demonstrates using AspectJ with pre-existing libraries and further discusses the AspectJ compiler (ajc).

The recipe "Adding advice with CDI Decorators" starts with discussion of interceptors in general before focusing on CDI decorators specifically. The recipe contrasts the common differentiating attributes of decorators versus interceptors: decorators implement business logic and intercept specific business methods while interceptors are more general and address cross-cutting concerns rather than implement specific business logic. CDI interceptors are the focus of the final recipe of the fifth chapter. Both CDI-related recipes of the fifth chapter include examples using JBoss's JSR 299 implementation (Weld).

Chapter 6

Chapter 6 of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications covers "recipes that touch on the issues, considerations, and options related to extending enterprise development efforts into mobile application development," but also starts with an important caveat: "With the mobile device and tool landscape changing daily, it will be difficult to cover certain specific implementations, but we can cover many of the options available and considerations that can be assessed when integrating mobile applications into an enterprise project."

As advertised, the sixth chapter provides an overview of considerations to be made in the mobile space and lists examples of and pros and cons of using "mobile-web framework projects", "native code generators", and "native web runtimes." The chapter then moves onto discussion of considerations to be made related to native mobile application development with focus on development, deployment, and distribution with Apple and Android.

Two recipes of the sixth chapter list some tools for mobile device application design and testing and there is an extensive recipe on "setting up a local Apache environment" with Tomcat using XAMPP. Chapter 6 concludes with a recipe on "native SDK development considerations" with focus on available IDEs and build management tools.

As the author pointed out early in the chapter, this sixth chapter is, in general, a higher level of explanation than is commonly associated with recipes. Software development recipe books and cookbooks tend to be example-focused and tend to be heavy on code with explanations of that code snippet. Many of the recipes in this same book follow that pattern, but Chapter 6 is definitely more text than code.

Chapter 7

The seventh chapter of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications returns to core Java EE coverage and focuses on deployment and configuration. This chapter is one of my favorites, which is not too surprising given that it includes Groovy and JMX in practical examples. The chapter starts with a JMX introduction and the statement, "The JMX recipes in this chapter are based on JDK 1.6 and VisualVM 1.3.3."

The first recipe of this chapter covers "how to implement application configuration with property files using the Contexts and Dependency Injection (CDI) APIs." The recipe looks at issues associated with using property files for application configuration and looks at how CDI can be used with properties to deal with some of these issues. Another recipe in the seventh chapter highlights advantages of using Groovy for configuration rather than properties files and provides an example using Groovy's ConfigSlurper in Java.

Chapter 7 contains four recipes focused on using JMX in conjunction with Tomcat and GlassFish with and without SSL. These recipes introduce JConsole and VisualVM (including debugging VisualVM connection issues) and demonstrate in detail how to use Tomcat and GlassFish with JMX on different operating systems. One recipe even introduces the Windows tool cacls.

One of Chapter 7's recipes focuses on JRebel and uses this in conjunction with IntelliJ IDEA IDE.

Chapter 8

The final chapter of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications is on "performance and debugging" and is one of my other favorite chapters in the book. VisualVM is heavily covered again in recipes in this chapter, this time for profiling memory consumption in conjunction with the VisualGC VisualVM plugin and for remote profiling with jstatd.

The relatively well-known netstat tool gets covered in a Chapter 8 recipe. This recipe introduces the basics of processes and threads and contrasts the two and briefly summarizes socket states as preparation for the remainder of the recipe. The recipe concludes with coverage of other "netstat tools" NetStat Agent and TCPView.

Chapter 8 includes additional recipes that demonstrate "how to leverage TCPMon to debug TCP connections", demonstrate "how to install and configure Munin to monitor computer resources and a Tomcat application server," and demonstrate how to "leverage HTTP Debugger to trace client and server-based requests and responses."

Overall Impressions

As with all books, Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications has its pros and cons. As is also the case with most books, certain attributes of this book are pros to one reader and cons to a different reader. Given this, I'll cite things I liked and did not like about the book, but I understand that some of the things I like will not be to others' liking and some of the things I did not like might be welcome to other readers.

  • Not Your Typical Java EE Book - Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications is not the typical Java EE book. Although it does provide coverage of core new features of Java EE 6 in its early chapters, its focus is generally on use of tools and scripts to do exactly what the title describes: secure, tune, and extend Java EE-based enterprise applications. This is not the book one learns about the basics of EJBs, servlets, JavaServer Faces, JMS, or other Java EE technologies. In my opinion, this is a good thing and is what perhaps separates this book most from other Java EE 6 books.
  • Name Dropping - One of my favorite aspects of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications is its broad coverage of interesting and useful tools used in Enterprise Java development and production. This book does more than just drop the names. It provides summaries of what each tool offers and shows realistic and meaningful uses of that tool for improving the enterprise development experience. I tried to reference several of this book's referenced tools in this post to provide a flavor of its breadth of coverage of tools. The recipes each end with a list of references for additional information on the tools discussed in that recipe.
  • Use of Groovy - Although Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications features numerous tools and techniques, I think its coverage of Groovy is particularly well done and provides solid examples of how Groovy can improve the Java developer's ability to write scripts.
  • Different Operating Systems - I liked that this book generally focuses on solutions and tools that apply to many major operating systems and often provides specific details on use of a recipe on each of these different operating systems.
  • Lots of Pictures - In keeping with something I've come to expect in Packt Publishing books, this book continues the trend of featuring numerous screen snapshots to illustrate points.
  • Repetition - Several closely related recipes include similar or even identical text to one another. For the typical reader of a cookbook or recipe-oriented book, this is welcome because it can be distracting and even irritating to be referred to a separate recipe if one is only interested in how to accomplish a single recipe. I read the book from cover to cover rather than focusing on particular individual recipes as they interested me and so was more cognizant of the occasional repeated text.
  • Different Backgrounds - One of the challenges facing the author of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications must have been addressing his audience at the appropriate level. I think most chapters and recipes deliver well on this, providing enough information to introduce the reader to useful tools and approaches for working with Java EE applications and only relying only minimal knowledge of Java EE. The one exception to this is Chapter 2, which I feel assumes quite a bit of JPA-specific knowledge to be appreciated. The good news is that, in the tradition of recipe-oriented books, understanding of Chapter 2 is generally (with a few exceptions) not required for appreciating the other chapters. Chapters 7 and 8, on the other hand, might be as useful to Java EE developers as they are to Java EE developers.
  • Typos, Editing, and Formatting - I reviewed an electronic (PDF) version of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications and do not know if the printed version has the same typo and editing issues that I occasionally saw in the PDF version. At times, the PDF version of the book feels like it missed a final edit. In general, these are only slightly distracting and rarely provide any significant distraction.
The Target Audience

The "Who this book is for" section of the Preface of Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications states, "This book is aimed at Java developers and programmers who want to secure, tune, and extend their Java EE applications." This articulates well the primary audience for this book, though I think that Java SE developers could benefit from several of the recipes and chapters in this book as well.

The "What you need for this book" section of the Preface also says of the book's audience, "The recipes in this book are of an intermediate to advance nature, so a good understanding of Java is required." The book definitely assumes basic familiarity with Java (SE and EE), but some recipes require this experience more than others.

Idea Generation

For me, the best thing about Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications is its introduction to a wide variety of topics, tools, and ideas. Even recipes that I might have no direct use for at this time provide value because they demonstrate use of tools for accomplishing various administrative tasks. I found myself thinking of related but different uses for some of the tools and approaches discussed in this book.

Related Links (External Sites)

The following are some other sources of information about the book Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications.

Thứ Bảy, 14 tháng 7, 2012

Initial Peek at Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications

Packt Publishing recently invited me to review Mick Knutson's (@mickknutson) book Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications. I intend to provide a comprehensive review in a later post after I've had a chance to read the book, but an idea of what the book covers can be found in its Table of Contents.

In roughly 320 pages, this book appears to cover a wide gamut of topics and tools. It appears to cover several Java EE specifications with focus on what's new to Java EE 6 (such as EJB 3.1, JPA 2.0, Servlet 3.0, and JAX-RS 1.1). It also appears to cover numerous tools and non-Java languages. For example, it appears to cover use of Groovy, Scala, Jython, JMX, VisualVM, and several other (including commercial) tools and products.

I'm looking forward to reading Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications and providing my thoughts and observations about the book in a future post.

Thứ Hai, 9 tháng 7, 2012

Book Review: The Well-Grounded Java Developer

Java-related books are perhaps the most widely available books in terms of diverse selections of any programming language. Even so, most Java books seem to fall into one of two categories: they are either introductory/general level books or they are highly focused specific books. These books all have their place and many of them have been beneficial to me in my career, but I'm always on the look out for that rare combination of the two: the book that is relatively general in terms of Java coverage, but is more advanced or looks at the topic quite differently than an introductory or typical general Java book. Books such as Effective Java and Java: The Good Parts come to mind as books that strive to hit this sweet spot. In this book review, I look at soon-to-be-released (in print, with electronic version available already) The Well-Grounded Java Developer, a book whose topic selection has interested me since first hearing about it in early 2011.

The initial paragraph of the "About This Book" section summarizes the authors' intent:

Welcome to The Well-Grounded Java Developer. This book is aimed at turning you into a Java developer for the modern age, reigniting your passion for both the language and platform. Along the way, you’ll discover new Java 7 features, ensure that you’re familiar with essential modern software techniques (such as dependency injection, testdriven development, and continuous integration), and start to explore the brave new world of non-Java languages on the JVM.

The authors of The Well-Grounded Java Developer, Ben Evans and Martijn Verburg, are instrumental players in the London Java Community, a member of the Java SE/EE Executive Committee in the Java Community Process. Both also speak at Java-related conferences with Martijn being well-known as the Diabolical Developer and Ben Evans as "the voice of reason?"

The title of the book and the selection of topics are what appealed to me most about the advertised content of The Well-Grounded Java Developer when I first saw its Table of Contents in the early MEAP edition. The chosen topics seem appropriate for experienced Java developers who are too busy developing solutions for their customers to spend time trying out features of Java 7, delving deeply into the intricacies of Java and the JVM, or playing with the major alternative JVM languages. I have worked with many solid Java developers who are great at Java, but don't have the time or inclination to play with the latest versions of Java or with JVM languages other than Java until or unless they need to for their job role. This book is a perfect quick introduction to these topics for such developers. A single book provides the highlights of Java SE 7 along with introduction material related to the three most popular non-Java JVM languages. It also throws in in-depth coverage of some advanced topics for making good Java developers better. In addition, the book includes information on modern Java development tools.

The Well-Grounded Java Developer is divided into four multi-chapter parts along with five appendices. Part 1 ("Developing with Java 7") introduces new features of Java SE 7 with focus on Project Coin (Chapter 1) and NIO.2 (Chapter 2).

Part 1 : Java 7

Chapter 1 ("Introducing Java 7") briefly discusses Java the language and Java the platform along with other general characteristics of the Java programming language (open source now, compiled or interpreted nature, etc.). The remainder of the first chapter covers various Project Coin features including switching on String, enhanced numeric literal syntax, improved exception handling, try-with-resources (automatic resource management), diamond operator syntax, and simplified variable arguments.

Chapter 2 ("New I/O") provides brief overview and history of NIO in Java before delving into details of Java 7's NIO.2. The chapter introduces NIO.2 via the all-important Path interface and looks at how this new interface enables improved file input/output (with Files class and other handy new files handling mechanisms).

Part 2 : Vital Techniques

Part 2 ("Vital Techniques") of The Well-Grounded Java Developer continues covering new Java 7 features, but the focus is shifted from the first part. In the first part, the focus was on the features new to Java 7. In the second part, other features new to Java 7 are covered, but in this part they are covered as a means to a different end than simply introducing new Java 7 features. The intent of this second part is to provide more in-depth coverage of "vital techniques" that Java developers should know. As the introduction to this part states, it is about "exploring vital programming knowledge and techniques with Java." These "vital techniques" are dependency injection (Chapter 3), concurrency (Chapter 4), class files and bytecode (Chapter 5), and performance tuning (Chapter 6).

Although there are great books devoted to some of these topics covered in Part 2 (Java Concurrency in Practice and Java Performance for example), many Java developers don't have the time, interest, or inclination to purchase and read these books. These chapters help to get a Java developer going with these ideas and more comprehensive books can be referenced when more comfortable with the subject or when more details are needed.

Chapter 3 ("Dependency Injection") provides an introduction to dependency injection (DI) and contrasts it with the encompassing concept of inversion of control (IoC). The chapter introduces JSR 330 ("Dependency Injection for Java") and discusses using Google Guice as an implementation of JSR 330.

The introduction to Chapter 4 ("Modern Concurrency") includes this description of the intent of the chapter:

The aim of this chapter is to make you aware of the underlying platform mechanisms that explain why Java’s concurrency works the way it does. We’ll also cover enough general concurrency theory to give you the vocabulary to understand the issues involved, and to teach you about both the necessity and the difficulty involved in getting concurrency right.

Chapter 5 ("Class Files and Bytecode") is one of the book's chapters that I think can be of most value to the highest percentage of intermediate to advanced Java developers. Classloading is one of the most frustrating issues in Java development and the fifth chapter attacks that topic head-on. A feature new to Java 7, method handles, are then covered. Method handles are described in this chapter as the "new Java 7 way to achieve the same ends [as the Java Reflection API], with much cleaner code."

When I reviewed the book Java Reflection in Action, I noted that one of its few weaknesses was its age (2004/JDK 1.4) and I concluded that "the most glaring omission from a book on Java reflection is Java 7's introduction of method handles, but few Java books in print today cover these." The Well-Grounded Java Developer is a welcome exception to this statement with an entire section (5.2) devoted to the topic.

I've been a big fan of the javap tool ("Java Class File Disassembler") that comes with the HotSpot SDK, but one of the things that has made it more difficult to learn to use that tool effectively is lack of easily accessible documentation on it. Section 5.3 ("Examining Class Files") of the fifth chapter goes a long way toward remedying that deficiency. Besides introducing javap, the ambitious 5.3 section also covers reading bytecode. This chapter is dense with detail, but this is welcome detail and a great introduction to the subject.

The final section of Chapter 5 (Section 5.5 on "invokedynamic") introduces Java 7's invokedynamic. The introduction to the section notes where this subject likely likes in terms of interest to general Java developers:

[invokedynamic] isn’t a feature that will necessarily be used directly by every working developer, because it involves a very advanced use case. This feature is for frameworks developers and non-Java languages at present.

Chapter 6 ("Understanding Performance Tuning") introduces Java and JVM performance tuning by reminding the reader that performance tuning is often not necessary and depends on measurement with realistic loads. The chapter provides definitions of performance-related terminology and introduces "a pragmatic approach to performance analysis." This sixth chapter also discusses the garbage collection in more details than most Java developers are probably aware of and introduces some of the Oracle (HotSpot) JVM options that can be used.

Chapter 6 also introduces another Oracle JVM command-line tool (jmap) ["Memory Map"] and provides descriptive text on how to read jmap's output (similar to approach used with javap coverage in Chapter 5).

Part 3 : Alternative JVM Languages

Part 3 ("Polyglot Programming on the JVM") moves beyond the Java programming language and focuses on alternative languages running on the JVM. The authors point out that learning about these alternative JVM languages can be useful to Java developers because "many of the new ideas that will be needed in the future are present in other JVM languages today." I'll also add that, at least in the case of Groovy, I've found it useful already for things where Java is not as strong (scripting).

Chapter 7 ("Alternative JVM Languages") introduces this third part of the book focused on alternative JVM languages. This chapter covers why one would be interested in an alternative JVM language before delving into how alternative JVM languages can be used to support functional programming concepts on the JVM. The chapter outlines different ways to classify non-Java JVM languages such as interpreted versus compiled, statically typed versus dynamically typed, and imperative versus functional. The chapter also contrasts completely new languages designed for the JVM (Groovy, Scala, Clojure) with "reimplementation" languages (pre-existing languages ported to the JVM such as Jython, JRuby, and Rhino).

Chapter 7 provides information on how to decide which alternative JVM language to choose for different situations. The authors quickly introduce the non-Java JVM languages that each get a chapter's focus (Groovy, Scala, and Clojure) and explain why they selected these languages upon which to focus.

We’ve picked three languages that we see having the greatest potential longevity and influence. These are the languages on the JVM (Groovy, Scala, and Clojure) that already have well-established mind share among polyglot programmers.

After Chapter 7 kicks off Part 3 on polygot programming on the JVM, the next three chapters of Part 3 each focus on a specific alternative JVM language: Chapter 8 ("Groovy: Java’s dynamic friend"), Chapter 9 ("Scala: powerful and concise"), and Chapter 10 ("Clojure: safer programming"). Each of these three chapters provides an overview of the respective alternative JVM languages. Of course, a single chapter is not sufficient to comprehensively introduce a programming language, so these chapters focus on the strengths of each covered language. They also cover things such as Java interoperability (for Groovy and Clojure) and use contrasting of the languages with Java to illustrate language features.

Part 4 : Applying Alternative Language and New Java Techniques and Tools

Part 4 ("Crafting the Polyglot Project") applies information covered earlier in the book to "some of the most common and important techniques in modern software development." Three of the four chapters in this part look at modern software development techniques (test-driven development, building/continuous integration, and rapid web development). The concluding chapter of the fourth part looks at what the future holds for Java.

Chapter 11 ("Test-Driven Development") introduces TDD, JUnit, Mockito, and ScalaTest. This chapter also looks at different ways to implement "test doubles" (dummy, stub, fake, mock). Chapter 12 ("Build and Continuous Integration") introduces tools Maven 3, Jenkins, FindBugs, Checkstyle, and Leiningen (for Clojure projects).

Chapter 13 ("Rapid web development") covers issues with developing web applications using Java. It looks at several different popular Java web frameworks before focusing specifically on Grails (Groovy) and Compojure (Clojure).

Chapter 14 ("Staying Well-Grounded") begins with the sentence, "To stay ahead of the curve, the well-grounded Java developer should always be aware of what’s coming around the corner." This chapter then looks at the authors' perspective on the future of Java. The authors cover Java 8 with specific focus on the two most significant features of that version: lambda expressions and Jigsaw modularity. The chapter also looks at JVM changes making polygot programming easier and more productive and at improved concurrency support. It ends by looking at other JVM trends.

Appendices : Background / Supporting Information

Besides the four parts with 14 chapters, The Well-Grounded Java Developer also includes five appendices: Appendix A ("Java7developer - source code installation"), Appendix B ("Glob pattern syntax and examples"), Appendix C ("Installing alternative JVM languages"), Appendix D ("Downloading and installing Jenkins"), and Appendix E ("Java7developer - the Maven POM"). These appendices provide example code related to the book as well as other useful reference information related to topics covered in the book.

The Book's Audience

The Well-Grounded Java Developer hits its goal of being aimed at and primarily beneficial for the Java developer who wants to be a "well-grounded Java developer." Newer Java developers can learn much about basic tools, techniques, and approaches in Java. Moderately experienced Java developers are likely to pick up new tools and techniques or to gain a better and deeper understanding of principles about the Java language and about the JVM.

Most experienced Java developers will likely find much to learn from this book, especially if they are too busy developing applications to spend the time trying out three alternative JVM languages along with the new features of Java in Java 7 and Java 8. I know several Java developers who I consider very experienced and even they would benefit from some of the low-level details this book provides. For example, the sections on javap and jmap are as good as introductions and concise reference as I've seen for those respective Oracle JVM tools.

Although I think nearly all Java developers can learn new things, new approaches, and new techniques from The Well-Grounded Java Developer, I think the book is particularly well-suited for the Java developer who feels comfortable with Java, but has not had a lot of time in recent years to come up to speed on the popular alternative JVM languages or the features of Java 7 and 8 (closures and modularity). This book can provide a quick "tune-up" to bring these experienced Java developers up to speed on the latest happenings.

Disclaimer

It is trendy currently to talk about how "transparent" one is. In an effort to fit in with this trend, I must acknowledge here factors that might be misconstrued as affecting my judgment. First, the authors have kindly included a reference to my blog post on Groovy JSON support in The Well-Grounded Java Developer. This is a book that I'm very happy to have my name and my blog associated with and that may prove my opinion of this book more than anything else.

A second potential conflict of interest that one might misconstrue to affect my judgment is author Martijn Verburg's (@karianna) tweet-out of my Twitter handle (@DustinMarx). That single tweet increased the number of people "following" me on Twitter by several times my previous number. However, I had planned to write this review and had the general gist of it in mind well before this Tweet.

Manning Early Access Program (MEAP)

I enjoyed having access to portions of The Well-Grounded Java Developer earlier than its formal publication via the Manning Early Access Program. This is an especially valuable program when the forthcoming book is on subjects that are very new (such as Java 7).

The Downsides

The Well-Grounded Java Developer's primary downsides are related to the fact that it cannot be everything to everyone (nothing can!). The book is great at helping Java developers kick-start their efforts at becoming well-grounded. However, as the authors acknowledge multiple times in the book, many of the subjects will require additional reading of other sources for more details on subjects introduced in this book. Also, the book cannot possibly cover every "new" thing coming to the world of Java. For example, JavaFX is not mentioned in the book, though the current Java.net poll may end up indicating that JavaFX may not have yet earned enough community-wide respect and acceptance to warrant such a mention.

Conclusion

I was excited about the prospect of The Well-Grounded Java Developer when I initially read about it and it has delivered to a level matching even those high expectations. This is that rare book I'm always on the lookout for that stretches me as a general Java developer. Many highly-focused and specific Java-related books do this for me in one area of Java, but this book helped me to learn and realize things in several different aspects of Java and the JVM.

I have used Java for many years and was a fairly early adopter of Java 7. I have also been a huge fan of Groovy for a while now and I read and write blogs frequently, but I still found numerous details and insights in this book that I had not thought about previously. I work with many great Java developers who spend far less time reading blogs, working with alternative JVM languages, or trying out new features of Java and I'd expect them to gain even more useful insights from reading The Well-Grounded Java Developer. As Dr. Heinz Kabutz wrote in the book's forward, "Studying this book will help you become a well-grounded Java developer. Not only that, it will give you tips on how to stay well-grounded." This book comes from a great idea and is an example of where a delivered product meets the lofty expectations of the original idea.

Thứ Bảy, 25 tháng 2, 2012

Book Review: Java Reflection in Action

The book Java Reflection in Action was published in 2004, but remains largely applicable eight years later. In this post, I review this book and cover its strengths and its weaknesses. In general, age is the common theme of most of its weaknesses, but I was surprised at how relevant its information still is. The book was written when JDK 1.4 was the commonly used release of Java and J2SE 5 was well on its way (released late September 2004). Given this relative timing, it's obvious that where this book suffers is in coverage of reflection-related features made available after the release of JDK 1.4.

Java reflection is a topic that most Java developers use on a daily basis, either directly or indirectly via popular frameworks and libraries that make use of reflection. However, it is probably true that many of us could use reflection to good effect in even more ways. For example, I have found reflection to be useful in writing Groovy scripts to manage Java application development.

Java Reflection in Action is written by the father/son team of Ira R. Forman and Nate Forman. It consists of ten chapters and is under 300 pages long. It's a quick read and one can understand the basics of Java reflection after reading only the first three chapters.

Chapter One ("A few basics"), Chapter Two ("Accessing fields reflectively"), and Chapter Three ("Dynamic loading and reflective construction") cover the basics of Java reflection. The contents of these three chapters are what most people probably expect in a book on Java reflection. Reading these three chapters alone provides the Java developer with the basics of Java reflection, including the advantages and some pitfalls of using reflection. These chapters provide detailed coverage of the most important reflection APIs and focus on constructing instances of Java classes and introspecting method and field information.

Early pages of Java Reflection in Action provide nice reflection-oriented definitions. For example, reflection is defined as "the ability of a running program to examine itself and its software environment, and to change what it does depending on what it finds" (p. 3). Introspection is defined as "reflective features that allow a program to examine itself" (p. 7) and metaobjects are defined as "objects that are part of a program's self-representation" (p. 9).

Chapter Four ("Using Java's dynamic proxy") is devoted to coverage of Java's dynamic proxies. This chapter states that java.lang.reflect.Proxy is "Java's only way of approximating method invocation intercession." The chapter defines intercession as "any reflective ability that modifies the behavior of the program by directly taking control of that behavior." This is one of the best treatments of dynamic proxies that I've seen.

Chapter Five ("Call stack introspection") covers use of StackTraceElement to provide introspection capabilities against the call stack (feature available since JDK 1.4). The authors point out that this is an approach for performing introspection on "execution state of the running application" (versus much of the commonly considered reflection that focuses on introspection of structure). The authors demonstrate accessing these stack trace elements via the Throwable.getStackTrace() call. Although this is still the approach for acquiring a stack's elements recommended in the Javadoc documentation for StackTraceElement, I prefer using Thread.getStackTrace() approach (see my blog post The Surprisingly Simple StackTraceElement), which was not made available until J2SE 5.

Chapter Six ("Using the class loader") provides nice coverage of Java class loaders. This is another subject that Java developers frequently run into directly and indirectly. The chapter provides a nice introduction to class loading in Java. Section 6.3 ("Multiple namespaces") provides information on a subject that Java developers definitely need to be aware of even when only using class loaders indirectly. This section explains that "a class object in the virtual machine is actually identified by both its fully qualified name and defining loader" (I added the emphasis).

Chapter Seven ("Reflective code generation") and Chapter Eight ("Design patterns") discuss using reflection capabilities to generate code. Specifically these chapters focus on using reflective capabilities to transform source classes into target classes. Specific design patterns applied to new classes that are implemented via transformation from existing source via reflective capabilities.

The Reflection API Trail of the Java Tutorials warns of "performance overhead" in its list of "reflection drawbacks." Chapter Nine ("Evaluating performance") of Java Reflection in Action addresses real and perceived performance issues related to reflection. Perhaps more importantly, the chapter provides ideas and issues related to the notoriously difficult application of micro-benchmarking. Besides covering micro-benchmarking itself, this chapter also introduces Amdahl's Law and reinforces use of proxies.

The first paragraph of the "Summary" of Chapter 10 made me think again about some of my preconceptions about Java reflection performance. This paragraph states (pp. 223-224):

Runtime performance is often cited as a disadvantage that renders reflection APIs impractical. Don't be taken in by this argument. Reflection is not slow! Over the first 50 years of software engineering, similar arguments were made against the move to high-level languages, against the move to virtual memory, against the move to object-oriented programming, and, most recently, against the move to garbage collection.

Chapter Ten ("Reflecting on the future") is, not surprisingly, the chapter made most obsolescent by the passage of time. Hindsight being 20/20, it is easy to see things missed in the Formans' predictions and speculation for the future of Java reflection. However, when one remembers that the book was published in 2004 before the general release of J2SE 5, this chapter's obsolescence is easily understood. The chapter specifically discusses the impact on reflection of several J2SE features we are now use regularly such as annotations, generics, and JSR 201 language extensions (Enums, for-each loop, static imports, and the cursed [my words] autoboxing). The chapter talks about other languages' likely advancements in reflection capabilities and provides a very brief introduction to aspect-oriented programming.

Java Reflection in Action packs a lot of information into its three appendices. Appendix A is the largest of the three and provides a description of "reflection and metaobject protocols and the relationship between the two." There is a two-page appendix devoted to basic UML (which is applied several times within the book) as well as appendix covering possible compilation problems of one of the book's basic code generation examples on certain operating systems versions.

Java Reflection in Action includes a lengthy list of authoritative references (nearly 100) for additional reading related to the topics covered in the book. It also provides a short glossary of key terms in reflection.

One of the book's most practical positive features is its supplying of a small set of static Java functions for making reflection tasks easier. Provided as part of the often referenced Mopex class (in the mopex package), this code is available for download from the Manning site for the book. The Mopex's class-level documentation describes the class: "This class provides a set of static methods that extend the Java metaobject protocol." The downloaded code samples include many more classes and code definitions used in the book as well.

Conclusion

Java Reflection in Action provides a thorough introduction to Java reflection. It features many positive aspects and its main negative aspect is its age (2004/JDK 1.4). Because versions of Java since JDK 1.4 have supplemented more than replaced reflective features, most of the book's content still applies today. Perhaps the most glaring omission from a book on Java reflection is Java 7's introduction of method handles, but few Java books in print today cover these.

Thứ Ba, 31 tháng 1, 2012

Book Review: JBoss AS 7: Configuration, Deployment, and Administration

I eagerly accepted Packt Publishing's invitation to review JBoss AS 7: Configuration, Deployment, and Administration because it has been several years since I last used JBoss and I was curious to learn more about JBoss AS 7. I have already written about my First Impressions of Book 'JBoss AS 7 Configuration, Deployment and Administration' and in this post I review the book in greater detail while attempting to minimize how much I repeat from that post. My review is based on an electronic (PDF) copy of JBoss AS 7: Configuration, Deployment, and Administration.

General Features

JBoss AS 7: Configuration, Deployment, and Administration highlights particularly important notes and warnings within boxing that makes them obvious and with an icon representing a pencil and paper. Similarly, tips and tricks also attract special attention with similar boxing and with a light bulb icon. It is helpful to have the most important notes and tips and tricks highlighted like this.

It didn't take much reading of this book to realize how significantly new JBoss AS 7's architecture is. One of the strengths of JBoss AS 7: Configuration, Deployment, and Administration is its comparisons of previous versions of JBoss AS to JBoss AS 7. These comparisons help to understand how changed JBoss AS 7 is and should be especially helpful to anyone migrating to JBoss AS 7 from a previous version.

This book provides several tables of various configuration options and their descriptions. These tables provide easy reference for various configuration options. Although I mostly just skimmed these as I read this book, I noted their existence for future reference when configuring various parts of JBoss AS 7.

Command line interfaces and script-based configuration and administration are emphasized throughout the book. I appreciate this because I tend to use command line approaches far more frequently than I use graphical tools, but some books focus almost exclusively on the graphical tools.

Perhaps the greatest strength of JBoss AS 7: Configuration, Deployment, and Administration is its focus on what its title promises: configuration, deployment, and administration. Although this book does provide brief introductory details about Java EE, the book assumes that the reader will look to focused books or tutorials for detailed information on Java EE. This allows the book to focus on administration and configuration of and deployment to JBoss AS 7.

Although examples in the book specifically use Eclipse, MySQL, and Windows, the descriptions and explanations are broad enough to cover other choices of IDE, database, and operating system respectively. The illustrations assuming one of these are relatively rare and most of the discussion is more general to JBoss AS 7 rather than to any of these supporting products. In many of these cases, alternatives (and how to use those alternatives) are mentioned. The final chapter (cloud computing with OpenShift) and the Appendix (common commands and operations) provide Linux-based examples.

There is a small number of typos and a few instances of questionable sentence structure, but the author's writing style generally flows easily and is easy to follow. There are numerous drawings, tables, and screen snapshots to illustrate points and highlight the more important details. I like the significant white space and the call outs for special notes and observations.

Chapter 1: Installing JBoss AS 7

Because I have not used JBoss for several years, I needed to install JBoss AS 7 and this chapter provides an easy guide to doing that. The chapter begins with brief coverage of the usefulness of Java EE application servers and of JBoss AS 7's high-level design. It then moves into the practical steps necessary for installing JBoss AS 7. The author recommends in one of the "important notes" that readers download and use the Java 6 SDK, but does acknowledge that Java SE 7 SDK is available and should work fine with JBoss AS 7. The chapter discusses installation on Windows and Linux/Unix and even includes a "tip/trick" highlighting of installation on Windows Vista. The chapter goes beyond basic installation (which amounts to uncompressing archive files) to discuss starting and stopping JBoss AS 7 and using Command Line Interface (CLI) to connect to it locally and remotely.

The initial chapter also discusses installation of Eclipse ("the development environment used in this book"). Besides downloading and installing Eclipse (Indigo), the chapter also discusses installation of the JBoss AS plugins (part of JBoss Tools) for Eclipse.

One of my favorite parts of this initial chapter is its coverage of the application server's directory structure and differentiation of JBoss AS 7's "standalone servers and domain servers." This was an important distinction for me coming back to JBoss after such a long period of time, but was an easy one to grasp because of my familiarity with GlassFish. After differentiating between the types of servers supported in JBoss AS 7, the section concludes with coverage of several significant directories/folders in the JBoss AS 7 installation.

Chapter 2: Configuring the Application Server

With JBoss AS 7 and tools (Eclipse) installed, it is natural to move onto configuring the JBoss AS 7 instance. This chapter had some surprises for me, including starting with this: "The application configuration has also been renewed, moving from a large set of XML files to a single monolithic file." The chapter discusses this single file and covers its default names (depending on server configuration). It goes through the configuration file one major section at a time, detailing how to configure the server in each area. There is quite a bit in this chapter on configuring logging. Another thing I learned here that has changed in JBoss in recent years is default use of its own logging framework.

Chapter 3: Configuring Enterprise Services

The third chapter is on configuring enterprise services. This chapter specifically focuses on configuring database connectivity, EJB container, messaging service, and transaction service.

The section of Chapter 3 on configuring database connectivity mentions that JBoss AS 7 comes with the H2 open source database server built in, but then uses MySQL for its examples. I liked how this chapter compared and contrasted how database configuration was performed in previous versions of JBoss AS to how it is now done in JBoss AS 7. The chapter demonstrates XML-based configuration of a data source (and how it was similar to that used in previous versions of the JBoss application server), but then also shows how to use the Java EE 6 annotation @DataSourceDefinition to programmatically configure the data source in conjunction with an EJB 3.1 Singleton EJB.

Chapter 3's section on configuring the EJB container starts by introducing the basics of EJBs with specific introductory focus on the "new EJB 3.1 variants introduced by Java EE 6": Singleton EJB, No-Interface EJB, and Asynchronous EJB. The chapter discusses in detail how to configure the different types of EJBs. It also points out the built-in JMS support in JBoss AS 7 provided by HornetQ. It also covers configuration related to JBoss AS 7's/HornetQ's use of Netty.

The section of Chapter 3 on configuring transactions introduces the Java Transaction API. It then explains how to configure the JTA support for timeouts and statistics gathering.

Chapter 4: JBoss Web Server Configuration

The focus of the fourth chapter of JBoss AS 7: Configuration, Deployment, and Administration is on configuration of the JBoss web server (JBoss Web), which is based on a fork of Tomcat 7. The chapter discusses HTTP connectors, including JBoss Web's built-in Coyote HTTP 1.1 connector and the Apache Portable Runtime (APR) connector. The chapter shows how to separately download and use the ARP connector with JBoss AS 7.

The chapter of JBoss Web server covers configuration of static (HTML/images) and dynamic (JSP) resources and then moves onto discussion of deploying JavaServer Faces (JSF)-based applications on JBoss AS 7. The author points out: "Currently, JBoss AS 7 supports the JSF release 2.1 using the Mojarra implementation, although there are plans for supporting MyFaces implementation too." The chapter then demonstrates using Eclipse to create a JSF project and adding an EJB layer to that application. The chapter also demonstrates adding JPA-based persistence (including how to switch the JPA provider from default Hibernate 4), setting a custom web context, and deploying the web application.

Chapter 5: Configuring a JBoss AS Domain

The fifth chapter concludes the chapters on configuration by providing a more detailed look at configuring JBoss AS 7 domains. Of particular interest to me is the sections on configuring the JVM and providing JVM options. I also found the author's use of VisualVM to be helpful. This detailed chapter introduces domain terminology, explains what a domain is, and explains why a domain does not provide the same functionality or purpose as node clustering. It provides thorough detail on configuring domains.

Chapter 6: Deploying Applications on JBoss AS 7

Deployment to JBoss AS 7 is the focus of Chapter 6. The chapter begins with an introduction to JAR, WAR, EAR, RAR, and SAR files and then goes onto more detailed (but still thankfully brief) coverage of the first three types of archive files.

After covering JAR, WAR, and EAR, the chapter moves onto coverage of manual and automatic deployments to JBoss AS 7. I was happy to see coverage of using CLI to deploy from the command line, but fans of deploying via web page will be happy to know that there is also coverage of deploying from the web administration console. The chapter also demonstrates deploying from the Eclipse IDE.

The most significant bane of my Java development experience has probably been classloaders, which become tricky when application servers, IDEs, and frameworks like Spring are involved. With this in mind, I was happy to see a section in the sixth chapter called "JBoss AS 7 classloading explained." Several pages are devoted to using JBoss's provided mechanism for appropriately dealing with classes used by the application server as well as the deployed applications. The chapter also talks about using Java EE's standard approach of specifying Class-Path in the MANIFEST.MF file.

Chapter 7: Managing the Application Server

The seventh chapter focuses on managing JBoss AS 7 via the command line-based CLI tool and the web-based Web admin console. Differentiation is made between CLI commands and CLI operations. I find the sections "Executing CLI scripts in batch" and "Executing scripts in a file" to be particularly interesting from a CLI perspective. The first section talks about CLI support for a group of commands as an atomic unit and the second section talks about writing file-based administration scripts. The book further peaks my interest in CLI by explaining how to take snapshots in CLI and how to display CLI history.

Although I find that I use command line-based tools for configuration, administration, and deployment of an application server in the long-run, web-based or other graphically-oriented tools are often nice when first using an application server or when trying to figure new things out. In other words, I prefer command line scripting for routine tasks and prefer graphically-oriented administrative tools for new or unusual tasks. The second half of Chapter 7 covers using "The new Web admin console."

Chapter 7's coverage of the history of JBoss's web administrative consoles is a good example of how the overall book does a nice job of comparing and contrasting different versions of JBoss tools. The chapter points out the advantages and limitations of the jmx-console approach (versions of JBoss up to JBoss 4.x) and the Seam-based Web admin console (JBoss 5.x and 6.x) before covering JBoss AS 7's GWT-based Web admin console. As one would expect, the section on Web admin console is filled with screen snapshots demonstrating the Web admin console in action.

Chapter 8: Clustering

One of the things many of us want from our application server is clustering functionality, which is the theme of Chapter 8 (load balancing of web applications is covered in the next chapter). The chapter points out several facets of clustering that have changed in JBoss AS 7. It also covers how JGroups and Infinispan are used to implement JBoss clustering. This is an information--packed chapter that I will be sure to read again before using JBoss AS 7 clustering.

Chapter 9: Load-balancing Web Applications

Chapter 9 covers load-balancing of web applications. The chapter only briefly covers installation of Tomcat's mod_jk and Apache's mod_proxy to connect the Apache web server to JBoss AS 7 because "the installation of either mod_jk or mod_proxy does not differ from earlier AS releases." The remainder of the chapter focused on load balancing covers mod_cluster (new to JBoss AS 7). The chapter concludes by returning to discussion of clustering. The author references the JBoss AS 7.1 High Availability Guide for continuing developments related to JBoss AS 7's clustering support.

Chapter 10: Securing JBoss AS 7

Chapter 10 of JBoss AS 7: Configuration, Deployment, and Administration is focused on security, an increasingly popular topic. Reading about security is often my best cure for insomnia, but there were some interesting nuggets in this chapter that kept my attention.

The chapter introduces PicketBox (formerly known as JBoss Security), the security framework upon which JBoss AS 7's security is built. It then provides a basic overview of Java's security API and provide definitions of key security terms in a Java EE context. This thorough chapter covers a wide range of security-related topics as they pertain to JBoss AS 7.

Chapter 11: Taking JBoss AS 7 in the Cloud

The final chapter is devoted to the trendiest topic of them all: cloud computing. The central focus of this chapter is Red Hat's OpenShift (PaaS). The author does as good a job as I have seen of describing cloud computing and I particularly liked the contrasting of cloud computing to grid computing. The majority of the chapter discusses starting with OpenShift Express and then transitioning to OpenShift Flex.

Appendix

The Appendix is six pages of "common commands and operations" that provides an easy access reference. Although the shown commands use Linux script jboss-admin.sh, the alternative for Windows (jboss-admin.bat) is shown at the beginning of the appendix. The subsections of the appendix are Startup Options, General Commands, Domain Mode, JMS, Data sources, mod_cluster, Batch, and Snapshots.

Conclusion

JBoss AS 7: Configuration, Deployment, and Administration delivers what it's title promises: an introduction and in-depth coverage of configuring and administrating and deploying to JBoss AS 7. Along the way, the book manages to provide differences in JBoss AS 7 from previous versions and to provide introductory details about aspects of Java EE supported in JBoss AS 7. This is not the book one would learn how to write JavaServer Pages, JavaServer Faces applications, EJBs, or other Java EE code from. However, it is the book one would learn how to deploy a Java EE application to JBoss AS 7 and how to maintain and configure JBoss AS 7 to most efficiently support Java EE applications.

Other Reviews

Other reviews of JBoss AS 7: Configuration, Deployment, and Administration are available. These include Markus Eisele's Review: "JBoss AS7 Configuration, Deployment and Administration" by Francesco Marchioni, Rick Wagner's Book Review for "JBoss AS 7 Configuration Deployment and Administration" (unfinished version of the book), Maksim Sorokin's [PACKT] JBoss AS 7 Configuration, Deployment and Administration (announcing review coming), and David Salter's Forthcoming Book Review (announcing review coming).

Thứ Hai, 16 tháng 1, 2012

Book Review: JavaFX 2.0: Introduction by Example

Although Oracle's changes to JavaFX at JavaOne 2010 and JavaOne 2011 have converted me from a skeptic to a believer when it comes to JavaFX, the shift in JavaFX vision has not been without its downsides. In particular, the JavaFX book market has been tricky because nearly all available JavaFX books have been about version 1.x. In this post, I review the only book that I'm aware of at time of this writing that is completely focused on JavaFX 2.0: Carl Dea's JavaFX 2.0: Introduction by Example.

I'll start my review by stating the most important observation about JavaFX 2.0: Introduction by Example: it provided me exactly what I was looking for exactly when I needed it. There are some attributes of the book that might be considered negative by some readers that I felt were positives in my use of the book. I'll attempt in this post to articulate the finer points of these attributes so that prospective readers can make up their own minds.

JavaFX 2.0 Introduction by Example does exactly what the title implies: it introduces JavaFX 2.0 via numerous and varied examples. This code-heavy book is roughly similar to a "recipes" or "cookbook" with individual item covered (AKA a "recipe" in a recipes or cookbook) featuring subsections on the problem to be solved, the solution or solutions to that problem, and how those solutions work. Like the best recipes-oriented or cookbook-oriented software development books, this one is constructed so that Chapter 1 ("JavaFX Fundamentals") covers some of the basics of JavaFX early on. In other words, the reader is not dropped into JavaFX without first getting some examples of how to write and deploy basic "Hello World" style JavaFX applications.

Although JavaFX 2.0: Introduction by Example does provide introductory examples early on, I really appreciated the author not spending significant time discussing esoteric features of the language or delving into the history of JavaFX in tedious detail or providing pages worth of explanation on why JavaFX is the greatest thing since sliced bread. I'm usually in a hurry and I have come to resent books wasting my time on such things and this book doesn't do that. In this case, I was already familiar with these aspects of JavaFX (at least its history and why I might be interested in learning more about it), so I was especially appreciative of Dea not wasting paper and my time on that subject. In the book's concise "Introduction," Dea covers in a page and a half some advantages of JavaFX and "some history" of JavaFX along with a simple table articulating features of each release of JavaFX. It's a thing of beauty to be able to read all of this in less than two pages and in the introduction!

Dea covers some more background on JavaFX in the first chapter, but again limits that discussion to a single page. This page is more detailed than the introductory section and is a nice, brief segue into the technical meat of the book. This first page also contains the sentences that I think best sum up the value of this book:

Although this book doesn't go through an exhaustive study of all of JavaFX 2.0's capabilities, you will find common use cases that can help you build richer applications. Hopefully, these recipes can lead you in the right direction by providing practical and real-world examples.

This is exactly what JavaFX 2.0: Introduction by Example has done for me. It has provided me with a fast start into the world of JavaFX. Although I have since used several aspects of JavaFX not covered in this book, the book gave me the start that I needed and I was able to use JavaFX documentation for the areas not covered in this book.

JavaFX 2.0: Introduction by Example gets to the point quickly. Besides common things like the very brief introduction and the index, the book contains four chapters (32 "recipes") spanning 174 pages of text, images, and code. Dea doesn't even waste time with a conclusion, but ends the book with "recipe" 4.5 ("Displaying Content from the Database"). Although some readers may need a conclusion to bring closure to their reading experience, I usually little value in this for me as a reader and I didn't miss it here. I typically don't read these types of book cover-to-cover anyway (instead focusing on sections or recipes I am most interested in), so the conclusion is often unnecessary. Lack of a conclusion is another example of how Dea's book focuses most on what I want: the technical meat.

The four chapters in JavaFX 2.0: Introduction by Example are "JavaFX Fundamentals," "Graphics with JavaFX," "Media with JavaFX," and "JavaFX on the Web." The first chapter was most useful for quickly immersing myself into the basics of JavaFX and how to apply it. The examples in that chapter tend to be simple and easy to follow. The examples in the other three chapters tend to be more sophisticated because the functionality being covered tends to be more sophisticated. There are numerous lengthy code listings in the book. Although code listings may not be the easiest to read, I like to see actual code in any book on a language. Dea typically follows each code sample with descriptive text on any new feature shown in the code sample that had not been covered previously in the book. The code samples can be downloaded from Apress's site. The book also features numerous screen snapshots, which I consider a must for a book focused on user interfaces.

The concise and introductory approach of JavaFX 2.0: Introduction by Example that appealed to me may not appeal to everyone. This book, as advertised in the above cited quotation from the first chapter, is intended to be introductory (hence the title) and not to be exhaustive. Some topics that I have not seen covered in this book include subjects such as FXML, the JavaFX charting functionality, GroovyFX, and ScalaFX. Deployment is only lightly covered (and mostly via NetBeans), but Dea does reference Deploying JavaFX Applications for more details on JavaFX deployment. All of these areas, however, are fairly approachable given the JavaFX basics provided in this book. Dea recommends that readers reference forthcoming (mid-February 2012, Apress) Pro JavaFX 2.0 Platform for an "invaluable resource" that provides "further insight into JavaFX."

Although a small number of the items/recipes covered in JavaFX 2.0: Introduction by Example are based on and assume use of NetBeans, most examples in no way specific to any tool or IDE. Rather, most examples provide "raw" code that can be used in any IDE or favorite text editor. Indeed, many of the examples can be compiled with the javac compiler and executed with the java application launcher. I appreciated that in at least one NetBeans-oriented recipe, Dea took the page or two necessary to provide the code listing for code generated by NetBeans. This is invaluable for those who do not use NetBeans or who want to understand the code itself rather than simply understanding how to use NetBeans to generate the code.

JavaFX 2.0: Introduction by Example was exactly what I needed for an efficient and effective start to my investigation of JavaFX. It may not provide quite the level of soft introduction someone completely unfamiliar with JavaFX might want (especially if that person's basic Java skills are a little rusty) and it isn't an "exhaustive" JavaFX 2.0 reference either. It falls in between these extremes and seems to be a fast start example-based introduction to JavaFX for those who want to get into the core of JavaFX as quickly as possible. That's what I wanted when I purchased this book and I was happy to find out that's exactly what this book provides. It's completely JavaFX 2.x-oriented and there is no sign of deprecated JavaFX Script in any of the code examples.