Showing posts with label Java EE 6. Show all posts
Showing posts with label Java EE 6. Show all posts

Saturday, March 8, 2014

Video Review: JBoss EAP Configuration, Deployment, and Administration

Packt Publishing released the video JBoss EAP Configuration, Deployment, and Administration by Red Hat employee Jason Shepherd in October 2013. This post is my review of this training video on configuring, deploying, and administrating the JBoss Enterprise Application Platform.

Like HTML5 Game Development which I recently reviewed, JBoss EAP Configuration, Deployment, and Administration is actually a series of short videos (1 to 5 minutes each and grouped with related videos in sections/chapters) that run in the Packt Video Player within a web browser.

Section 1: Standalone versus Domain Mode

The first section (or chapter) covers download and installation of JBoss along with coverage of the basics of setting up standalone instances and domain instances of the application server. Two approaches (command line copying of WAR file into appropriate directory and use of web-based Management Console at http://localhost:9990 with newly created user) for standalone deployment are demonstrated. The first section then moves onto coverage of using command line (emphasizing JBoss AS7's Command Line Interface) tool and web-based Management Console to deploy to multiple instances in domain mode.

Section 2: Adding and Configuring Databases and Message Queues and Using Them from Your Application

The second section of JBoss EAP Configuration, Deployment, and Administration contains short videos related to using database and JMS with JBoss. The first video in this section demonstrates using the browser-based Management Console to associate a JDBC driver with the application server using JBoss's JCA support. A MySQL database is used in this example. The second video also shows association of a datasource with the JBoss instance, but uses the Command Line Interface this time. It introduces and demonstrates use of the commands deployment-info and data-source. The third video of Section 2 indicates a third way of configuring a datasource to be used by JBoss Application Server: directly editing the configuration file. The narrator explains why this must be done when the application server is not running and demonstrates changing the configuration file by changing the datasource to be an XA datasource.

The fourth video of Section 2 is simply titled "Connecting to a Database," but demonstrates far more than that. In this video, the author demonstrates use of the JBoss Tools plugin for Eclipse IDE. The demonstration shows use of a sample application included with JBoss Tools that uses Java Persistence API to connect to the database (note that installation of the JBoss Tools plugin for Eclipse is demonstrated in the first video of Section 7). The fifth video of Section 2 demonstrates use of the Management Console to configure database connection pooling and demonstrates how to use files provided with the JBoss distribution to learn about more potential settings to adjust.

The final two videos of Section 2 demonstrate setting configuring a JMS Queue in JBoss using the Management Console and then interacting with that JMS Queue with simple examples written in Java and displayed in the video in the Eclipse IDE.

Section 3: Configuring the Java Virtual Machine (JVM) for Troubleshooting and Diagnostics

The third section of JBoss EAP Configuration, Deployment, and Administration looks at troubleshooting and diagnosing performance and memory related issues with JBoss. The majority of the information provided in these videos in this section are not JBoss-specific, but rather cover use of the standard tools provided by the Oracle JDK (and OpenJDK) and by Linux. For example, demonstrated tools include jps, jstack, top (including a useful script for running it periodically), and so forth. There are some JBoss-specific aspects to the videos in Section 3 such as how to specify the garbage collector to use, enabling logging of garbage collection events, and specifying JVM heap sizes that JBoss instances should use. The videos provide introductory detail on analyzing output of these tools (garbage collection logging, thread dumps, and heap dumps) and what common symptoms of the output indicate about potential issues. Useful tools for helping with this analysis are also briefly mentioned: GCViewer (garbage collection), Samurai (thread dumps), and Eclipse Memory Analyzer (heap dumps).

Section 4: Clustering and Load Balancing for Web Applications

After the highly general Section 3 with few JBoss-specific details, Section 4 returns to a heavy JBoss focus with its coverage of clustering and load balancing. This section of videos uses Linux command line options heavily and most of the work is done and verified with Linux commands and viewing output.

Section 5: Classloading with JBoss Modules

Section 5 is on JBoss Modules. The author explains that while developers may have run into issues with classes using by the application server being available and even erroneously used by the applications in some previous versions of the application server, JBoss AS7 (JBoss EAP 6) provides special class loading support to help avoid this issue. This section discusses this and also talks about the implicit module dependencies in JBoss. The videos show how to exclude certain implicitly provided modules and how to explicitly declare dependencies on different modules. The videos demonstrate using and changing jboss-deployment-structure.xml files to control JBoss classloading. The final video in this section uses JBoss AS 7: Configuration, Deployment, and Administration to show in writing how JBoss classloading precedence rules work.

Section 6: Deploying Applications

Although the title of Section 6 is "Deploying Applications," this is not the first section in which deployment to a JBoss application server instance is covered. Instead, this section focuses on more specific capabilities that can be enabled in JBoss at deployment time for performance improvements and for greater security. The first video in this section emphasizes using Java EE 6 Servlet 3.0 asynchronous servlets and shows how use of these improves ability to serve frequently repeated requests sent in as tests using JMeter.

The second video of Section 6 is on using SSL with JBoss. This video showed key portions of the "JBoss community document" Using SSL with JBoss using JSSE and moves back and forth between describing concepts covered on that page and video illustrations of how to apply those concepts.

The third video of Section 6 uses the servlet-security example of the JBoss AS Quick Starts to demonstrate integrating Java Authentication and Authorization Service (JAAS) support into a JBoss application. I noted that the comments in the referenced servlet-security example were perhaps the first references in these videos to "JBoss Enterprise Application Platform." These comments stated that the example applies to "JBoss Enterprise Application Platform 6 or JBoss Application Server 7."

The final video in Section 6 demonstrates how to secure JBoss passwords (encrypt them rather than storing them in plain text) using the JBoss Vault. As with the second video in this same section, the narrator moves back and forth between online documentation (JBoss AS7 Securing Passwords) and video illustration of applying the concepts in the documentation.

Section 7: Building and Testing Application with Maven and JBoss Tools

Although JBoss Tools for Eclipse was mentioned in a previous video, the first video of Section 7 demonstrates configuration of JBoss Tools in Eclipse. The second video of this section revisits JBoss AS QuickStarts to demonstrate use of Maven (jboss-javaee-6.0-with-tools BOM and jboss-as-maven-plugin) to build and deploy JBoss applications.

JBoss Tools in Eclipse is the featured tool of the third video of Section 7. In this video, deployment of a JBoss-hosted application via JBoss Tools for Eclipse is demonstrated. Arquillian is the main tool covered in the final two videos of Section 7. The first of these demonstrates running test suites in JBoss with Arquillian and the second video features use of Arquillian with Shrinkwrap to run init tests against a JBoss instance.

Section 8: Configuring the Application Server Logging

The final section of JBoss EAP Configuration, Deployment, and Administration focuses on logging in JBoss. The first video briefly references the JBoss Command Line Interface Recipe called Toggle root logger level during runtime with out bouncing the server before demonstrating changing the log level by changing the XML configuration file directly (requires stopping the server) and by using CLI both in standalone mode and in domain mode. This demonstration shows how to set the logging appenders so that different levels of logs go to the console than to log files. The second video of Section 8 looks at setting log levels at category levels rather than at more general system-wide levels. It demonstrates doing this both by editing the file directly and by using CLI.

The final three videos of Section 8 look at making JBoss logging more efficient. Techniques demonstrated include using async-handler for asynchronous logging, rolling the generated server.log file based on specified maximum size, and overriding JBoss's default logging configuration with application-specific logging configuration.

General Observations
  • I liked that JBoss EAP Configuration, Deployment, and Administration generally illustrated these tasks with both the web browser-based Management Console and with the Command Line Interface tool. I find myself using both approaches when working with application servers that support both approaches. I generally lean toward use of the web interface when first learning and then gradually move to the command-line as I start to script steps I am tired of doing manually. It is nice to see how to do things with both approaches.
  • Verbal cues in the narration and examples showing the command-line, Management Console, and Eclipse plugin indicate that it is JBoss 7.1.1 being used in these videos. To the best of my understanding, this implies that it is JBoss Enterprise Application Platform 6 being demonstrated. I don't recall any verbal mention and only a few written mentions of "JBoss Enterprise Platform" in this video, but "JBoss Application Server" was mentioned numerous times in text and verbally. Perhaps my biggest negative observation regarding this video tutorial is that its title might have been better as "JBoss AS7 Configuration, Deployment, and Administration" (which probably was not done because there is a book already with this title).
    • It is not a fault of this video, but a more general challenge is the difficulty differentiating JBoss Application Server, JBoss Enterprise Application Platform, and Wildfly. According to jboss.org community documentation, JBoss Application Server "allows innovation at a faster pace" while JBoss Enterprise Application Platform is described as "a rigorously tested, stable, supported platform for developing and deploying mission critical Java applications and services." The JBoss Application Server 7 FAQ states that "JBoss Enterprise Application Platform (EAP) is the productized version of JBoss Application Server (AS)." The "community edition" JBoss Application Server was renamed Wildfly and the post JBoss EAP and WildFly - a Symbiotic Relationship describes the relationship between JBoss Enterprise Application Platform and newly named Wildfly.
    • The best way I've found to get my head around which version of JBoss Enterprise Application Platform corresponds to a particular version of JBoss Application Server/Wildfly version is to cite the JBoss Downloads page. As of this writing, that page indicates that JBoss Enterprise Application Platform 6.x versions are "built from" AS 7.x versions. Therefore, I can conclude that the videos I am reviewing here are demonstrating configuration, deployment, and administration of JBoss Enterprise Application Platform 6 when I see JBoss Application Server 7 references in the tools and command-line output shown in the videos.
  • JBoss EAP Configuration, Deployment, and Administration should probably not be a person's initial and only exposure to JBoss Application Server or Enterprise Application Platform. A viewer of these video snippets would be better served to have at least rudimentary awareness of how an application server works conceptually and preferably would have at least some awareness of JBoss specific concepts. Although the videos start by showing how to download JBoss, I doubt that someone entirely new to application servers would be able to keep up with the videos for very long.
  • Demonstration of configuration, deployment, and administration of JBoss EAP are done in Linux. It will be easier for the viewer to understand the points the video makes if the viewer understands basic Linux because commands such as ls, grep, less, diff, scp, connect, ip addr show, and ifconfig, are used and Linux tools such as vim and top are used.
  • The videos in JBoss EAP Configuration, Deployment, and Administration will be useful to anyone wanting to learn how to configure, deploy, and administrate JBoss Application Server 7/JBoss Enterprise Platform 6. However, they will be slightly more approachable to those using Eclipse IDE and Linux because that operating system and IDE are used for demonstrations.
  • Although Section 3 had very few JBoss-specific details, this is the type of information that I believe all intermediate or advanced Java developers should know. The author's mixing of Oracle JDK tools, Linux tools, and other available tools provides a good overview of the basics of using these tools to improve performance of any (not just JBoss-based) Java-based application.
  • JBoss EAP Configuration, Deployment, and Administration references written documentation in several of the videos. I like that the author shows the actual page (so it will look familiar when I pull it up in my own browser) and emphasizes the URL so that I can make note of it for later reference. An advantage of this is that a viewer can not only learn the concept being illustrated, but can learn where to go for more details or to refresh one's memory.
  • The best fit for this video tutorial is probably someone with general Java EE/application server experience, but with relatively little JBoss AS7 administration experience. The videos don't waste anytime getting into the core subject and are probably not best suited for someone totally new to Java EE. However, a person familiar with configuring other Java EE application servers should be able to pick up JBoss specifics shown in these short videos without significant trouble.
  • The videos I have reviewed here provide much information in quick fashion, making it easy to quickly see the overall approaches one can use. In some cases, it would probably be helpful for the viewer to have access to online or other "print" details to reference in case small details outside the videos' scope are desired.
  • The audio is clear on all of the videos and the videos was clear on my laptop screen as long as I ran the video in full-screen mode.
Conclusion

I found JBoss EAP Configuration, Deployment, and Administration to be engaging and informative. These videos provide a mechanism for a person to easily and quickly understand how to work with configuration, deployment, and administration features in JBoss Application Server 7/JBoss Enterprise Application Platform 6/Wildfly.

Monday, September 9, 2013

Book Review: JBoss Weld CDI for Java Platform

JBoss Weld CDI for Java Platform is a relatively short book (approximately 100 "main" pages) that introduces JBoss Weld, which it describes as "the open source reference implementation" of Java Contexts and Dependency Injection. Weld is the reference implementation of Java Specification Request 299 ("Contexts and Dependency Injection for the Java EE platform") and is not limited to use with JBoss Application Server. This post is my review of Packt Publishing's JBoss Weld CDI for Java Platform by Ken Finnigan.

Preface

The Preface of JBoss Weld CDI for Java Platform explains that the book is written for "anyone wanting to understand what CDI 1.0 is and how it can be used to benefit an application's architecture." This Preface also states that the latest version of Weld 1.x is required along with Maven and a "favorite runtime container" (out of JBoss AS7, GlassFish, and Tomcat).

Chapter 1: What is a Bean?

The opening chapter of JBoss Weld CDI for Java Platform provides a brief history of Java "beans" that includes mention of early JavaBeans, Enterprise JavaBeans, and JSF Managed Beans. There are, of course, many more types of "beans" in Java such as JMX Managed Beans (MBeans and MXBeans) and product-specific beans like Spring Framework's beans.

The initial chapter goes on to provide a definition of a CDI bean. Finnigan explains that a CDI bean generally "needs a non-private constructor with no parameters" to be "proxied by the container" before discussing use of the @Inject annotation for classes without a no-argument public constructor. There is a typo here as the text reads, "It is also possible for a bean to be proxied by the container if it does not have a constructor with any parameters," but I think the text should read, "It is also possible for a bean to be proxied by the container if it does not have a constructor without parameters" or "It is also possible for a bean to be proxied by the container if it does not have a constructor no parameters."

Chapter 1 of JBoss Weld CDI for Java Platform introduces several other annotations besides @Inject; these include @Dependent, @RequestScoped, @ApplicationScoped, @SessionScoped, @ConversationScoped, and @Alternative. The chapter includes coverage of the beans.xml file and discusses where it should be placed and what it should contain.

The first chapter continues its introduction to CDI beans by quoting the CDI specification of the characteristics required of a CDI bean and then focuses on each characteristic (bean types, qualifiers, scope, interceptor bindings, bean implementation, and optional bean expression language [EL]). These introductions to the characteristics of a CDI bean introduce more annotations such as @Typed, @Qualifier, and @Named.

The packed ten-page first chapter continues with coverage of CDI's @ManagedBean (not to be confused with JSF's @ManagedBean) and @Produces (on methods and fields).

Chapter 2: Dependency Injection and Lookup

The second chapter of JBoss Weld CDI for Java Platform begins with a deeper look at dependency injection using Weld. Finnigan describes the ability to inject dependencies at class level (via no-arguments constructor or constructor annotated with @Inject), at get/set method level, or at field level. I was happy to see that he specifically mentions constructor setting and field level setting of injection points as preferable to method level setting to support creation of immutable objects. (I think the importance and value of immutability (when possible) in Java objects is still under-appreciated.)

The second chapter provides more focus on qualifiers (including @Any and @Default annotations), alternatives, and client proxies, and injection point metadata.

I like that Finnigan talks about some likely errors (including error message output) that can occur when configuration problems exist. I wish more introductory books did this, focusing on things that often go wrong rather than simply covering the happy path of using the framework or tool being introduced. Finnigan includes a section in this chapter called "Resolving Weld deployment errors" that lists the common types of errors that can occur with Weld deployments (unsatisfied dependencies and ambiguous dependencies) and then lists multiple ways to resolve each.

Chapter 3: Deploying JBoss Weld

The third chapter of JBoss Weld CDI for Java Platform covers "installation of JBoss Weld into Java EE 6 and Servlet containers." Finnigan points out that "all Java EE 6 containers will come with an implementation of CDI preinstalled," but also makes the point that it's worth knowing how to install or deploy Weld because the version bundled with the container may be insufficient. The chapter talks about how to download Weld and mentions that the current version as of the book's writing was 1.1.10 (at the time of this blog post's writing, Weld 1.2 beta and Weld 2.0 are available for download).

Chapter 3 concludes with a useful discussion on upgrading of Weld versions within three containers: JBoss AS 7 (7.1.1) with bundled Weld 1.1.5Final, GlassFish 3 (3.1.2.2) with bundled Weld 1.1.8Final, and Apache Tomcat 7.0.35 (no bundled Weld implementation because Tomcat is a web servlet implementation).

Chapter 4: Scopes and Contexts

JBoss Weld CDI for Java Platform's fourth chapter delves deeper into the concepts of scopes and contexts introduced earlier in the first chapter. This fourth chapter introduces the concepts of normal and pseudo scopes. Finnigan explains that the differentiating factor between normal scope and pseudo scope is whether a client proxy is required or not. The chapter provides a relatively large section on the built-in scopes introduced earlier and describes the underlying respective lifecycles: request context, session context, application context, and conversation context. I liked that Finnigan wanrns about conversation scope in CDI 1.0 being specific to JSF, but mentioning that CDI 1.1 (JSR 346) is expected to make conversation scope more generally available.

The majority of Chapter 4 is spent on normal, built-in scopes and their associated contexts. In particular, a significant portion of the chapter is dedicated to coverage of using the conversational scope with JSF. The chapter, however, does briefly describe pseudo scopes and concludes with an example of writing custom scope and context.

Chapter 5: Producers

The fifth chapter in JBoss Weld CDI for Java Platform provides greater focus on another topic introduced in the first chapter: producers with @Produces and @Disposes. This chapter's coverage includes some more highly useful side notes with special emphasis that discuss the use of @New, but also mention that @New is deprecated in CDI 1.1 in favor of @Dependent at the injection point.

Chapter 6: Interceptors and Decorators

Chapter 6 of JBoss Weld CDI for Java Platform introduces interceptors and decorators and differentiates them, "Interceptors are perfect for separating concerns that are orthogonal to our application ... Decorators are well suited for solving business problems that apply to a hierarchy of classes of the same type."

This chapter provides relatively in-depth coverage of created interceptors and decorators. I like the fact that the examples, especially the interceptors examples, include some complicating issues to take the examples past "Hello World" status and to be more reflective of what one might do with these constructs.

Chapter 7: Events

The seventh chapter of JBoss Weld CDI for Java Platform covers "events within CDI" including "how they are fired" (javax.enterprise.event.Event.fire), "how we listen for new events" (@Observes), "what we can use as an event payload" (concrete Java classes), and "how we can narrow what events we can listen to and fire" (event qualifiers and conditional observers).

Chapter 8: Writing a Portable Extension

Chapter 8 is the last chapter of JBoss Weld CDI for Java Platform that focuses on detailed coverage of Weld concepts in an purely introductory fashion because Chapter 9 and Chapter 10 focus on an example book store application. This chapter's focus is use of CDI-exposed Service Provider Interfaces (SPIs) that allow extension and customization of CDI. The chapter outlines the development of portable CDI extensions by implementing javax.enterprise.inject.spi.Extension and registering the extension in META-INF/services/javax.enterprise.inject.spi.Extension. The chapter discusses the "core" role of BeanManager in allowing extensions to access the CDI lifecycle. Chapter 8 also mentions Apache DeltaSpike, a product which I had never heard of, but which its homepage advertises as "a number of portable CDI extensions that provide useful features for Java application developers."

Chapter 9: Book Store – CDI Services

JBoss Weld CDI for Java Platform's ninth chapter is the first of two chapters that use an online book store application as a CDI/Weld example intended to "provide a more indicative picture of how (Weld CDI) can be utilized," to "cover some of the CDI usage patterns that can be beneficial," and to "provide clear examples of topics that we have discussed in the previous chapters." Chapter 9 introduces the example application and demonstrates building its "back end" (services, interceptors, and events portions).

Chapter 10: Book Store – User Interfaces

The tenth and final chapter continues the example online bookstore application started in Chapter 9. This chapter focuses on the "front end" of the example application and demonstrates "how CDI services can be reused to create two distinct user interfaces." The two technologies used for the interfaces are AngularJS and JSF2/Rich Faces. In the book's example application, REST is used for communication between the user interfaces and the services.

Strengths
  • General CDI Specification (not just Weld) Resource - Although the book title and some of its content suggest focus on the CDI implementation Weld, the vast majority of the book is likely applicable to most common implementations of CDI (Chapter 3 being about the only significant exception that is highly Weld-specific rather than CDI-general). I find it often to be the case that books on reference implementations are good sources of information on the specification being implemented and that is definitely the case with JBoss Weld CDI for Java Platform; it can serve as simply "CDI for Java Platform."
  • Forward-looking - Technology books, especially those focused on new implementations of ongoing specifications, always come with great risk of being outdated quickly. Finnigan's mention of CDI 1.1 in several parts of the book helps to mitigate this risk at least a bit.
  • Appropriate Level of Detail - This is not a very lengthy book, but its length feels appropriate. There is nice introductory discussion along with discussion on some things to do and not do with CDI/Weld. There are several code examples, but most are short and easy to follow. The lengthy and more difficult to follow examples are reserved for the final two chapters on the sample application.
Conclusion

I really enjoyed JBoss Weld CDI for Java Platform and recommend it to anyone interested in learning about Java EE CDI in general or the Weld implementation of CDI in particular. Other than a few typos such as the one I mentioned in this post, the text is generally well-written. I particularly like the text's mixing of introductory material with forward-looking caveat statements and discussion of why certain practices are beneficial or detrimental in different circumstances.

Thursday, August 9, 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.

Saturday, July 14, 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.

Saturday, March 24, 2012

Software Development Posts of Interest - March 2012

This post references some of the recent blog posts and articles that have interested me. Topics include Java-specific topics such as Java EE, JavaFX, Scala, and Gradle as well as more general software development topics such as software patents and open source.

Why Software Patents are Evil

Simon Phipps summarizes in Why software patents are evil why patents in software may not make sense:

Patents may work in other industries, where the cost of innovation is so high that a temporary, state-sanctioned monopoly provides just enough time to gain a return on the investment. But that investment-return ratio has a completely different value for software. It turns out that software patents have little bearing on encouraging innovation. ... Software patents are ... bad news for most innovators in the software industry.

Phipps also looks at the relationship between software patents and open source software. He writes, "The problem is that open source software is defenseless against the anticompetitive abuse of patents."

Java EE 6 Versus Spring Framework

In the post Why is Java EE 6 better than Spring? Arun Gupta discusses why he believes developers should use Java EE 6 rather than the Spring Framework. Gupta begins the post by referencing several similar blog posts including Java EE wins over Spring and Why I will use Java EE (JEE, and not J2EE) instead of Spring in new Enterprise Java Projects in 2012.

Some of the feedback comments on this post are interesting because they demonstrate the differences of opinions between Java EE evangelists and Spring Framework evangelists (with comments from employees of both Oracle and SpringSource/VMWare among them). It is interesting to see the role reversal in this situation. Evangelists of the Spring Framework (even before it was so named) helped convince the Java enterprise development community of the problems with early J2EE, but now it seems the tables have turned and similar evangelism is advertising the "legacy" nature of Spring Framework as compared to modern Java EE.

Java EE 6 vs Spring - let's get ready to rumble provides another look at this post.

Oracle's Long-Term Intentions for Java

Paul Krill's Oracle lays out long-range Java intentions summarizes the "Oracle slide presentation entitled 'To Java SE 8 and Beyond!' posted on the QCon conference website." Based on Krill's summary, this presentation sounds very similar to the Oracle OpenWorld 2011 presentation From Java SE, 2012, to Java 12: Java SE Roadmap.

Reducing Memory Usage and Garbage Collections with -XX:+UseCompressedOops

Stuart Leneghan's post Reducing Java Memory Usage and Garbage Collections with the UseCompressedOops VM Option looks at the author's observation of the -XX:+UseCompressedOops HotSpot-specific JVM option "[reducing] the memory usage of the application by 14% and the number of garbage collections by 24%."

More on Java Tuning

Speaking of Java performance and memory tuning, Rupesh Ramachandran's post Java Tuning in a Nutshell - Part 1 provides a "JVM tuning cheat sheet" and categorizes JVM options into four categories: garbage collection, heap tuning, logging, and other performance.

The IBM DeveloperWorks article From Java code to Java heap is fairly comprehensive, providing background details on JVM memory handling and a focus on the impact of different Java collections on memory. This article also references the HotSpot option -XX:+UseCompressedOops as well as the similar IBM JVM option -Xcompressedrefs.

Understanding Garbage Collection is another recently-posted resource. This post is "the first of a series of 'Become a Java GC Expert' articles" and its focus is on introducing garbage collection in Java. The same site also hosts the blog post How to Analyze Java Thread Dumps. Figure Out Why Java is Eating CPU provides an interesting tip.

Scala

There continues to be a profusion of Scala posts. Recent posts include How Scala Can Improve Your Life, Is Scala making the right steps forward?, Scala creator Martin Odersky fends off critics of Scala's roadmap, Free online books for learning Scala, and Scala: Sink or Swim? Part 1. I have also seen new references to Twitter's Effective Scala.

Unit Testing

Neil Buesing's post How to Mock Final Classes in Unit Tests examines the problem that "both Mockito and EasyMock cannot mock classes (or methods) that are final." The feedback comments are also informative and discuss other available solutions to this issue: PowerMock), Groovy-based gMock, and JMockit.

Improved Java Stack Trace Presentation

Tomasz Nurkiewicz has posted two blog posts on how to improve Java stack trace experience using the Logback Project. Filtering irrelevant stack trace lines in logs demonstrates his "proof-of-concept" for filtering out selected stack trace frames using Logback and references the StackOverflow thread Cleaning noise out of Java stack traces. An older post, Logging exceptions root cause first, discusses a feature he contributed to Logback for displaying exceptions with root cause first rather than last.

A Peek at NetBeans 7.2

Geertjan Wielenga's NetBeans Java Hints: Quick & Dirty Guide provides a peek at a capability coming in NetBeans 7.2 for creating NetBeans hints.

Gradle

Last milestone for Gradle as it prepares for first major version cites the Gradle roadmap and states that the current version of Gradle ("1.0-milestone-9, released on 13th March 2012") "will be the final one" before Gradle goes into release candidate.

GroovyFX and JavaFX

Gradle is not the only product in the Groovy ecosystem with recent version advancement news. Dean Iverson has announced the GroovyFX First Official Release. He also shows how to use Grape to "grab" GroovyFX similar to the approach shown in my post Easy Groovy Logger Injection and Log Guarding.

Other interesting recent posts related to JavaFX include Example CSS Stylying in JavaFX, New in JavaFX 2.1: ComboBox, and Packaging JavaFX Applications as Native Installers.

Groovy and DevOps

In the post Groovy, A Reasonable JVM Language for DevOps, Geoffrey Papilion writes that Groovy provides the "JVM glue" he sought for "a simple JVM language that allows me to use any native object." After demonstrating use of Groovy for a "quick script to get data from JMX into ganglia fromSsolr," he concludes

So, if you're working in a Java with a bunch of Java apps, think about giving Groovy a chance for writing some of your monitoring tests, and metric collectors. It is a simpler language than Java to put together those little applications that can tell you how your system is performing, and well within the reach of your average DevOps engineer.
DNS for Software Developers

Doug Rathbone's post DevOps DNS for Developers – Now There’s No Excuse Not To Know is intended to help software developers become more familiar with the basics of DNS. This does seem like the sort of article one would except to be associated with the DevOps movement.

The Big Three JVM Languages

The Big Three – Scala, Clojure and Groovy is a blog post with observations about Groovy, Scala, and Clojure seeming to be the most popular JVM languages among Java developers based on two polls (Which alternate JVM language do you prefer? and Which JVM Language Is On Top?). Charles Oliver Nutter has added a feedback comment regarding JRuby being a more popular JVM language when you consider Ruby developers.

Java 7 WatchService

The post What’s New in Java 7: WatchService describes java.nio.file.WatchService and calls the related functionality "one of the more interesting ... new features in Java 7." This is a fairly concise post that quickly introduces the functionality and includes sample code.

Opinions on Rails, Hibernate, Google, JSON's License Agreement, and the Spanish Theory of Management

I started this post with reference to an opinion-oriented post on open source and patents. It seems symmetrically pleasing to close this post with references to other opinion-oriented pieces. Tyler Menezes discusses technical and cultural reasons he won't use Ruby on Rails in the simply titled post I will not learn Rails. James Whittaker provides a articulate and insightful post Why I left Google.

Rob Gordon is "not impressed" with Hibernate 4.1 ease of use. The Dodgy Coder blog ("Never trust a programmer in a suit") includes a post on the "Spanish Theory" of project management.

Brian Fox points out that JSON's license agreement states "The Software shall be used for Good, not Evil." Fox further points out that "compliance is impossible" and that "this isn't even open source." He asserts that "this additional clause adds an unnecessary complication" and I tend to agree. The folks in suits are not comfortable with objective statements in the license agreements.

Conclusion

I have summarized and linked to Java-specific and general software development posts of interest in this blog post. The software development industry continues to be ever-changing and full of news.

Monday, August 22, 2011

Book Review: Java EE 6 Development with NetBeans 7

I recently posted an early preview of my thoughts on David R. Heffelfinger's book Java EE 6 Development with NetBeans 7. In this post, I provide a more detailed review of this book.


General Observations

In this section of my review, I make some general observations regarding the book.


Breadth of Coverage for Java EE 6 and NetBeans 7

Reviewing the Table of Contents for Java EE 6 Development with NetBeans 7 provides a quick overview of what the book covers. Its chapters cover topics such as using the NetBeans IDE, servlets and JavaServer Pages (JSP), JavaServer Faces (JSF), Java Persistence API (JPA), session beans, Contexts and Dependency Injection (CDI), Java Message Service (JMS), Java API for XML Web Services (JAX-WS), and Java API for RESTful Web Services (JAX-RS). In addition, the book features two appendices focused on debugging with NetBeans 7 and profiling with NetBeans 7.


Lots of Pictures!

Java EE 6 Development with NetBeans 7 features numerous screenshots that illustrate the points being made. The writing style is easy to read and the concepts are generally easy to follow.


Use of Keyboard Shortcuts

One of the "small" things that I really liked about this book was the consistent inclusion of NetBeans 7 keyboard short cuts and commands that can be used to perform functionality available via mouse clicks. I've long benefited from being aware of powerful keyboard commands that make development and code maintenance quicker. I sometimes even copy code into vim just to use a few such commands before pasting the code into my blog posts or other presentation venues.


Best Practices and Common Practices

There are several times in Java EE 6 Development with NetBeans 7 that best practices and common practices are discussed in conjunction with the particular topic being discussed. This is a natural mix of coverage of a particular portion of Java EE 6 with practices that lead to better use of that feature.


References to Additional Resources

I like the author's liberal use of references to online resources with additional details. The book generally does a nice job of focusing on topics at an introductory level and providing some illustrative examples before referencing more detailed resources for lower level and additional details. The author has done a nice job of providing enough details in the book to get started and understand the overall concept without burdening the reader with too many details. The reader can reference the more detailed resources after gaining familiarity with the concept in general.


To Use web.xml or Not To Use It

One of the things I had heard about Java EE 6 was that web.xml is no longer required due to the heavier use of annotations. However, this book has pointed out at least three situations (web security, database access, JSF project stage) in which web.xml is either still required or may be desirable.


Specific Sections in Review

The Preface

The Preface of Java EE 6 Development with NetBeans 7 answers many of the questions that a person considering the book might ask. For example, it talks about what Java EE 6 adds to previous versions of Java EE (JSF 2.0, Servlet 3.0, and JAX-RS for example). The Preface also states the prerequisites needed to run examples from the book: Java SE 6 or newer (I'm using JDK 7) and NetBeans 7.0 Java EE Edition (I'm using the "All" edition that includes Java EE).

Perhaps the most important part of the Preface is the section that states who Java EE 6 Development with NetBeans 7 is intended for. The three types of developers forming the book's primary audience are general Java developers wishing to learn how to use NetBeans 7 to write Java EE 6 applications, NetBeans 7 users wishing to learn how to use their IDE to developer Java EE 6 applications, and developers already familiar with Java EE 6 who wish to learn how to use NetBeans 7 in their work.


Chapter 1: Getting Started with NetBeans

The first chapter introduces the NetBeans IDE generally and describes several aspects associated with obtaining NetBeans. This section includes information on configuring an application server to be used with NetBeans 7 other than the bundled GlassFish or bundled Tomcat. It similarly covers using a relational database other than the Java DB bundled with NetBeans 7. The chapter also describes how to deploy a very simple Java EE application in NetBeans.

After the section on obtaining and configuring NetBeans and deploying a Java EE application to NetBeans, Chapter 1 moves onto coverage of NetBeans "tips for effective development." In this section, Heffelfinger covers topics that are useful to general Java development (not limited solely to Java EE benefit). These topics include code completion, code templates, keyboard shortcuts, and visual cues. Although I have used NetBeans frequently and regularly for several years, I don't consider myself a "power user" and I picked up several good tips for being a more effective developer with NetBeans after reading this second part of the first chapter.


Chapter 2: Developing Web Applications with Servlets and JSPs

The second chapter of Java EE 6 Development with NetBeans 7 introduces development of JavaServer Pages (JSP) with NetBeans 7. This is the first example (of several) in the book where the Java EE topic is introduced at a general and beginning level rather than focusing solely on what's new to Java EE with Java EE 6. In other words, the treatment of JSP development with NetBeans is approached in a manner that allows even developers unfamiliar with JSPs to start using NetBeans to develop web pages based on JSP. Being fairly comfortable with JavaServer Pages, there wasn't a lot new here for me, but it was interesting to see how much presentation assistance NetBeans provides for generating JSPs.

The second chapter also covers development of Java servlets and use of JSP fragments. It again approaches these as if the reader has little or no background with these. The chapter also covers form-based authentication in some detail and talks about the general Java EE support for form-based authentication as well as GlassFish-specific support for form-based authentication.


Chapter 3: Enhancing JSP Functionality with JSTL and Custom Tags

Chapter 3 builds on the second chapter's introduction to JavaServer Pages. Heffelfinger first explains why custom JSP tags can lead to better JSP development and maintenance. The chapter then introduces NetBeans 7 support for core JSTL (JavaServer Pages Standard Tag Library) tags such as if, choose, and forEach.

Heffelfinger covers NetBeans 7 support for JSTL SQL tags. He demonstrates creating JSP code using NetBeans 7 JSTL support for all of the CRUD operations. I think it's generally a bad idea for multiple reasons to access a database directly from the JSP source code. Although coverage of the JSTL SQL tags is included in the book, the author also warns that the JSTL SQL tags "tend to create applications that are hard to maintain, since they mix database access with display logic." From his coverage of NetBeans support for using JSTL tags, Heffelfinger moves onto coverage of using NetBeans to generate the tag file for one's own custom JSP tags.


Chapter 4: Developing Web Applications using JavaServer Faces 2.0

The fourth chapter covers JavaServer Faces. This is one of the subjects covered in this book that I have the least familiarity with, so reading it gave me a chance to see coverage of a topic from a less experienced reader's point of view. I was pleased to learn that JSF, like other aspects of Java EE, has reduced much of its configuration requirements via annotations. It was also useful to read about when and why web.xml and faces-config.xml are required when developing JSF applications. Topics such as creating a basic input page with JSF, validating input with JSF, and providing a confirmation page with JSF are discussed in this chapter.

The chapter concludes by covering two major features new to JSF 2: using Facelets templating and JSF 2.0 custom components (composite components).

This chapter is available for download as a sample chapter from the book's main page.


Chapter 5: Elegant Web Applications with PrimeFaces

Although I have a little experience with JSF, I have never used PrimeFaces, so this chapter was entirely new to me. The PrimeFaces main web page describes it as a "lightweight open source component suite for Java Server Faces 2.0 featuring 100+ rich set of JSF components." The PrimeFaces Showcase (referenced in the chapter) shows off some of PrimeFaces's impressive visual features and components.

I had not realized that PrimeFaces is bundled with NetBeans 7, but Heffelfinger demonstrates how to configure NetBeans to use PrimeFaces and provide features such as code completion related to PrimeFaces. It is clear to me after reading this chapter that PrimeFaces does indeed make use of JSF much simpler and NetBeans 7 makes the use of JSF and PrimeFaces much easier. The combination of NetBeans 7 with JSF 2 and PrimeFaces seems to put ease of development much closer to that of Flex.


Chapter 6: Interacting with Databases through the Java Persistence API

I'm a big fan of the Java Persistence API and am happy to see it get a chapter's focus in Java EE 6 Development with NetBeans 7. The chapter introduces JPA and creation of a JPA entity to be used in a JDF application. The default EclipseLink implementation of JPA employed by the NetBeans-bundled GlassFish is used. Although the JPA example specifically uses the NetBeans-bundled JavaDB relational database implementation, information is provided on what is necessary to connect to other data sources.

Heffelfinger provides all the information needed for someone who had never used JPA before to build his simple example in NetBeans 7 using the bundled application server, bundled database, and bundled JPA implementation. I also like that he discusses using NetBeans 7's feature to implement Data Access Object design pattern via JPA Controller Classes. The generated classes provide basic CRUD support for the entities specified using the NetBeans 7 wizard.

The JPA chapter includes coverage of a new feature in JPA 2 and Java EE 6: bean validation. The chapter also covers how to use NetBeans 7 to generate entity beans and named queries from an existing database and then concludes with coverage of creation of a JSF application from an entity bean.


Chapter 7: Implementing the Business Tier with Session Beans

After introducing the concept of Enterprise Java Beans (EJBs) in general, this chapter delves immediately into creating session beans in any of three NetBeans 7 project types. The chapter demonstrates creation of a stateless session bean with NetBeans 7 and deploying it with a Java client library. The chapter also covers some defining features of EJBs such as transaction support and EJB timer service.

The chapter calls out many new features of Java EE 6: allowing EJBs to be deployed in WAR files, the introduction of singleton session beans (in addition to preexisting stateless and stateful session beans), removal of requirement for local interfaces, and aspect-oriented programming via interceptors. Heffelfinger concludes the chapter by describing how to "completely generate the data access layers of our application without having to write a single line of Java code."


Chapter 8. Contexts and Dependency Injection (CDI)

CDI support is one of the most significant new features of Java EE 6, so it is not surprising that an entire chapter of Java EE 6 Development with NetBeans 7 is devoted to this subject. Although CDI can be used to "integrate various kinds of components in a loosely coupled but typesafe way" (Java EE Tutorial), it is most typically used to "make it easy for developers to use enterprise beans along with JavaServer Faces technology in web applications" (Java EE Tutorial). Chapter 8 of Java EE 6 Development with NetBeans 7 covers use of CDI and explains the "additional functionality that the CDI API provides over standard JSF."


Chapter 9: Messaging with JMS and Message Driven Beans

Chapter 9 covers the Java Message Service and describes JMS as "a standard Java EE messaging API that allows loosely coupled, asynchronous communication between Java EE components." I have found JMS 1.1 relatively easy to use, but its verbose boilerplate code is tedious to write (hence the popularity of Spring Framework's JMS Messaging).

Heffelfinger demonstrates how to use NetBeans 7 to generate much of this verbose boilerplate code normally associated with JMS. Although he talks about both queues and topics, his example focuses on creating a queue and on creating an associated connection factory. He demonstrates using NetBeans 7 to deploy newly created destination and connection factory and to create a JMS client against the deployed destination. Finally, creation of a message-driven bean (MDB) to process sent messages is demonstrated with NetBeans 7.


Chapter 10: SOAP Web Services with JAX-WS

Chapter 10 covers the general principle of a web service (whether SOAP-based or REST-based) before focusing exclusively on SOAP-based web services (REST is covered in the next chapter). I cannot think of a better candidate for the need of good tools to help with development than the SOAP-based web service. A common theme in Java EE 6 Development with NetBeans 7 is that of using NetBeans 7 to reduce the boilerplate code a developer needs to write. There are many areas of Java EE 6 where this is true, but it is no more true than in the area of SOAP-based web services and JAX-WS.

Heffelfinger opens up his discussion on NetBeans 7 support for SOAP-based web services by introducing WSDL and by discussing how NetBeans 7 allows for either top-down (contact first with Java generated from existing WSDL) or bottom-up (WSDL generated from existing Java classes) development of SOAP-based web services. He provides an example of generating a simple length conversion web service using NetBeans 7's wizard, changing the body of the generated methods on the properly annotated Java POJO, and automatically generating WSDL and a client to test the simple web service.

The second example and third example use JAX-WS to expose a stateless session EJB as a web service. One of these examples demonstrates this by creating the EJB in conjunction with creation of a web service and the other of these examples demonstrates this by creating a web service on an existing EJB.

There are many who argue that contract-based, top-down web service design is the preferred approach. This is demonstrated in this chapter via an example that shows generation of Java classes with stub methods based on a provided existing WSDL.


Chapter 11: RESTful Web Services with JAX-RS

One of the most exciting additions to Java EE 6 is that of JAX-RS to support RESTful web services. I have blogged on REST and on JAX-RS before and really like much about both. It is nice to see a chapter of Java EE 6 Development with NetBeans 7 devoted to JAX-RS and REST in Java EE 6 with NetBeans.

Heffelfinger begins his coverage of Java EE 6/JAX-RS support in NetBeans 7 with a discussion on and demonstration of generating a REST-based web service from an existing database. The discussion includes details of what NetBeans does to make this happen, including the use of JPA facsdes and the typical use of Jersey.

As was done for coverage of NetBeans 7 with JAX-WS, this chapter demonstrates how to use NetBeans 7 to test a newly created REST-based web service and how to use NetBeans 7 to generate a client of the REST-based web service. I thought it was interesting, albeit not surprising, that the client API used for the generated client is Jersey's Client API. This makes it easy for NetBeans 7 to create methods for handling both XML and JSON.


Appendix A: Debugging Enterprise Applications with the NetBeans Debugger

I'm not normally the type of reader to "skip to the end," but I must admit that I read the Appendices first in this case. The reason for this is that I was curious regarding what the author had to say regarding debugging and profiling in NetBeans 7. For the most part, the coverage of both debugging and profiling in NetBeans 7 is largely applicable to any Java development, enterprise or standard.

Appendix A covers debugging with NetBeans 7 and does provide some information specific to debugging Java EE applications. The chapter describes using NetBeans 7 with the embedded GlassFish instance to essentially boil initial enterprise debugging steps down to a single step. Another piece of the NetBeans 7 debugging coverage that is specific to Java EE is the example itself. The example is intentionally broken so that debugging effort is needed and the example is based on Java EE technologies JSF, CDI, and JPA.

Fortunately for developers familiar with using NetBeans for debugging standard Java applications, the process for debugging enterprise Java applications is very similar. For example, the steps of setting breakpoints, stepping over, stepping into, and using the Local Variables window are the same as for standard applications.


Appendix B: Identifying Performance Issues with the NetBeans Profiler

The final portion of Java EE 6 Development with NetBeans 7 is an appendix focused on profiling with NetBeans 7. Appendix B is a relatively short appendix, but it does give an overview of the types of information that NetBeans 7 provides that can be used to identify performance issues. There is some discussion of how memory leaks can occur in Java, a principle worth understanding whether working on standard or enterprise Java applications.


The Drawbacks

Nothing is perfect and no book is perfect. Although there are some issues with Java EE 6 Development with NetBeans 7, they tend to be very minor and are not overly distracting. There is the occasional expected erratum and I thought a few of the sentences were a little too choppy, but the message was always relayed. Overall, the text was highly readable and was conducive to relaying the message rather than distracting from it.

It would be easy to say that the most significant drawback of the book is that it doesn't cover every single NetBeans feature or every single nuance of Java EE. However, I'd argue that details of that level are best left to books that are exclusively focused on particular aspects. For example, I'd expect to use a book centered on JavaServer Faces to learn the gritty details of using JSF. The focus of Java EE 6 Development with NetBeans 7 is clearly on introducing development of Java EE 6 applications using NetBeans 7 as its title implies. The book is written so that developers are only expected to have basic Java SE familiarity, but can be new to both Java EE and NetBeans. I like the author's style of introducing the most important concepts at a high level, showing them in demonstrations, and then referring to other resources for details that would have perhaps gotten in the way if covered in the introductory text.

This book is perfect for the developer who wishes to get a thorough introduction to Java EE and NetBeans 7, but it is not (and I doubt it was intended to be) a comprehensive Java EE reference. Similarly, it is also not a comprehensive NetBeans 7 reference. However, it does cover a wide swath of the most important features of both individually and as used together.


Other Characteristics

Although Java EE 6 Development with NetBeans 7 is almost 400 pages in length, it reads much more quickly than similar technical books of similar size because of the numerous screenshots. There are significant code samples included as well, which may lead to a reader spending more or less time than he or she would on text.

According to the book's web page, Java EE 6 Development with NetBeans 7 was released in June 2011 and has an ISBN of 1849512701. It is written in English and is available in printed format or in multiple electronic formats (PDF or ePub download or via PacktLib). I reviewed the downloaded PDF version.


Conclusion

I enjoyed reading and reviewing Java EE 6 Development with NetBeans 7. Because I have done most of my Java EE development with a different IDE and have used NetBeans mostly for Java SE/Spring/Groovy development, it was an eye-opener to see how useful NetBeans 7 can be for Java EE development. I also learned quite a bit about areas of Java EE that I am less familiar with (CDI, JSF, PrimeFaces) and even learned some smaller but still useful tips regarding areas of Java EE I am more familiar with.

Java EE 6 Development with NetBeans 7 provides introductory coverage to Java EE 6. It does not focus solely on topics new to Java EE 6, but instead covers Java EE as a whole from an introductory level and happens to include some Java EE 6 new features in that coverage. There are some entire new chapters on entirely new Java EE 6 features such as CDI and JAX-RS support, but most of the chapters include relevant Java EE topics that were the same clear back in the days of J2EE.

Java EE 6 Development with NetBeans 7 demonstrates via discussion and numerous screenshots how to employ NetBeans 7 and its many wizards to generate significant code and configuration for a Java EE 6 project. Best and common practices related to Java EE 6 development are sprinkled throughout this introductory discussion and references to online resources with greater detail are provided.

Java EE 6 Development with NetBeans 7 is particularly beneficial for developers with little or no Java EE experience who want to use NetBeans 7 to generate Java EE 6 applications. In a single book, such developers can find solid introductory coverage of both Java EE 6 topics and how to use NetBeans 7 to most easily employ those features. Even developers new to Java EE who are not necessarily planning on using NetBeans may find this useful as they could use NetBeans 7 to generate boilerplate code and configuration files that they could use to learn what they needed to write or maintain in their own preferred IDE.