Skip to main content



      Home
Home » Eclipse Projects » Equinox » Best practices for exception handling
Best practices for exception handling [message #68711] Thu, 22 June 2006 08:47 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:NPE with j9
Next Topic:possible issue with refreshPackages and dynamically importing bundles
Goto Forum:
  


Current Time: Tue Jul 08 18:54:59 EDT 2025

Powered by FUDForum. Page generated in 0.04590 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top