急问题about EJB

04-05-07 yuancongjia
我需要做一个仓库管理系统(inventory manager)

客户端是GUI application

请问我该采取如何的架构叫好

(1)GUI----->EJB------>DATABASE

(2)GUI----->EJB(business logic layer) JDO(persistence layer)---->DATABASE

jdbc

(3)GUI(construct a persistence layer myself in GUI layer, and how)------->DATABASE

(4) other suggestion?

if(1)

(a) if采用entity bean 方式, 当我update gui table 中一个row的时候,

how to map this update in the gui table to the corresponding entity bean

eg

table in GUI(editable table) entity bean

customer_id,customer_name Customer (ejbobject)

then i change the customer_name in the left table in GUI, i want this change to be reflected and executed on the corresponding

ejb, how can i locate the ejb that corresponds to this particular table row in GUI, What's the best way to establish this mapping.

in ADO.net, Microsoft has databinding mechnasim, is there any conterpart in J2EE.

if (3)

how to establish a persistent layer myself (ie not using any ejb and communicate directly with batabase)

Another question:

If i want to update lots of table rows in a time, and i don't want this update to be excuted immediately, ie cache the change

in the persistent layer.And then after i press a button, say "UPDATE", all the updates will be done to the database. How to

implement such a CACHE mechanism?

wwlhp@jdon.com
2004-05-08 09:23
Like windows application, Swing application is also event driven.You can register a few event listeners with a Swing component, such as JButton and JTable. Any changes to this component will cause it send some event to its registered listeners. So, it is in the listener's method that you can call ejb and synchronize JTable and entity bean. There is no available databinding mechanism in J2EE, so you have to think over and build this mechanism yourself.

banq
2004-05-08 20:44
to yuancongjia

首先,我不赞成第3个方案,GUI不能直接操作数据库,这已经违背多层结构宗旨。

在GUI和EJB之间做Mapping的工作,其实就是你的仓库管理系统主要工作,目前没有很好很灵活的通用框架支持。

至于如何做Mapping,有多种途径,一般是如下:

GUI ---> Http ---> EJB

Http协议穿透防火墙好,基于Http也有多种方案,例如Web Services或EJB Services。

后者可参见我的书籍《Java实用系统开发指南》中"EJB方法调用框架",该框架就是专门基于Http,针对远程GUI调用EJB设计的通用框架。

在这两者之上你完成具体的Mapping工作就可以,当然我也曾经看到,使用数据库的MetaData属性实现通用的Mapping,需要更高和复杂的技术了。

猜你喜欢