版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、原文:Java EE 5:Power and productivity with less complexityAn overview of Java EE 5 features and developer-productivity enhancementsMomentum for organizations to adopt Java Platform, Enterprise Edition 5 (Java5) is steadily increasing as the platforms container support, developer tools, educational res
2、ources, and developer-community experience all improve. Get a high-level view of the new productivity features and API enhancements in Java EE 5 and work through a Web service example that demonstrates its simplified development models.IntroductionJava EE technology is an extension to the Java langu
3、age platform that enables you to create scalable, powerful, and portable enterprise applications. It defines four types of containers for application components: Web, Enterprise JavaBean (EJB), application client, and applet. These containers, and the Java APIs each must support, are detailed in an
4、application-server specification that encourages a competitive marketplace for Java EE products while guaranteeing server portability for applications that adhere to the specification .The latest version of the platform, Java EE 5, was released in May 2006. Primarily focused on developer productivit
5、y, Java EE 5 brings simpler programming models without sacrificing any of the platforms power and richness. Two mechanisms Java annotations and better defaults are responsible for most of its simpler development models. Major functional improvements include enhanced Web services support and incorpor
6、ation of JavaServer Faces (JSF) and the Java Standard Tag Library (JSTL) into the platform.Web services technologiesThe introduction of annotations into Java EE 5 makes it simple to create sophisticated Web service endpoints and clients with less code and a shorter learning curve than was possible w
7、ith earlier Java EE versions. Annotations first introduced in Java SE 5 are modifiers you can add to your code as metadata. They dont affect program semantics directly, but the compiler, development tools, and runtime libraries can process them to produce additional Java language source files, XML d
8、ocuments, or other artifacts and behavior that augment the code containing the annotations . Later in the article, youll see how you can easily turn a regular Java class into a Web service by adding simple annotations.A leap forward in Web services supportThe cornerstone of Web services support in J
9、ava EE 5 is JAX-WS 2.0, which is a follow-on to JAX-RPC 1.1. Both of these technologies let you create RESTful and SOAP-based Web services without dealing directly with the tedium of XML processing and data binding inherent to Web services. Developers are free to continue using JAX-RPC (which is sti
10、ll required of Java EE 5 containers), but migrating to JAX-WS is strongly recommended. Newcomers to Java Web services might as well skip JAX-RPC and head right for JAX-WS. That said, its good to know that both of them support SOAP 1.1 over HTTP 1.1 and so are fully compatible: a JAX-WS Web services
11、client can access a JAX-RPC Web services endpoint, and vice versa.The advantages of JAX-WS over JAX-RPC are compelling. JAX-WS: Supports the SOAP 1.2 standard (in addition to SOAP 1.1). Supports XML over HTTP. You can bypass SOAP if you wish.Uses the Java Architecture for XML Binding (JAXB) for its
12、data-mapping model. JAXB has complete support for XML schema and better performance (more on that in a moment).Introduces a dynamic programming model for both server and client. The client model supports both a message-oriented and an asynchronous approach.Supports Message Transmission Optimization
13、Mechanism (MTOM), a W3C recommendation for optimizing the transmission and format of a SOAP message.Upgrades Web services interoperability (WS-I) support. (It supports Basic Profile 1.1; JAX-WS supports only Basic Profile 1.0.)Upgrades SOAP attachment support. (It uses the SOAP with Attachments API
14、for Java SAAJ 1.3; JAX-WS supports only SAAJ 1.2.)The wsimport tool in JAX-WS automatically handles many of the mundane details of Web service development and integrates easily into a build processes in a cross-platform manner, freeing you to focus on the application logic that implements or uses a
15、service. It generatesartifacts such as services, service endpoint interfaces (SEIs), asynchronous response code, exceptions based on WSDL faults, and Java classes bound to schema types by JAXB.JAX-WS also enables high-performing Web services. See resource for a link to an article (Implementing High
16、Performance Web Services Using JAX-WS 2.0) presenting a benchmark study of equivalent Web service implementations based on the new JAX-WS stack (which uses two other Web services features in Java EE 5 JAXB and StAX) and a JAX-RPC stack available in J2EE 1.4. The study found 40% to 1000% performance
17、increases with JAX-WS in various functional areas under different loads.Web application technologiesJava EE 5 welcomes two major pieces of front-end technology JSF and JSTL into the specification to join the existing JavaServer Pages and Servlet specifications. JSF is a set of APIs that enable a com
18、ponent-based approach to user-interface development. JSTL is a set of tag libraries that support embedding procedural logic, access to JavaBeans, SQL commands, localized formatting instructions, and XML processing in JSPs. The most recent releases of JSF, JSTL, and JSP support a unified expression l
19、anguage (EL) that allows these technologies to integrate more easily.JSF 1.2JSF has built-in support for common UI concerns such as component state management, event handling, navigation, user-input validation, and internationalization. Expert developers can create customized, powerful, reusable com
20、ponents or create custom renderers for client devices other than a Web browser. Less-technical users can reuse custom components, including the default JSF tag library for HTML interfaces, in visual programming environments such as Sun Java Studio Creator. This puts the creation of sophisticated Web
21、 presentation layers within reach of novice programmers.A growing landscape of third-party JSF components exists in both the open source community and the licensed-software realm. Youll turn up dozens of options by searching for JSF components or JSF component libraries on the Web. Many of these com
22、ponents rely on Asynchronous JavaScript + XML (Ajax) techniques, which are a driving force behind the Web 2.0 experience. Web programmers can use them to create applications that offer a better user experience than traditional Web applications, without needing to fuss with the details of writing Aja
23、x components from scratch.JSP 2.1JSP technology has been around since J2EE 2.1. It leverages the Java Servlet specification to enable declarative programming of a UI. It supports programming UIs as documents that are translated into Java servlets, compiled, and invoked by the Web application contain
24、er to service requests. These documents typically mix JSP directives and scriptlets with a presentation markup language such as HTML. JSPs can use an older syntax that relies on special tags that start with , or on a newer syntax that is well-formed XML. They typically serve as the View part of a Mo
25、del-View-Controller (MVC) UI framework.JSP 2.1 and JSF 1.2 are more mutually compatible than prior releases, primarily because of the integration of their EL syntax into the unified EL. EL enables operations such as:Accessing properties of JavaBeans in the request, session, and applicationcontexts.P
26、erforming logical tests that determine such choices as whether to hide or show a particular element.Performing calculations that affect numbers and strings that appear in the UI. In the past, there were differences in the JSP and JSF EL syntax and how thecontainer evaluated them. The unified EL reso
27、lves these differences while also adding features such as:A pluggable framework to enable customization of EL interpretation.Support for deferred expressions that can be executed as needed by a JSP tag handler.Support for assignment operations that can, for example, use an EL expression to set a pro
28、perty on a JavaBean from within JSP code.A boon for JSP tag-library developers is that tag handlers now support resource injection using annotations, so tags that once required resource configuration and code to perform Java Naming and Directory Interface (JNDI) lookups can now be greatly simplified
29、.JSTL 1.2JSTL has been around for years, but until Java EE 5, it existed outside of the Java EE umbrella. JSTL tags provide support for embedding the following types of elements in JSPs:Procedural logic, such as loops and if/else switches.Access to JavaBeansthat can provide dynamic data to the UI or
30、 be modified byUI code.SQL commandsto perform database access.Formatting instructionsthat format UI output according to specific locales. XML processing, such as Document Object Model (DOM) parsing orExtensible Stylesheet Language (XSL) transformations.JSTL 1.2 is a maintenance release that supports
31、 the unified EL and resolves issues that used to arise from trying to mix JSF tags and JSTL iteration tags in the same JSP page.Java Servlet 2.5The Java Servlet specification the backbone of Java Web-tier technology is as old as Java EE technology itself. The specification is designed to provide a h
32、igh-performing, component-based approach to building Web applications that are portable across any servers that implement the specification.The Servlet 2.5 specification required by Java EE 5 is a maintenance release that includes minor improvements over the 2.4 release. It introduces a dependency o
33、n theJava 5 platform along with some annotations that reduce the need for configuration in the Web application deployment descriptor (web.xml) configuration file. Additional configuration conveniences have been added, such as more-flexible servlet configuration with wildcarding and multiple url-patt
34、ern elements.Java Persistence API (JPA 1.0)JPA introduces an object-relational mapping (ORM) framework for persisting Java objects. It was developed with EJBs in mind, but it can be used for any Java objects. Using annotations, you indicate which objects and fields are persistent and which database
35、tables and columns they map to. JPA supports a rich query language that resembles SQL. The query language enables:Definition of parameterized queries that can take parameters as an ordered list, referred to by index numbers, or as named parameters referred to by name.Queries that traverse the relati
36、onships between persistent entities without requiring JOIN statements (though you can use JOIN statements if you prefer).Typical SQL-like features to form search criteria (comparison operators, LIKE statements, BETWEEN statements, and so on) and define how to treat the result set (using operators su
37、ch as DISTINCT, ORDER BY, GROUP BY, and so on.)JPA brings new functionality to the Java EE platform, relieving many of the past headaches of roll-your-own or container-specific persistence approaches.Management and securityJava EE 5 requires the same three management and security specifications that
38、 are available in prior versions:Application Deployment provides an API for deploying components and applications to a Java EE container. Tools can access this API to deploy code to a Java5 container without restarting the container. IDEs often use this API to enable rapid code/test/fix cycles durin
39、g development.Application Management specifies required attributes and operations of objects managed by the container. Its compatible with various industry-standard management protocols.Authorization Contract for Containers (Java ACC) defines the semantics of security-policy providers and how to aut
40、horize access to operations managed within this contract. It requires that containers implement interfaces that enable deployment tools to manage authorization roles.Each of these specifications in Java EE 5 is a maintenance release (each advances from version 1.0, introduced in J2EE 1.4, to version
41、 1.1), with minor enhancements that are too detailed for this articles scope. Follow the Java EE Management and Security Technologies link in resources for more information.Java EE 5 is backward-compatible with prior EJB deployment descriptors. You can even mix approaches if you wish, allowing legac
42、y code to specify EJBs using descriptors while new EJBs are declared with annotations.Aside from the reduction in the amount of code it takes to get the job done, annotations enable a maintenance benefit from what Sun architect Graham Hamilton refers to as truth-in-source-code (see Resources): With
43、a properly annotated class, you dont need to look at both source code and configuration files to understand what is going on because the annotations that define special behavior are right there in the source code.For a code-intensive review of many other examples of how annotations ease application
44、development in Java EE 5, see Roland Barcias article Get to know Java EE 5.Reasonable defaultsThe fact that RideStatistics can become a Web service just by the addition of a single annotation also shows another Java EE 5 design principle in action: providing reasonable defaults to enable simpler pro
45、gramming models.In this case, JAX-WS assumes that any public method in a class annotated with WebService should be turned into a Web service operation that bears the same name as the method. Similar assumptions are made when the input and output parameters for these methods are processed. If you don
46、t want the default behavior, you can always modify it by annotations on the methods. But in many cases, youll probably want the terms used in the Web service to match terms used in the class that implements the Web service, and JAX-WS makes this easy to accomplish by providing reasonable defaults.Co
47、nclusionIn the past, the benefits of Java EE technology have come only to those willing to wrestle with its complexity or tame it using development tools. It has earned a reputation as overly burdensome, a platform to consider only when a large, enterprise-grade system needs its powerful features an
48、d has the resources to deal with the development difficulty.Java EE 5 seeks to shatter this reputation by leveraging new language features such as annotations, design goals such as reasonable defaults, and an emphasis on simpler programming models to provide an accessible, powerful platform for ente
49、rprise application development. Simpler programming models also make development shops less reliant on third-party tools to manage unnecessary complexity. The net result for people footing the bill is that its now significantly less expensive to develop ever-more powerful enterprise applications. Th
50、e net result for developers isthat you can spend less time wrestling with the platform and more time impressing your managers with rapidly developed features built upon it.Development shops that have shied away from Java EE technology in the past should give it a fresh look, and developers and maint
51、ainers of existing J2EE applications should explore Java EE 5 to discover the many ways it can make their lives easier.译文:JavaEE5 :强大的功能、高生产率和低复杂性概述 Java EE 5 特性和提高开发人员生产率的改进随着平台的容器支持、 开发人员工具、 培训资源和开发人员社区体验等方面的改善,推动组织采用 Java? Platform, Enterprise Edition 5 ( Java EE 5)的动力正在稳定增长。本文从较高层面介绍 Java EE 5 中
52、新的生产率特性和 API 改进,并通过一个 Web 服务示例展示简化的开发模型。简介Java EE 技术是Java 语言平台的扩展,支持开发人员创建可伸缩的强大的可移植企业应用程序。它为应用程序组件定义了四种容器:Web、 EnterpriseJavaBean(EJB)、应用程序客户机和 applet。一个应用服务器规范详细描述了这些容器和它们必须支持的 Java API,这促使 Java EE 产品相互竞争,同时保证符合这个规范的应用程序可以在服务器之间移植。这个平台的最新版本 Java EE 5 已经于 2006 年 5 月发布。Java EE 5 主要关注提高开发人员的生产率, 它提供了
53、更简单的编程模型, 而没有牺牲平台的任何功能。更简单的开发模型主要由两个机制提供 Java 注解和更好的默认行为。主要的功能性改进包括改进了 Web 服务支持以及在平台中集成了 JavaServer Faces( JSF)和 Java Standard Tag Library(JSTL)。Web 服务技术在 Java EE 5 中引入了注解 (annotation)特性,这简化了复杂 Web 服务端点和客户机的开发,与以前的 Java EE 版本相比,代码更少,学习过程更短了。注解(最早在 Java SE 5 中引入)是可以作为元数据添加到代码中的修饰性代码。它们并不直接影响程序的语义, 但是
54、编译器、 开发工具和运行时库可以通过处理它们生成额外的 Java 语言源文件、 XML 文档或其他工件和行为,这些对包含注解的程序起辅助作用。 在本文后面, 会看到如何通过添加简单的注解, 将常规的 Java 类转换为 Web 服务。Web 服务支持方面的飞跃Java EE 5 中Web 服务支持 的基 础是JAX-WS2.0,它是 一种替 代JAX-RPC 1.1 的技术。这两种技术都支持创建REST 风格和基于SOAP 的Web 服务,而不必直接处理Web 服务固有的XML处理和数据绑定细节。开发人员可以继续使用 JAX-RPC(这仍然需要 Java EE 5 容器),但是强烈建议迁移到
55、JAX-WS 。刚开始学习 Java Web 服务的开发人员可以跳过 JAX-RPC,直接使用 JAX-WS 。它们都支持 SOAP 1.1 over HTTP 1.1,所以完全兼容: JAX-WS Web 服务客户机可以访问 JAX-RPC Web 服务端点,反之亦然。与 JAX-RPC 相比, JAX-WS 有许多优点。 JAX-WS :支持 SOAP 1.2 标准(以及SOAP 1.1)。支持 XML over HTTP 。如果愿意,可以不使用SOAP。使用 Java Architecture for XML Binding( JAXB )作为数据映射模型。 JAXB 完全支持 XML
56、模式,而且性能更好(更多信息见下文) 。为客户机和服务器引入了一个动态编程模型。 客户机模型支持面向消息方式和异步方式。支持 Message Transmission Optimization Mechanism(MTOM ),这是一个用于优化 SOAP 消息传输和格式的 W3C 建议规范。升级了 Web services interoperability (WS-I )支持。(它支持 Basic Profile 1.1; JAX-WS 只支持 Basic Profile 1.0。)升级了 SOAP 附件支持。(它支持 Attachments API for Java SAAJ 1.3:JAX
57、-WS只支持 SAAJ 1.2。)通过阅读文章 “ web服务提示与技巧: JAX-RPC 与 JAX-RPC 的比较 ”,可以进一步了解这些差异。JAX-WS 中的 wsimport 工具自动地处理 Web 服务开发的许多细节,并以跨平台方式集成到构建过程中, 这让开发人员可以将注意力集中于实现或使用服务的应用程序逻辑。它生成各种工件,包括服务、服务端点接口( SEI)、异步响应代码、基于 WSDL 错误的异常以及通过 JAXB 绑定到模式类型的 Java 类。 JAX-WS 还 能 够 提 高 Web 服 务 的 性 能 。 在 文 章 “ Implementing High Perfor
58、mance Web Services Using JAXWS- 2.0 ”中,对基于 JAX-WS 的 Web 服务实现(使用了Java EE 5 中的另外两个Web 服务特性 JAXB 和 StAX )和基于 J2EE 1.4 中的 JAX-RPC 的服务实现做了性能对比。这项研究发现在不同负载下 JAX-WS 在各个功能领域产生了 40% 到 1000% 的性能改进。Web 应用程序技术除了现有的 JavaServer Pages 和 Servlet 规范, Java EE 5 引入了两种前端技术 JSF 和 JSTL。JSF 是一组 API ,支持以基于组件的方式开发用户界面。 JSTL
59、 是一组标记库, 支持在 JSP 中嵌入过程式逻辑、 对 JavaBean 的访问方法、 SQL 命令、本地化格式指令和 XML 处理。 JSF、JSTL 和 JSP 的最新版本支持一种统一表达式语言( expression language,EL),这使这些技术更容易集成在一起。JSF 1.2JSF 为常见的 UI 问题提供了内置支持, 比如组件状态管理、 事件处理、导航、用户输入检验和国际化。 有经验的开发人员可以创建定制的强大的可重用组件,还可以为 Web 浏览器之外的其他客户机设备创建定制的组件。技术经验不足的用户可以在 Sun Java Studio Creator等可视编程环境中重
60、用定制组件,包括用于 HTML 界面的默认 JSF 标记库。这让编程新手也能够创建复杂的 Web 表示层。在开放源码领域和受许可协议限制的软件领域中, 第三方 JSF 组件越来越多了。在 Web 上搜索 “JSFcomponents”或 “JSFcomponent libraries 会”找到几十种组件。许多组件都依赖于 Asynchronous JavaScript + XML(Ajax )技术,这种技术是 “Web 2.0”运动背后的主要驱动力。 Web 程序员可以使用它们创建出比传统 Web 应用程序更好的用户体验,同时避免了从头编写Ajax 组件的麻烦。JSP 2.1JSP 技术是从J
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年度年福建省高校教师资格证之高等教育心理学综合检测试卷B卷含答案
- 2024年度山西省高校教师资格证之高等教育法规押题练习试卷B卷附答案
- 2024年度年福建省高校教师资格证之高等教育学押题练习试卷B卷附答案
- 2024年DVD视盘机和驱动器光头项目投资申请报告
- 广东开放大学2024年秋《国家安全概论(S)(本专)》形成性考核作业参考答案
- 党员使命意识提升培训协议2024
- 2024新建设工程成本咨询协议范本
- 2024水电开发建设协议范本
- 2024年政府专项资金支持计划协议
- 厂房2024年租赁化协议模板
- 保安公司客户满意度调查表
- 课间安全教育主题班会课件
- 民法典 婚姻家庭编课件
- 电气工程及其自动化专业人才需求调研报告(新)5100字
- 公务员考试行测答题卡
- 消失模工序工艺作业指导书
- 广西壮族自治区北海市各县区乡镇行政村村庄村名明细居民村民委员会
- 老年人能力评定总表(含老年人日常生活活动能力、精神状态与社会参与能力、感知觉与沟通能力、老年综合征罹患情况)
- 小学英语期中试卷分析(三篇)
- 系动词公开课 完整版PPT
- 土工击实仪不确定度评定
评论
0/150
提交评论