12
返回列表 发新帖
楼主: Sky-Tiger

Integrating Macromedia Flex with Java

[复制链接]
论坛徽章:
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-2-13 22:29 | 只看该作者
Integrating Flex with the Persistence Layer

In applications that use a well defined decoupled architecture over the Web you do not communicate with your persistence layer directly. Using Flex should not change this architecture. The integration layer typically will communicate to your persistence layer in most cases. This is usually done using a Data Access Object (DAO) that is responsible for accessing data in a persistent store such as a database. The Flex client should not communicate directly to the persistence layer or even know about this layer because it forms a tight coupling. Let's use Hibernate as an example of our persistence layer.

There are a couple of pitfalls when using Hibernate and remote objects with Macromedia's AMF gateway. Hibernate users know you cannot access a lazy loaded collection that has not been initialized with a Hibernate Session object. Accessing a collection of dynamic proxy objects that has not been initialized will result in a runtime exception. The AMF gateway does not know how to specifically look for Hibernate dynamic proxy objects. A potential solution is an aspect-oriented programming (AOP) interceptor that can take the object that is about to be sent over the AMF gateway in the delegate object and remove the dynamic proxies. This process involves sending the resultant object through the interceptor class, which recursively looks for proxy objects that use reflection and that are not initialized. If any lazy proxy objects or collections are found then they are set to null. This is a cross-cutting concern that can be applied as an aspect using an AOP language such as JBoss AOP, AspectJ, Spring AOP, and so on. The AOP interceptor should be applied to objects in the business delegate layer. Figure 4 shows what this looks like in the application architecture:

Introducing AOP interceptors/advice to delegate objects before they pass through the AMF gateway
Figure 4. Introducing AOP interceptors/advice to delegate objects before they pass through the AMF gateway. This further reduces coupling from components in higher layers such as the integration layer, persistence layer, and so on.

The good news is the AMF gateway does know how to cache bidirectional objects so infinite recursion does not occur when transforming the objects. Therefore, you can keep these relationships intact when transmitting them back and forth over the AMF gateway. Also, because the objects are disconnected and made into copies, you will need to use the Session.saveOrUpdateCopy(Object object) method to persist results into the database. This method has to be used because the object that will be sent back through the AMF gateway will not have any enhanced bytecode information that Hibernate can take advantage of.

FlexIntegrationAOP.gif (14.92 KB, 下载次数: 13)

FlexIntegrationAOP.gif

使用道具 举报

回复
论坛徽章:
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-2-13 22:30 | 只看该作者
Authentication

Typical J2EE web applications have some kind of authentication scheme. This might be a container-based authentication scheme or it might be some custom code that authenticates the user. RIA servers such as Flex allow you to use custom authentication forms on the Flash client and container-based authentication in most application servers. Furthermore, if you look at the business delegate configuration in the example above you will notice that you can assign roles to these objects for security. There are even hooks in the AMF gateway that allow developers to grab the HttpRequest, HttpResponse, and ServletConfig objects to refine the security you want to use within a method of a delegate object.
Summary

This article introduced a number of concepts with the intention of exposing you to some of the tradeoffs and potential pitfalls when using a RIA such as Flex. Whether you use Flex or another RIA implementation, there are major considerations to take into account when architecting an application with this technology. When evaluating an RIA framework make sure it is extensible enough to meet the demands of the application. Furthermore, carefully evaluate integration issues that might need attention when transmitting objects between and RIA and a Java backend.

使用道具 举报

回复
论坛徽章:
131
乌索普
日期:2017-09-26 13:06:30马上加薪
日期:2014-11-22 01:34:242014年世界杯参赛球队: 尼日利亚
日期:2014-06-17 15:23:23马上有对象
日期:2014-05-11 19:35:172014年新春福章
日期:2014-04-04 16:16:58马上有对象
日期:2014-03-08 16:50:54马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
13#
发表于 2009-2-15 23:59 | 只看该作者
学习了

使用道具 举报

回复

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

本版积分规则 发表回复

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