floater
Java Jedi
总版主
发贴: 3233
积分: 421
|
于 2003-06-18 22:22
For #1, this is the general rule. However for entity beans, this is exceptional(that's why I say that if no entity bean). The reason behind it is the cost of network traffic. You have to reduce the network overhead for entity beans by using local interfaces of entity beans.
For other options, jdbc, hibernate, etc. It's pretty straight forward
public interface User { public long getID(); }
public class JDBCUser implements User { public long getID() { //get DataSource, get connection, get user } }
public class JDOUser() implements User { public long getID() { //do it in JDO way } }
....
Then in your client code using User would like this: User user = (User) DB.createUser(); long i = user.getID();
In your DB class: public User createUser() { //get class name from configure file and initiate the class, it must be one of JDBCUser, JDOUser, etc. //return the object. }
You may need to pass in some parameters to create the user object.
For #3, there are many options with certain restrains on the network side. I don't know the way that your GUI connects to the server, it could be http, rmi, or sockets, etc. So my point is whenever possible, don't use session bean for business logic(out of the picture=get it out of my way, ). Otherwise you would have a dependency from business logic to ejb container, this doesn't make sense in general.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler, Refactoring - Improving the Design of Existing Code
|