楼主: Sky-Tiger

CRUD Operation using JSF,Web Services and OJB

[复制链接]
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
11#
 楼主| 发表于 2009-11-28 23:06 | 只看该作者
Right click on WSDL > Select Web Services > Generate Java bean skeleton

Figure 12. Specify Service Project Settings
Specify Service Project Settings

Specify the Service Project Name with its project type and EAR name.

1英语.jpg (44.88 KB, 下载次数: 5)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
12#
 楼主| 发表于 2009-11-28 23:06 | 只看该作者
Generating client

To check the implemented classes functionality we generate client that actually make a call to the web service and confirm us that everything is fine. In real time we actually give the wsdl to the user from which they generate the client and invoke for the required functionality. Figure 13 shows how to create the client.

Figure 13. Generating the Client
Generating the Client

1英语.jpg (33.41 KB, 下载次数: 6)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
13#
 楼主| 发表于 2009-11-28 23:06 | 只看该作者
Right click on WSDL > Select Web services > Generate Client

Figure 14. Specify Client Project Settings
Specify Client Project Settings

Click on Client Project > Specify the Client Project Name

1英语.jpg (44.95 KB, 下载次数: 7)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
14#
 楼主| 发表于 2009-11-28 23:07 | 只看该作者
ObJectRelationalBridge (OJB)

Data being the major component in any project should be manipulated and stored in a right way at right time. Delay in response time or dirty read/write will degrade the performance of the system and keeping the system in an inconsistent state as a whole. In the current tutorial the DB layer sits at the end storing the data that is passed through UI layer and service layer.

With the introduction of ORM tools the data manipulation and maintenance became easy that can be directly mapped with the java, OJB is one among them that is designed developed by Apache. It allows persistence for java objects against relational databases.

The following are some key features of OJB:

    * Provides flexibility through support to multiple persistence APIs
    * The applications that are designed and developed using OJB are scalable for future enhancements.
    * It support JNDI lookups and Bean Managed Persistence
    * The XML based ORM helps to manipulate during run-time
    * It provides a flexible configuration and plug-in mechanism that allows to select from set of predefined components.
    * The open source feature with 100% pure Java orientation facilitates rapid development.

With the completion of the user inteface layer and services layer we move into the database layer which actually saves the data into the database. The annotations and xml configuration features provided by OJB enables us to map the table columns with the bean properties directly thus making the data manipulations easy. The built-in methods in OJB help us to store ,update and delete the data in a object model.

Figure 15. Creating New Java Project
Creating New Java Project

1英语.jpg (28.93 KB, 下载次数: 6)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
15#
 楼主| 发表于 2009-11-28 23:07 | 只看该作者
To achieve this we create a Java Project with two main packages that store DAO’s and Domain classes. Following the java naming conventions create the packages with appropriate names. The Domain package stores the classes that contain doclets mapping the properties to that of columns in the specific table, while the DAO package contains the real operational methods that stores the domain object. Import the required Jars into the lib folder. This include the necessary jars for the database support, in this article we use DB2 as database and import them accordingly.

Figure 16. Configuring the repository_database.xml
Configuring the repository_database.xml

1英语.jpg (73.93 KB, 下载次数: 8)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
16#
 楼主| 发表于 2009-11-28 23:07 | 只看该作者
Once we are done with the basic packaging structure and importing of dependent jar files we moved ahead with configuring the XML files. The files are stored in the config folder, the main config file include repository_database.xml  that is used to configure the database name and other credentials. The next file we deal is the build.xml that actually map the location of domain objects and classpath from where required jars are loaded. It also specifies the target location for files project-schema.xml and repository_user.xml. These two files will be generated and placed in config folder once we run the build.xml file. Figure 17 shows the typical build.xml file.

Figure 17. Configuring the build.xml
Configuring the build.xml

1英语.jpg (67.52 KB, 下载次数: 6)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
17#
 楼主| 发表于 2009-11-28 23:08 | 只看该作者
Integrating the user interface with services

Now we are ready with three individual layers and need to integrate them to make an end-to-end flow. Firstly we integrate the user interface with Web services. Since the user interface is a dynamic Web project, adding the service client jar makes the operations defined in Web service to be available to the user interface layer. This can be achieved in the following way, described below.

Figure 18. Adding web service client to UI
Adding web service client to UI

Right Click on UI Project > Properties > J2EE Module Dependencies > Check the Client JAR

1英语.jpg (61.52 KB, 下载次数: 7)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
18#
 楼主| 发表于 2009-11-28 23:09 | 只看该作者
Invoke the service using service locator and locate the endpoint with appropriate port type. If the server is listening in another port, we need to change accordingly. Depending on the object type at user interface layer we map them to objects that are defined at service layer. Figure 19 shows the sample code for invoking web service from a managed bean in user interface layer.

Figure 19. Service Invocation from Managed Bean
Service Invocation from Managed Bean

1英语.jpg (79.02 KB, 下载次数: 6)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
19#
 楼主| 发表于 2009-11-28 23:09 | 只看该作者
Integrating the services with the database layer

The integration of services with database layer includes adding the database java project as dependency jar in Web service project J2EE Module dependencies. Make certain that the required jars for the database project are already added in EAR that is generated for the Web service project. Figure 20 shows adding the data project as dependency jar to the Web service project.

Figure 21. Adding DB jar dependency
Adding DB jar dependency

1英语.jpg (73.94 KB, 下载次数: 5)

1英语.jpg

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
20#
 楼主| 发表于 2009-11-28 23:09 | 只看该作者
Right Click on Web Service Project > Properties > J2EE Module Dependencies > DB JAR

Figure 21. Creating Domain and DAO objects
Creating Domain and DAO objects

    * Create the Domain and DAO Objects
    * Set the domain object using appropriate DAO

1英语.jpg (88.22 KB, 下载次数: 7)

1英语.jpg

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表