Hi, On 25.10.2010, at 14:57, Bigard Olivier wrote:
> Hi Clement, > > The error-detector that you recommend to create is not able to know why some > instances are not valid. > Using the LogListener OSGi service, it seems to be possible to get that > information. > But it's necessary to filter out all the not interesting log records. > > In my opinion, it could be more efficient to add in an optional error-handler > the internals of iPojo that can be used to track invalid instances. > This error-handler could generate a dedicated kind of OSGi Event that could > be handled by the application. > What do you think about this proposal? Sorry to not have answered before, I'm still looking for the best solution. This error handler makes a lot of sense, but the question is where to plug this handler. Using a 'plain' iPOJO handler won't work because handlers may not communicate their errors. One solution would be to plug this handler on the iPOJO internal logger. I keep you posted when I found a consistent solution. Regards, Clement > > Thanks, > Olivier > > > -----Message d'origine----- > De : Clement Escoffier [mailto:[email protected]] > Envoyé : mercredi 13 octobre 2010 20:33 > À : [email protected] > Objet : Re: Exception handling in iPojo annotations > > Hello, > > On 13.10.2010, at 17:06, Bigard Olivier wrote: > >> Hi, >> >> >> >> When using iPojo 1.6.4 with annotations, the method you implement can >> throw Java exceptions like following: >> >> >> >> @Validate >> >> public void validate() throws Exception >> >> { >> >> throw new Exception("My Exception"); >> >> } >> >> a kind of error >> >> When executing this method, iPojo will first catch the Exception in the >> "stateChanged(int)" method of the "LifecycleCallbackHandler" class. >> >> This method will log an error and throw a new Exception that will >> finally be caught by the "setState(int)" method of the "InstanceManager" >> class. >> >> This method will stop the current iPojo instance. >> >> >> >> This mechanism is perfect, but is it possible to customize iPojo to be >> able to do more in this use-case? >> >> For example in our case: sending an Alert to someone indicating that the >> start sequence of this Bundle failed... >> >> This could be achieved by iPojo by sending a specific OSGi Event >> indicating the cause of the error. >> >> What do you think about this? > > What I do, and what I recommend, is to create a kind of error-detector. It's > a component (or a plain osgi bundle) which check the configuration of the > platform. > For example, it checks that all instances are valid, all expected instance > are created, services exposed... You can rely on the Architecture service to > know these informations. When a error is detected, > the detector can do whatever you want (Event, Mail, Jabber, Twitter ...). > > An other way is to rely on the Log Service. The error you described, logs a > message in the OSGi Log Service is available. So you can detect issues by > listening the log (using a LogServiceListener). > > Regards, > > Clement > >> >> >> >> Thanks >> >> Olivier >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

