I'm struggling with a system design with regards to Session and EJB's. >From what I've read, you never want a client talking to an EJB directly, but rather a Session bean. This means that you cannot let out ANY references to EJB's. I can understand this logic as I think of the EJB 'layer' as the persistence of the business, and the Session bean layer as the 'logic' of the business. The 'logic' will change/evolve (in general) much faster than the persistence - so you don't want to constantly be changing your EJB's (and hence your schema), but instead change your Sessions. Also you want the business logic contained in one location (not spread about some client code (JSP?)) So my problems are: i) Session beans need to completely wrap EJB's. In doing so this seems horribly inefficient. For example an EJB home interface has a findAll which returns a Collection of the remote interfaces. So in the Session bean I have to get that Collection of remote EJB's and 'convert' them to a Session remote and return that Collection to a client (proxy the EJB - take one Collection and 'copy' it into a new different Collection) - yuk. ii) There are no constructors in Session (or EJB's) so I have to play with this mess of flags ( if(isDirty) init(); etc...) on every method call. I can't initialize the object in the ejbCreate, because in doing the lookup(s) exceptions are thrown that ejbCreate doesn't like (RemoteException, NamingException, FinderException) etc.. This doesn't seem right. iii) In general the complexity of wrapping EJB's with Session beans has skyrocketed. I had a somewhat clean, simple (very easy to read/understand) API (and implementation) that JSP's/Applications could talk to (given the API was talking directly with the EJB's), and now the internal implementation is getting very messy. For example I have a UserEJB that has a Collection of AddressEJB's. Now I need a UserSession that hasa Collection of AddressSession's to 'wrap' this UserEJB/AddressEJB relationship. The code has quite a bit of messy bookkeeping (and I still have quite a few bugs that I'm having trouble tracking down) to keep track of what once was a simple association. My question: Am I totally spacing out? Is there a better way to do this (outside remote proxies)? Is there a way to just have a reference to an EJB from a Session without performing the lookup (like in EJB's - just have a reference to another EJB and the container deals with the persistence and linking)? Thanks. Jason Amy [EMAIL PROTECTED]
