1 Reply Latest reply on Sep 23, 2002 11:08 PM by Donald

    Setting up an object model or two

    Scott Newbie

      Hi. We are setting up a j2ee application that will mostly be accessed via web-pages, but we may expose it as a web service or via a client application at a later date, so we want to build a solid object model from the get go. It's a virtual-classroom type of thing, and the objects are heavily nested/linked (a course has sections, a section has discussion boards, a discussion board has posts, a post has replies and so on). This heavy-nesting approach would be quite luxurious for the developers and we'd like to stick with it if possible. The database is already built and there's a layer of entity beans on top of it, which heavily utilizes CMR fields. This seems like a great way to implement the web of relationships between the objects because of the lazy loading feature of CMR entity beans. Objects can be accessed and the whole graph of links doesn't have to be traversed to load them (If I'm mistaken and this is not how lazy loading works, somebody please let me know).

      Here's the problem.

      We want to have a sessionbean facade over the whole thing, and implement an object model that is independent of the entity bean layer, but is still heavily nested/linked. Transactions happen at the session beans, using these independent objects. When a transaction is run, the entity bean layer is accessed and contents of an entity bean are translated into/from a corresponding, high-level bean (Data Transfer Object, maybe?) The crux of the issue lies with trying to translate the web of relationships. Translating the entity beans into DTOs defeats the lazy loading becuase the whole graph has to be travsered to create the DTOs and link them together.

      I'm not too familiar with all this and I don't know if this is going to a big problem, or if its going to be possible. Maintaining the relationships only really has to happen when extracting data from the persistence layer. We can store information using separate methods, but we'd like to be able to extract information from the persistence layer simply by traversing the graph of DTO objects, instead of having separate lookup methods. Is this unrealistic given the separation between the entity bean layer and the DTO layer?

      Another possibility I've given some thought to is integrating the entity layer into the object model somehow. So the object model would double as the session bean facade, and objects would perform their own book keeping by directly calling their counter parts in the entity bean layer. Is this realistic? It seems like this approach would facilitate lazy loading, but would be very taxing on the system, with lots and lots of jndi lookups. Are jndi lookups that expensive? Also, these objects would be accessed (quite heavily) from the web container. It's my understanding that jsp's can only access remote interfaces and not local. Is this true? Would remote vs. local be an issue in this case?

      Or should I just scrap the whole idea of a heavily linked object model and just have independant objects and use separate lookup and store methods?

      If it seems like I have no idea what I'm talking about, somebody please let me know. If all of this sounds like chapter one of some book, somebody please let me know which book. Thanks for putting up with my long post.

      Scott



        • 1. Re: Setting up an object model or two
          Donald Newbie

          I would look at the Sun petstore application. I have worked on a a couple modified versions. That setup has a facade that wraps the whole backend. Well, they have seperate facades for application areas but is best served through one facade that is called from the front end proxy.

          That way, all requeste go to the backend through one facade and you send that backend a neutral business event that holds it purpose and any data the back end needs. At that point, who cares what and who and where the request is comming from. Webservice, pc client, RMI, webserver.

          Now, The modification that I am using is from a past release improved for areas that were lacking but I know that they have come along on it. Rip up their framework and build from there. Why re envent the wheel if it rolls and rolls nicely and I can tell you that I know many of these modified version that rip thousands of txns through them and they perform nicely.