|

楼主 |
发表于 2007-4-10 11:20:54
|
显示全部楼层
Version 5 of the Java Platform, Enterprise Edition (Java EE, formerly referred to as J2EE), has arrived. Its streamlined features offer added convenience, improved performance, and reduced development time, all of which enable developers to bring products to market faster.
To get an update on the Java EE 5 platform, we met with Java EE specification lead Bill Shannon, a Distinguished Engineer at Sun Microsystems. Shannon has been with Sun since 1982 and previously worked on the JavaMail API, the HotJava Views product, the Common Desktop Environment (CDE), the Solaris Operating Environment, and all versions of SunOS. He graduated from Case Western Reserve University with an MS in Computer Engineering.
Can you give developers some specific ways that Java EE 5 will reduce the amount of code they need to write?
There are so many ways we've made life simpler for developers, it's hard to know where to start. To some extent, the amount of improvement you'll see is based on the tools you use.
I think one of the biggest improvements is that, in most cases, you no longer need to use deployment descriptors. Even something as simple as combining modules together into an "ear" file used to require a deployment descriptor to list where the modules were. Now all you need to do is to put the modules in the ear file in an obvious way, follow some simple conventions like putting all your shared libraries in the "lib" directory, and that's it.
Here's a simple programming example. Previously, to create a web service, you needed to write a Java interface that describes the web service API, a Java class that implements the web service, a deployment descriptor that tells the container about the web service, and a configuration file that tells the web service runtime how to map Java classes to web service operations. Much of this was boilerplate that changed little from application to application. In Java EE 5 all of this can be done by writing a single Java source file -- the class that implements the web service. The rest is taken care of for you by the container, based on annotations you include in your source code, and based on default rules for what to do when no annotations are present.
Here's the complete source code for a simple web service:
package endpoint;
import javax.jws.WebService;
@WebService
public class Hello {
public String sayHello(String param) {
return "Hello " + param;
}
}
Time Saved
"There are so many ways we've made life simpler for developers, it's hard to know where to start."
Bill Shannon
Distinguished Engineer, Sun Microsystems
Can you estimate how much time a developer would save in developing an enterprise application with Java EE 5 compared with J2EE 1.4?
Of course that's difficult to measure and depends a lot on the type of application you're developing. For a relatively simple app, the time to develop the application may be proportional to the number of lines of code in the app. For simple apps, we've probably reduced the number of lines of code you need by half. And if you factor in the reduction in the number of concepts you need to understand in order to write such apps, the time to develop the application is even less. For larger enterprise class apps, the bulk of the application is likely to be the actual business logic of the app, and the reduction in lines of code won't be as great. But the reduction in the number of concepts you need to learn will help, and the overall simplification will reduce the drudgery of creating such an app. You really can focus all your attention on your business logic.
Take us through the importance of annotations in Java EE 5.
Java EE has always promoted a declarative approach for many aspects of enterprise application development. Without support in the Java language for this style of programming, we used external files -- deployment descriptors -- to hold this declarative information. The use of annotations allows us to move this information into the source code, which is where it belongs in most cases.
So, instead of calling an API to request the container to do something for you, and instead of writing a deployment descriptor that has to be synchronized with the code you're writing, you can put your request for the container right in the code. You can say "please expose this class as a web service" or "please start a transaction when this method is called".
"If you were scared off of J2EE because it seemed too complex, it's time to take another look."
Bill Shannon
Distinguished Engineer, Sun Microsystems
Of course, this new capability in no way removes or interferes with older capabilities. There are cases in which a deployment descriptor is the right approach, and you can continue to use them when desired.
If you could speak to an audience of 1000 talented developers who were on the fence, and considering moving to Java EE 5, what would you say to them?
This is not your father's J2EE!
If you were scared off of J2EE because it seemed too complex, it's time to take another look. If you've been attracted to alternative technologies such as Spring and Hibernate, you'll find many of the good ideas from those technologies in Java EE 5.
Take a look at Java EE 5, you'll be amazed at how easy it is. |
|