A couple more notes on this.
J. Matthew Pryor wrote:
>> public void ejbCreate(CreateMyEntity command)
>>
>
> would CreateMyEntity be a base class or perhaps an interface ?
I have changed this now so that it is an interface that belongs to the
EJB layer. That way there is not reliance on WebWork as the underlying
implementation of the commands. I.e. I have this:
public interface EntityVisitor
{
// Static --------------------------------------------------------
// Valid actions that can be performed by visitors
public static String CREATE = "create";
public static String POST_CREATE = "postCreate";
// Public --------------------------------------------------------
public void setEntity(EntityBean instance);
public void execute(String aName)
throws Exception;
}
which is a generic visitor pattern interface that can be used for more
than just the create. It can also be used to allow visitors to get
DTO-like property subsets, or similar.
My generic create looks like this now:
public Object ejbCreate(EntityVisitor aVisitor)
throws CreateException
{
try
{
aVisitor.setEntity((EntityBean)this);
aVisitor.execute(EntityVisitor.CREATE);
} catch (Exception e)
{
throw new CreateException("Could not create entity:"+e);
}
dao.create();
return null;
}
public void ejbPostCreate(EntityVisitor aVisitor)
throws CreateException
{
try
{
aVisitor.execute(EntityVisitor.POST_CREATE);
} catch (Exception e)
{
throw new CreateException("Could not create entity:"+e);
}
}
--
So, it is very clean, and doesn't have to change as new EJB
relationships or properties are introduced. Instead the visitors are
updated to handle that, but they are supposed to be more "alive" (in
terms of evolution) IMO, so that's ok.
/Rickard
--
Rickard �berg
Chief Architect, TheServerSide.com
The Middleware Company
_______________________________________________
Xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user