J. Matthew Pryor wrote: > Care to share any further insights about your approach?
First off, eventually I'll write articles on TSS that describe the cool new features that I'll be implementing, including the porting to XDoclet. > Are you using xdoclet for the DAOs as well ? What about the factory > mechanism ? Hand coded ? Any other patterns in use there I'm not using XDoclet for DAO's right now, but I see that as the logical next step. For the first round I want to handcode everything and do it "the hard way". The next round, when things have stabilized, will be to identify common patterns and automate those with XDoclet. One of the coolest pattern I'm using right now, and which I haven't seen anywhere else, is the use of the command pattern and the visitor pattern in order to do entity creation. Example: Usually you use Data Transfer Objects (DTOs) to initialize entity beans, i.e. your create's look like this: public Object ejbCreate(MyEntityDTO data) { this.name = data.getName(); ... } If you want several ways to create an entity, then simply add more create's for those cases, and possibly more DTO's with different subsets of data. Also, if there are any side-effects that should happen (such as an entity instance count increment, or creation of helper entity) then this will be coded directly into the entity's create method. This makes the entity much less reusable, and it will have to change often as client needs evolve and it is being used in different ways in conjunction with other EJB's. The way to solve this is to use the command pattern and the visitor pattern. Create an entity creation command base class that has setters for the parameters you need for creation. Then add a callback method "setEntity(MyEntityBean entity)" to this command. In the entity you now only need *one* create method regardless of how you want to use the entity: public void ejbCreate(CreateMyEntity command) { command.setEntity(this); command.execute(); } -- The command can then copy as much data as is relevant from itself to the entity, and initialize relationships with other beans. If anything fails, then an exception is thrown and the transactions rolls back. This is so incredibly powerful I'm a bit surprised noone has thought of it before :-) Anyway, the next step is to couple it to a web framework that is command oriented, let's say, oh, for example WebWork. Then, the commands that are instantiated by the web framework can be used directly for the entity creation. The code becomes very simple, and very compact. No extra junk needed. Example execute code in an action using WebWork: protected String doExecute() throws Exception { try { Portal.getForums().create(this); } catch (javax.ejb.CreateException e) { return ERROR; } if (invalidInput()) return ERROR; else return SUCCESS; } -- So, the command just passes itself to the creation mechanism outlined above, where it is used to initialize the new entity. And so on and so forth :-) Was this answer what you were asking for? /Rickard -- Rickard Öberg Chief Architect, TheServerSide.com The Middleware Company _______________________________________________ Xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user