On Tue, 2004-02-17 at 10:08, DDU DUQUENNOY Didier wrote:
> I'm trying to generate a Business Delegate for a Session Bean.
> Since I'm using a specific implementation, I use a custom XDT file.
> 
> My problem is that I want to catch exceptions that *may be* throws by the Bean 
> class, for example javax.ejb.FinderException or javax.ejb.CreateException.
> To generate the required catch block, I need to know wether these exceptions are 
> thrown or not.
> 
> I'm looking for a way to analyse the result of <XDtMethod:exceptionList/> to do 
> this, but I find no way to substring nor to test a string value with XDT tags.
> 
> How should I do this?

The cleanest way might be to write a custom tag handler.  Then you can
just use something like

<XDtDidier:ifThrowsFubarException>
} catch (FubarException e) {
    // handle exception
</XDtDidier:ifThrowsFubarException>

in your template.  Much tidier than tags to do string manipulation on
the output of other tags' output.

Copy one of the existing tag handlers as a starting point; the existing
exceptionList code should give you some pointers as to the
implementation you'll need (get current method, get its exceptions,
iterate through and look for FubarException, generate tag body if
found).  Then make sure it gets included in the ejbdoclet taskdef's
classpath, and add a

<XDtTagDef:tagDef namespace="Didier"
handler="com.fubar.DidierTagHandler"/>

at the top of your custom template.  I think that should do the trick.

Alternatively, you could raise an enhancement request in JIRA to have
"ifThrows" & "ifDoesntThrow" template tags added to the existing
XDtMethod and XDtConstructor tag handlers, as they sound like generally
useful additions to me :-)  You could even write them yourself and
submit a patch...


Andrew.



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to