Best practices for exception handling [message #68711] |
Thu, 22 June 2006 08:47  |
Eclipse User |
|
|
|
Hi,
I'm looking for best practices for dealing with exceptions generated from
within bundle code. Specifically, exceptions generated within
activate(ComponentContext), deactivate(ComponentContext),
handleEvent(Event), and custom component service methods. The first three
methods are defined and called by the framework implying that either
unchecked exceptions should be thrown, or that the issue should be dealt
with by the component directly (i.e. log and leave). Which is best? How
should one deal with exceptions generated within custom service methods?
Any standard approaches or recommendations?
Cheers,
Cameron.
|
|
|
Re: Best practices for exception handling [message #69882 is a reply to message #68711] |
Thu, 13 July 2006 17:01  |
Eclipse User |
|
|
|
Hi Cameron,
The methods you mentioned are called using reflection and the spec
states that any exceptions thrown (checked or unchecked) should be
logged by the declarative services runtime implementation. In these
cases the only time you should catch and handle exceptions yourself is
if you are able to continue even though the exception occurred and you
want the activate, deactivate etc. operation to continue even though the
exception occurred. You have to decide how to handle the exception
yourself. For example, if you failed to open a specific port maybe you
can try a different one. If you can only use a specific port then you
can choose to throw the SocketException and have your service component
fail to activate.
HTH
Tom.
|
|
|
Powered by
FUDForum. Page generated in 0.04590 seconds