继往开来 吐故纳新
日历
网志分类
· 所有网志 (990)
· 个人作品 (62)
· 软件设计 (33)
· 面向对象编程 (22)
· JavaAPI (39)
· Java开源工具 (31)
· Swing (34)
· Java语法细节 (39)
· 样式表CSS (12)
· XML (10)
· J2EE(JavaEE) (23)
· 算法数据结构 (64)
· 正则表达式 (4)
· 软件知识 (6)
· Java线程 (9)
· Web开发.Jsp/Servlet/Struts (20)
· 程序随想录 (7)
· Spring (5)
· Hibernate (7)
· J2SE 高级 (2)
· J2SE 高级 (0)
· Web开发.Ajax (16)
· Web开发.JavaScript (43)
· DB4O (2)
· Web开发.CSS/Html (22)
· C# (20)
· ERP (4)
· JDBC (1)
· 编程资源 (16)
· 编程感悟 (29)
· DB/Sql (13)
· VB (29)
· VC (2)
· 桌面脚本 (3)
· 新兴软件 (3)
· 英语学习 (21)
· 网文转载 (159)
· 职场风云 (39)
· 诗词歌赋 (32)
· 生活感言 (77)
· 奇文共赏 (13)
· 财经纵横 (6)
· 未分类 (11)
站内搜索
友情链接
· 歪酷博客
· 我的歪酷 非非共享界
· 偶要雷锋
· 豆瓣
· nczonline
· 当当网
· easyjf中文站
· Donews
· 天极Java文章列表
· W3CSchool
· taiten的BLOG
· Dojo中国
· Dojo
· Extjs.com
· Lifehack中文网志
· JaveEye的一个AS专题
· Banq's JDon
· Java 中文网址大全
· 梦想Java
· 360Doc个人图书馆
· java开源大全
· 我在硅谷动力的软件下载站
· 站长中国
· 随意贴
· CSS教学素材站
· java 参考中文站
· 面向构件与SOA社区
· 彩字生成
· 派派小说论坛
· 如坐春风
· 英语学习网
· BBC CHina
· www.dlbang.com
· 古文竖排格式在线转化工具
· 免费家谱
· 图片上传基地
· 风景壁纸
· 和风细雨
· MyC#BlogInCsdn

订阅 RSS

0207392

歪酷博客

开此博一为经验积累,二为资料收集,三为同道交流,四为资源共享.
« 上一篇: 【整理】Java中实现回调函数 下一篇: 【整理】在Web程序中使用文件绝对地址 »
Junglesong @ 2007-03-19 19:10

Achieve implementation transparency for your business objects with the Business Object Factory framework
By James Carman, JavaWorld.com, 07/18/03

down to business
Achieve implementation transparency for your business objects with the Business Object Factory framework
By James Carman, JavaWorld.com, 07/18/03

Many architects strive to reduce coupling between the presentation tier and the business logic tier in multitier applications. The Business Delegate design pattern (in Sun Microsystems' Core Java 2 Platform, Enterprise Edition (J2EE) Patterns Catalog) was created to solve this problem. But, many critics claim it is an unnecessary added layer of abstraction for achieving this simple goal. Most argue that the business delegate's interface mimics the business logic interface so closely that any change to the business logic interface also mandates a change to the business delegate's interface. In most cases, this is true. However, the Business Delegate pattern has other benefits such as remoteness hiding, failure recovery, thread synchronization, and caching. But many applications that use the Business Delegate pattern do not take advantage of these additional benefits. Thus, the pattern's overhead seems to outweigh its merits. For these applications, all that is desired is an abstraction layer that hides the underlying implementation details, such as the familiar lookup and narrow operations required for Enterprise JavaBeans (EJB) implementations. This article takes you through the API, configuration, and implementation of one such framework, the Business Object Factory framework.
许多架构师致力于在多层程序中减少表现层和业务层的耦合.因此业务代理设计模式被创建出来用以解决这个问题.但许多批评意见认为这是一种为达成简单目的而不必要添加的层.

Note: You can download this article's source code from Resources.

The API
The Business Object Factory framework's simplest part is the API itself. There is only one major class, but a few other "behind-the-scenes" classes can extend and customize the framework.

The BusinessObjectFactory class
Apart from the business interfaces used in their applications, consumers of business objects' services need only concern themselves with one primary class, BusinessObjectFactory. Let's look at its public interface:


                        public final class BusinessObjectFactory
{
  public BusinessObjectFactory getInstace();
  public Remote create( Class businessInterface );
}

                    


As you can see, the BusinessObjectFactory class implements the Singleton design pattern (a Gang of Four design pattern). The BusinessObjectFactory's constructor is declared as private, and the class only maintains one static instance. This provides one global point of access to the functionality BusinessObjectFactory provides. We could just as easily make all of the methods static, but that approach is more object-oriented.

The create() method tends to raise a few eyebrows. First, it returns an instance of java.rmi.Remote. Most business object implementation choices, namely Remote Method Invocation (RMI), EJB, and the Java API for XML-based Remote Procedure Calls (JAX-RPC), require a remote interface. For simple JavaBean-based business object implementations, this adds the inconvenience of requiring the client code to catch java.rmi.RemoteException when it will never be thrown. However, this inconvenience helps provide the implementation transparency, as the business objects can be migrated to a different implementation type without altering the client code. The only stipulation is that the remote interface does not change. Another create() method peculiarity is its parameter type, java.lang.Class, which corresponds to the remote interface type requested. This allows the BusinessObjectFactory class to be loosely coupled with the application using it. This does not prevent company XYZ from creating an adapter class to simplify client programming:   Continued


--------------------------------------------------------------------------------
Related Article1 | 2 | 3 | 4 | 5 |  Next >


Discuss
Start a new discussion or jump into one of the threads below:

Subject  Replies  Last post  
 Configuration file Schema
By Katari  0  02/20/07 03:14 PM
by Katari 
 Singleton
By Juan Casares  2  03/02/06 09:33 AM
by Anonymous 
 Interesting, but very tilted towards EJB usage
By Eric Pugh  4  03/01/06 07:04 PM
by Anonymous 
 Oops...
By James Carman  0  08/05/03 09:17 PM
by Anonymous 


    Print E-Mail article Feedback Add to del.icio.us Related Article Resources

Download the source code that accompanies this article
http://www.javaworld.com/javaworld/jw-07-2003/factory/jw-0718-factory.zip
Business Delegate pattern in Sun's Core J2EE Patterns Catalog
http://java.sun.com/blueprints/corej2eepatterns/Patterns/BusinessDelegate.html
Browse more of Sun's Core J2EE Patterns Catalog
http://java.sun.com/blueprints/corej2eepatterns/Patterns/
The famous Gang of Four bookDesign Patterns, Eric Gamma, Richard Helm, Ralph Johnson, John Vlissides (Addison-Wesley Publishing Co., 1995; ISBN0201633612)
http://www.amazon.com/exec/obidos/ASIN/0201633612/javaworld
The Apache Software Foundation's Commons Digester homepage
http://jakarta.apache.org/commons/digester
"Simplify XML File Processing with the Jakarta Commons Digester," Erik Swenson (JavaWorld, October 2002)
http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-opensourceprofile.html
The Apache Software Foundation's Commons Logging homepage
http://jakarta.apache.org/commons/logging.html
The Apache Software Foundation's Commons BeanUtils homepage
http://jakarta.apache.org/commons/beanutils.html
The AspectJ homepage
http://www.aspectj.org
AOP- and AspectJ-related articles in JavaWorld:

"I Want My AOP," Ramnivas Laddad:


Part 1Separate software concerns with aspect-oriented programming (January 2002)
Part 2Learn AspectJ to better understand aspect-oriented programming (March 2002)
Part 3Use AspectJ to modularize crosscutting concerns in real-world problems (April 2002)
"Add a JAC to Your Toolshed," Renaud Pawlak (March 2003):
http://www.javaworld.com/javaworld/jw-03-2003/jw-0307-jac.html
Sun's Java Servlet Technology homepage
http://java.sun.com/products/servlet/
Jason Hunter's JavaWorld articles about Servlet 2.3 discuss the servlet filter model:

"Servlet 2.3New Features Exposed" (January 2001):
http://www.javaworld.com/javaworld/jw-01-2001/jw-0126-servletapi.html
"Filter Code with Servlet 2.3 Model" (June 2001):
http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html
Also read about the latest Servlet 2.4 specification in Jason Hunter's "Servlet 2.4What's in Store" (JavaWorld, March 2003)
http://www.javaworld.com/javaworld/jw-03-2003/jw-0328-servlet.html
For more servlet-related articles, see the Servlets section of JavaWorld's Topical Index
http://www.javaworld.com/channel_content/jw-servlets-index.shtml
Read David Geary's Java Design Patterns columns
http://www.javaworld.com/columns/jw-java-design-patterns-index.shtml
For more design pattern articles, visit the Design Patterns section of JavaWorld's Topical Index
http://www.javaworld.com/channel_content/jw-patterns-index.shtml
Browse the Enterprise JavaBeans (EJB) section of JavaWorld's Topical Index
http://www.javaworld.com/channel_content/jw-ejbs-index.shtml
Browse the Java 2 Platform, Enterprise Edition (J2EE) section of JavaWorld's Topical Index
http://www.javaworld.com/channel_content/jw-j2ee-index.shtml
Browse the Java and XML section of JavaWorld's Topical Index
http://www.javaworld.com/channel_content/jw-xml-index.shtml
Speak out in the JavaWorld Forum
http://www.javaworld.com/javaforums/ubbthreads.php?Cat=&C=2
Sign up for JavaWorld's free weekly email newsletters
http://www.javaworld.com/subscribe

Partner Content

Open Source Software Solutions
Explore a universal platform of frameworks for open source on eclipse solutions coming on April 5, 2007.

Continuum of open source
 
Build Secure Web Services
Discover how to authenticate using a user ID and password, ensure integrity using digital signatures, and ensure confidentiality using encryption.

Build your services now
 
Rational V7 Downloads
Test-drive the IBM Rational V7 desktop products offering new capabilities for empowering global teams to speed SOA results.

Free Rational trials
 
New! Rational SOA Testing Open Beta
IBM Rational invites you to participate in our open beta program for testing SOA applications.

Sign up today!
 

 
Sponsored links
JUnit Test Generation
Submit Java. Get back FREE JUnit. Try it! - www.junitfactory.com

Java Installer Builder
install4j is easy to use, amazingly powerful and creates beautiful installers for all platforms. Try out the free trial version. - ej-technologies GmbH


Buy a link now.Cost Effective SOA Management & Runtime Governance
JaxView SOA Management for small to medium enterprise Management and Policy enforcement. Try it Now!
Free Webinar: The IT infrastructure of the future
Learn about how the HP BladeSystem is revolutionizing the datacenter. Attend the free webinar here.
The comprehensive, yet seamless help desk solution
Apply ITIL best practices at your service desk while eliminating integration cost. Learn more here.


RESEARCH CENTERS: Java Standard Edition | Java Enterprise Edition | Java Micro Edition | Development Tools
About Us | Advertise | Contact Us | Terms of Service/Privacy
Copyright, 2006-2007 Network World, Inc. All rights reserved.
IDG Network: CIO Computerworld CSO Demo Games.net IDGconnect.com Infoworld IT World Canada Linuxworld.com Macworld NetworkWorld.com Outsourcing World PC World Playlistmag.com



评论 / 个人网页 / 扔小纸条
* 昵称

已经注册过? 请登录

新用户请先注册 以便能显示头像及追踪评论回复

Email
网址
* 评论
表情
 


 

分类小组论坛
杂谈 , 娱乐、八卦 , 文学、艺术 , 体育 , 旅游、同城 , 象牙塔 , 情感 , 时尚、生活 , 星座 , 科技

请注意遵守中华人民共和国法律法规, 如威胁到本站生存, 将依法向有关部门报告, 同时本站的相关记录可能成为对您不利的证据.

相关法律法规
全国人大常委会关于维护互联网安全的决定
中华人民共和国计算机信息系统安全保护条例
中华人民共和国计算机信息网络国际联网管理暂行规定
计算机信息网络国际联网安全保护管理办法
计算机信息系统国际联网保密管理规定