Ed Ort
Enterprise Tech Tip: Using CDI and Dependency Injection for Java in a JSF 2.0 Application
The next release of the enterprise Java platform, Java EE 6 includes a number of powerful new technologies and well as significant enhancements to existing technologies. Two of the new technologies are JSR 299: Contexts and Dependency Injection (CDI) (referred to in earlier times as Web Beans) and JSR 330: Dependency Injection For Java. One of the significantly enhanced technologies is JSR 314: JavaServer Faces 2.0.
CDI defines a set of services for the Java EE environment that makes applications much easier to develop. Perhaps most significantly, CDI unifies and simplifies the Enterprise JavaBeans (EJB) and JavaServer Faces (JSF) programming models. It allows enterprise beans to act as managed beans in a JSF application.
Until now there has not been a standard approach for annotation-based dependency injection. Dependency Injection For Java changes that by introducing a standard set of annotations that can be used for dependency injection.
If you're involved with creating user interfaces (UIs) for web applications, you're probably familiar with JavaServer Faces. It's a technology that provides a server-side component framework that is designed to simplify the development of UIs for Java EE applications. The latest release of the technology, JSR 314: JavaServer Faces 2.0, makes UI development for Java EE applications even easier through support for annotations and the addition of new features such as Facelets and composite components.
You can get a good idea of how these technologies simplify web application development by reading the Tech Tip Using CDI and Dependency Injection for Java in a JSF 2.0 Application, written by Roger Kitain, the JavaServer Faces co-specification lead. Roger presents a JSF 2.0 application and shows in the source code where CDI components and Dependency Injection for Java annotations play a role.
Posted at 09:59AM Oct 30, 2009 by edort in Tech Tip | Comments[0]
Enterprise Tech Tip: Locking and Concurrency in Java Persistence 2.0
One of the real success stories behind Java EE 5 is the Java Persistence API, know informally as JPA. The technology has been widely adopted and is recognized as the enterprise standard for Object/Relational (O/R) persistence.
However, one of the shortcomings of JPA 1.0 is that the only type of locking it supports is optimistic locking. Recall that locking is a technique for handling database transaction concurrency. When two or more database transactions concurrently access the same data, locking is used to ensure that only one transaction at a time can change the data.
There are generally two locking approaches: optimistic and pessimistic. Optimistic locking assumes that there will be infrequent conflicts between concurrent transactions, that is, they won't often try to read and change the same data at the same time. In optimistic locking, the objective is to give concurrent transactions a lot of freedom to process simultaneously, but to detect and prevent collisions. Two transactions can access the same data simultaneously. However, to prevent collisions, a check is made to detect any changes made to the data since the data was last read.
Pessimistic locking assumes that transactions will frequently collide. In pessimistic locking, a transaction that reads the data locks it. Another transaction cannot change the data until the first transaction commits the read.
The next release of JPA, JPA 2.0, which will be offered as part of Java EE 6, adds support for pessimistic locking. Using JPA 2.0, you can lock an entity either optimistically or pessimistically, depending on how often you think transactions will collide.
To learn about the new locking support in JPA 2.0, see the Tech Tip Locking and Concurrency in Java Persistence 2.0 by Carol McDonald.
Posted at 02:24PM Sep 29, 2009 by edort in Tech Tip | Comments[0]
Enterprise Tech Tip: A Sampling of EJB 3.1
Enterprise JavaBeans (EJB) technology has taken a number of knocks in the past. When it was first introduced some, perhaps many, cried that it was too complicated, with a lot of programming overhead that made the technology needlessly difficult to use.
Over time things have improved dramatically. Features such as annotations in EJB 3.0 made the technology much, much easier to use. Those ease-of-use advancements continue with the upcoming release of EJB 3.1, which will be included in Java Platform, Enterprise Edition (Java EE) 6. A preview version of Java EE 6 is currently available for download. The preview version includes a nearly complete implementation of EJB 3.1
If you want to learn about some of the new, cool features in EJB 3.1, see the Tech Tip, A Sampling of EJB 3.1, written by Ken Saks, the EJB 3.1 Specifical Lead.
Posted at 08:54AM Jun 26, 2009 by edort in Tech Tip | Comments[0]
Enterprise Tech Tip: Jersey and Spring
There have been a number of interesting Enteprise Tech Tips about JAX-RS and Jersey. These include Implementing RESTful Web Services in Java, Configuring JSON for RESTful Web Services in Jersey 1.0, and Consuming RESTful Web Services With the Jersey Client API. Recently, another interesting Tech Tip on Jersey made an appearance. This one covers Jersey's support for the Spring Framework.
Spring is a very popular enterprise Java framework, and if you're a Spring user who is also interested in JAX-RS, check out this tip.
Posted at 05:33PM Apr 15, 2009 by edort in Tech Tip | Comments[0]
Two new Tech Tips
I'd like to highlight two interesting Enterprise Tech Tips that were added over the last few months to the Enterprise Tech Tips blog. The first, Converged Enterprise Applications, by Prasad Subramanian, is a follow up to an earlier tip on Session Initiation Protocol (SIP) servlets and their use in voice-related applications. The earlier tip introduced the concept of a converged enterprise application -- an enterprise application that has a SIP servlet application bundled within it. The follow-up tip goes into more detail about this concept and provides a working example. Prasad Subramanian is the project lead for the Sailfin project, an open source implementation of a SIP servlet container using the GlassFish application server.
The second tip covers Jersey's support for Spring. The tip is written by Paul Sandoz, co-spec lead and implementation lead for JSR-311, the Java API for RESTful Web Services (JAX-RS). Jersey is an open-source, production-ready reference implementation of JAX-RS. Spring is a popular framework for building and running enterprise Java applications. Jersey has integrated support for Spring. This tip shows you how to take advantage of that support. It shows you how to configure Spring with Jersey and use Jersey's Spring-related features.
And by the way, if your a quiz aficianado, try the Tech Tips quiz.
Posted at 11:17AM Apr 13, 2009 by edort in Tech Tip | Comments[0]
Enterprise Tech Tip: Configuring JSON for RESTful Web Services in Jersey 1.0
There's a lot of interest in the developer community in RESTful web services. That's because the Representational State Transfer (REST) approach presents a relatively simple and flexible way of building and communicating with web services. Message exchanges with a RESTful web service can be conducted in any format, including JavaScript Object Notation (JSON). Because of its simple text format, JSON provides a good alternative to other message interchange formats such as XML and is particularly attractive as a meassage interchange format for RESTful web services.
This tip shows you how to build a Jersey-based web application that returns information in JSON format. Jersey is an open-source, production-ready reference implementation of JAX-RS, the Java API for RESTful Web Services (JSR-311).
See the tip Configuring JSON for RESTful Web Services in Jersey 1.0.
Posted at 08:44AM Oct 31, 2008 by edort in Tech Tip | Comments[0]
Enterprise Tech Tip: Using WS-Trust Support in Metro to Secure Web Services
This is another in a series of Tech Tips related to Metro, the high performance, extensible, easy-to-use web services stack that is implemented in the GlassFish application server. This one, written by Jiandong Guo, a senior member of the Application Server Web Services Security GroupWeb Services Security, focuses on the support in Metro for WS-Trust. You will learn the basics of WS-Trust and its Security Token Service (STS) framework. You'll also learn about the support in Metro for WS-Trust and STS. And you'll see how easy it is to take advantage of this support to secure a web service using Metro and the NetBeans IDE.
See the tip Using WS-Trust Support in Metro to Secure Web Services.
Posted at 09:15AM Oct 21, 2008 by edort in Tech Tip | Comments[0]
Enterprise Tech Tip: Composite UI Components in JSF 2.0 -- Part 2
As I mentioned in my previous post, this two-part Tech Tip introduces a powerful new feature in JavaServer Faces (JSF) 2.0 technology: composite user interface (UI) components. Part 1 of the tip shows you how create a composite UI component and use it in a web application.
Part 2 is now available. It shows you how to add functionality (through attached validators, converters, action listeners, and value change listeners) to the composite component you created.
See Composite UI Components in JSF 2.0 -- Part 1 and Composite UI Components in JSF 2.0 -- Part 2.
Posted at 09:07AM Sep 15, 2008 by edort in Tech Tip | Comments[0]
Enterprise Tech Tip: Composite UI Components in JSF 2.0 -- Part 1
This Tech Tip introduces a powerful new feature in JavaServer Faces (JSF) 2.0 technology: composite user interface (UI) components. This feature allows you to turn any collection of page markup into a JSF UI component -- with attached validators, converters, action listeners, and value change listeners -- for use by page authors.
This tip is presented in two parts. In the first part, you'll learn you how create a composite UI component and use it in a web application. In the second part, which will be published in the next issue of the Enterprise Tech Tips, you'll learn how to add functionality to the composite component.
See Composite UI Components in JSF 2.0 -- Part 1.
Posted at 08:55AM Sep 02, 2008 by edort in Tech Tip | Comments[0]
Enterprise Tech Tip: Using P6Spy and the GlassFish Connection Pool to Trace Database Operations
Detecting performance bottlenecks is an important task in optimizing database operations in an application. One way to do that is to trace the database operations of the application. This information can help you fine tune the database calls that the application makes and in this way improve the application's performance. In this Tech Tip, Sun engineer Jagadish Ramu demonstrates how to use a tool called P6Spy to trace the database requests issued by an application running with the GlassFish v2 application server. Specifically, you'll learn how to trace SQL statements from an application that uses GlassFish's JDBC Connection Pool. It's all covered in the tip Using P6Spy and the GlassFish Connection Pool to Trace Database Operations.
Posted at 09:46AM Jul 15, 2008 by edort in Tech Tip | Comments[0]