On 18 Mar 2009, at 07:27, Carlo de Wolf wrote:
Pete Muir wrote:
>
> On 17 Mar 2009, at 22:29, Carlo de Wolf wrote:
>
> ...
>
>> On another note I would name the
>> SessionObjectReference.getReference method getBusinessObject (in
>> the likes of SessionContext.getBusinessObject).
>
> Done
>
>> And both should throw an NoSuchEJBException if the EJB is already
>> removed.
>
> Done
>
>> (Note: keep the IllegalStateException for invalid
>> businessInterface.)
>
> Not IllegalArgumentException? I went for IllegalArguementException
>
> I also did the changes Ken suggested whilst there...
Well actually I hate both exceptions in this case. I went for
IllegalStateException, because that's how
SessionContext.getBusinessObject works, IllegalArgumentException
would have been the obvious.
Ok, updated to EJB spec version as that is best for consistency...
I don't entirely agree with Bloch's guidelines for exception
handling (#1). To me the guideline should be: a checked exception
whenever an user error is encountered. A precondition on an argument
is an user error. So NoSuchBusinessInterfaceException would have
been better.
Then again this leads to ugly coding (#2), so it might even be
better to add
boolean SessionContext.isBusinessInterface(Class<?>
businessInterface);
Then it becomes a programming error again.
Ken, does this argument make sense to you? If so, I'll raise it in
EJB-EG.
> ...
>
Carlo
#1: Effective Java Item 40: Use checked exception for recoverable
conditions and run-time exceptions for programming errors
#2: EJ Item 41: Avoid unnecessary use of checked exceptions
--
Pete Muir
http://www.seamframework.org
http://in.relation.to/Bloggers/Pete