概要:在JDeveloper 11gR1中,使用EJB, JPA and JavaServer Faces技术开发一个Web应用程序。Data Model,使用EJB diagrammer, EJB 3.0 and Java Persistence API (JPA)创建。View Controller,一个JSF Page会被创建用来浏览编辑HR信息。实例中,还创建了一个task flow用来查询查询员工,该task flow会做为ADF region添加到JSF Page上。
1. Part1:使用EJB3.0创建数据模型
可以使用EJB/JPA组件创建Web Application的Data Model。JDeveloper提供了wizards来创建EJB projects,实体,持久化单元,会话beans,消息驱动beans. Java Persistence API(JPA)提供了POJO持久化模型用来做面向对象的数据映射。
(1)创建一个新的Application和Projects
(2)创建持久化模型
使用EJB3.0实体beans创建Departments和Employees的持久化模型,该步完成后就会生成JPA实体。
(3)创建EJB Diagram
EJB Diagram可以可视化各种beans及其之间的关联关系。
(4)创建客户端应用程序使用的会话Bean
Session Bean是一些具体的业务逻辑,例如查找employees和departments的记录,就可以做成会话beans。Client端通过Session Bean层与EJB通讯。好处是:(1)减少了用户直接访问EJB3.0实体时的network traffic引起的性能问题;(2)是Client与EJB的business objects解耦合,代码容易维护。
有两种类型的session bean:Stateless session bean和 stateful session bean。stateful session bean使用场合:用户登录权限切片控制,购物车等。
A stateful session bean maintains conversational state on behalf of the client. A conversational state is defined as the session bean field values plus all objects reachable from the session bean fields. Stateful session beans do not directly represent data
in a persistent data store, but they access and update data on behalf of the client. The lifetime of a stateful session bean is typically that of its client.
Stateless session beans are designed strictly to provide server-side behavior. They are anonymous because they contain no user-specific data. The EJB architecture provides ways for a single stateless session bean to serve the needs of many clients.
All stateless session bean instances are equivalent when they are not involved in serving a client-invoked method. The term stateless means that it does not have any state information for a specific client. However, stateless session beans can have non-client
specific state, for example, an open database connection.
Use Container for a transaction being handled by the session facade and bean for managing user transaction explicitly through a programmatic process.
(5)使用EJB会话beans创建ADF Data Controls.
2. Part2:创建View Project
Part1在EJB/JPA组件的基础上创建了Data Controls,下面创建JSF页面。
(1)为JavaServer Faces Page创建Global Layout
(2)将JSF Page绑定到Data Control
(3)运行测试页面
(4)增加新建/删除功能
3. Part3添加新的方法供UI使用
使用EJB3.0注解技术为实体Beans添加新的Data Control方法,然后将该方法暴漏给task flow中的Web Page。
(1)修为Employees实体Bean的@NamedQuery,为其添加通过工资查询员工的getEmployeesFindBySal()方法
(2)创建有两个JSF页面的Bounded Task Flow
【注意】有两种类型的task flow.
Unbounded task flow: A set of activities, control flow rules, and managed beans that interact to allow a user to complete a task. The unbounded task flow consists of all activities and control flows in an application, that are not included within
a bounded task flow.
Bounded task flow: A specialized form of task flow that, in contrast to the unbounded task flow, has a single entry point (an entry point is a view activity that can be directly requested by a browser) and zero or more exit points. It contains its
own set of private control flow rules, activities, and managed beans. A bounded task flow allows reuse, parameters, transaction management, reentry, and can render within an ADF region in a JSF page.
(3)将Task flow region添加到mainHR page
You can extract, configure, and package application functionality within a bounded task flow so that it can be added to other pages using an ADF region. ADF regions can be reused wherever needed, which means they are not dependent on a parent page.
(4)运行mainHr Page
4. Part4:Testing the Facade Inside and Outside the Java EE Container
Step 1: Add a New Method to the Entity and Expose it
Step 2: Run the Java Service outside the Java EE container
效果如下图所示:
参考
【1】http://docs.oracle.com/cd/E18941_01/tutorials/toc.htm
【2】http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/ejb/ejb.html
【3】http://blog.csdn.net/luyushuang/article/details/5885447
【4】http://hi.baidu.com/smilease/blog/item/798e42cbbfe7e4017f3e6fdb.html
【5】使用 EJB、JPA 和 JavaServer Faces 通过 JDeveloper 11g构建 Web 应用程序
http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/229517_zhs.html
分享到:
相关推荐
5使用 JDeveloper 的 JavaServer Faces 简介
Introduction to JavaServer Faces using JDeveloper.
使用oracle的jdeveloper开发的一个EJB应用程序的截图和简述的完整全过程
ADF EJB 官网例子demo 指导文档 Build a Web Application with JDeveloper 11g Using EJB, JPA, and JavaServer Faces.pdf
JDeveloper的环境下,制作的关于利用oc4j发布web服务的一个例子,描述非常详细.
Oracle 9i JDeveloper开发手册 构建J2EE应用程序
WebCenter Framework• 使用 JDeveloper 构建上下文丰富的、可自定义的应用程序、将 JSF 应用程序公开为 portlet• 使任何 faces 应用程序可用于远程 WebCenter 应用程序• 使用声明式工具保护您的应用程序 ...
05 Creating the Web Tier Using JavaServer Faces 06 Controlling Navigation and Data Flow with JSF 07 Creating the Business Tier: Enterprise JavaBeans 08 Creating the Persistence Layer with TopLink ...
利用 JDeveloper 和 Oracle 应用服务器开发配置和管理Web服务-14
Oracel Jdeveloper 开发手册
NULL 博文链接:https://duqiangcise.iteye.com/blog/749438
JDeveloper是一种用于Java编程的集成开发环境(IDE)。它为设计、开发、调试和部署所有类型的3GL Java及组成J2EE(Java 2 Platform,Enterprise Edition)战略的其他相关文件提供了相当丰富的特性。JDeveloper包括很多...
NULL 博文链接:https://wyx810316.iteye.com/blog/363579
Oracle 公司的JSF文档,涉及JDeveloper的使用
JDeveloper 使用小技巧,对新人有用的
oracle jdeveloper3使用手册.
oracle adf JDeveloper 教程 java j2ee oracle adf JDeveloper 教程 java j2ee oracle adf JDeveloper 教程 java j2ee oracle adf JDeveloper 教程 java j2ee oracle adf JDeveloper 教程 java j2ee
jdeveloper11g 开发的 一个简单demo 但对于新手很实在
本系统是基于J2EE的Web模式,应用了JDeveloper作为开发工具,搭建了JDeveloper+SQL Server2000的运行平台,JDeveloper是J2EE的一个集成开发工具,它可以加快程序的开发,大大提高程序员的开发效率和软件产品质量。...
JDeveloper VCS插件安装及使用