Injectable ExceptionHandlers

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Injectable ExceptionHandlers

nmaves
I was curious how hard it would be to add an ExceptionHandlerFactory like the TypeConverterFactory which would allow for plugins like the stripes-guice framework to inject these ExceptionHandlers.

If there is a better way I am all ears and will update the current stripes-guice project to use it.

Nathan

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Injectable ExceptionHandlers

Poitras Christian

Hi,

 

My bet is that it should be easy if exception handler classes are implementing AutoExceptionHandler. Then you only need to override the addHandler(Class) method in DelegatingExceptionHandler to get an actual instance of the exception handler using Guice’s injector before delegating the call to addHandler(Object).

 

Christian

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 1:55 AM
À : Stripes Users List
Objet : [Stripes-users] Injectable ExceptionHandlers

 

I was curious how hard it would be to add an ExceptionHandlerFactory like the TypeConverterFactory which would allow for plugins like the stripes-guice framework to inject these ExceptionHandlers.

 

If there is a better way I am all ears and will update the current stripes-guice project to use it.

 

Nathan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Injectable ExceptionHandlers

nmaves
Nice!  

I just started implementing this.  Will this still handle exception handlers that are not annotated with AutoExceptionHandler?

On Mon, Oct 20, 2014 at 6:55 AM, Poitras Christian <[hidden email]> wrote:

Hi,

 

My bet is that it should be easy if exception handler classes are implementing AutoExceptionHandler. Then you only need to override the addHandler(Class) method in DelegatingExceptionHandler to get an actual instance of the exception handler using Guice’s injector before delegating the call to addHandler(Object).

 

Christian

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 1:55 AM
À : Stripes Users List
Objet : [Stripes-users] Injectable ExceptionHandlers

 

I was curious how hard it would be to add an ExceptionHandlerFactory like the TypeConverterFactory which would allow for plugins like the stripes-guice framework to inject these ExceptionHandlers.

 

If there is a better way I am all ears and will update the current stripes-guice project to use it.

 

Nathan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Injectable ExceptionHandlers

Poitras Christian

I don’t think so.

 

I suggested extending the DelegateExceptionHandler because I think that if you extend DefaultExceptionHandler and use stripes-guice Configuration class (GuiceRuntimeConfiguration), your exception handler gets dependencies already. I haven’t tried it though...

The second reason is that stripes-guice lets Stripes find actions beans and context. So to copy that behaviour, using either DelegateExceptionHandler or DefaultExceptionHandler is the way to go.

 

Now for the end user that tries to use stripes-guice, I would suggest him either to extends DefaultExceptionHandler in which case he must use stripes-guice Configuration class, or to implement AutoExceptionHandler in which case he must add stripes-guice as an extension package.

In the end, as long as he adds stripes-guice as an extension package he should be fine with either choice.

 

If you really want to pick up classes in a non Stripes related way, ask the user to register his exception handlers in a module and inject the list of exception handlers in your custom implementation of DefaultExceptionHandler.

If you choice to go this way, I’ll give you more hints.

 

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 12:05 PM
À : Stripes Users List
Objet : Re: [Stripes-users] Injectable ExceptionHandlers

 

Nice!  

 

I just started implementing this.  Will this still handle exception handlers that are not annotated with AutoExceptionHandler?

 

On Mon, Oct 20, 2014 at 6:55 AM, Poitras Christian <[hidden email]> wrote:

Hi,

 

My bet is that it should be easy if exception handler classes are implementing AutoExceptionHandler. Then you only need to override the addHandler(Class) method in DelegatingExceptionHandler to get an actual instance of the exception handler using Guice’s injector before delegating the call to addHandler(Object).

 

Christian

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 1:55 AM
À : Stripes Users List
Objet : [Stripes-users] Injectable ExceptionHandlers

 

I was curious how hard it would be to add an ExceptionHandlerFactory like the TypeConverterFactory which would allow for plugins like the stripes-guice framework to inject these ExceptionHandlers.

 

If there is a better way I am all ears and will update the current stripes-guice project to use it.

 

Nathan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users

 


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Injectable ExceptionHandlers

nmaves
All of this was fun but it turns out it is already injected :)  Stripes-Guice already injects all ConfigurableComponent(s) which include any ExceptionHandler(s).   I went looking for a fix that I did not have a problem for :)



On Mon, Oct 20, 2014 at 10:31 AM, Poitras Christian <[hidden email]> wrote:

I don’t think so.

 

I suggested extending the DelegateExceptionHandler because I think that if you extend DefaultExceptionHandler and use stripes-guice Configuration class (GuiceRuntimeConfiguration), your exception handler gets dependencies already. I haven’t tried it though...

The second reason is that stripes-guice lets Stripes find actions beans and context. So to copy that behaviour, using either DelegateExceptionHandler or DefaultExceptionHandler is the way to go.

 

Now for the end user that tries to use stripes-guice, I would suggest him either to extends DefaultExceptionHandler in which case he must use stripes-guice Configuration class, or to implement AutoExceptionHandler in which case he must add stripes-guice as an extension package.

In the end, as long as he adds stripes-guice as an extension package he should be fine with either choice.

 

If you really want to pick up classes in a non Stripes related way, ask the user to register his exception handlers in a module and inject the list of exception handlers in your custom implementation of DefaultExceptionHandler.

If you choice to go this way, I’ll give you more hints.

 

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 12:05 PM
À : Stripes Users List
Objet : Re: [Stripes-users] Injectable ExceptionHandlers

 

Nice!  

 

I just started implementing this.  Will this still handle exception handlers that are not annotated with AutoExceptionHandler?

 

On Mon, Oct 20, 2014 at 6:55 AM, Poitras Christian <[hidden email]> wrote:

Hi,

 

My bet is that it should be easy if exception handler classes are implementing AutoExceptionHandler. Then you only need to override the addHandler(Class) method in DelegatingExceptionHandler to get an actual instance of the exception handler using Guice’s injector before delegating the call to addHandler(Object).

 

Christian

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 1:55 AM
À : Stripes Users List
Objet : [Stripes-users] Injectable ExceptionHandlers

 

I was curious how hard it would be to add an ExceptionHandlerFactory like the TypeConverterFactory which would allow for plugins like the stripes-guice framework to inject these ExceptionHandlers.

 

If there is a better way I am all ears and will update the current stripes-guice project to use it.

 

Nathan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users

 


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Injectable ExceptionHandlers

Poitras Christian

Nice to know!

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 1:56 PM
À : Stripes Users List
Objet : Re: [Stripes-users] Injectable ExceptionHandlers

 

All of this was fun but it turns out it is already injected :)  Stripes-Guice already injects all ConfigurableComponent(s) which include any ExceptionHandler(s).   I went looking for a fix that I did not have a problem for :)

 

 

 

On Mon, Oct 20, 2014 at 10:31 AM, Poitras Christian <[hidden email]> wrote:

I don’t think so.

 

I suggested extending the DelegateExceptionHandler because I think that if you extend DefaultExceptionHandler and use stripes-guice Configuration class (GuiceRuntimeConfiguration), your exception handler gets dependencies already. I haven’t tried it though...

The second reason is that stripes-guice lets Stripes find actions beans and context. So to copy that behaviour, using either DelegateExceptionHandler or DefaultExceptionHandler is the way to go.

 

Now for the end user that tries to use stripes-guice, I would suggest him either to extends DefaultExceptionHandler in which case he must use stripes-guice Configuration class, or to implement AutoExceptionHandler in which case he must add stripes-guice as an extension package.

In the end, as long as he adds stripes-guice as an extension package he should be fine with either choice.

 

If you really want to pick up classes in a non Stripes related way, ask the user to register his exception handlers in a module and inject the list of exception handlers in your custom implementation of DefaultExceptionHandler.

If you choice to go this way, I’ll give you more hints.

 

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 12:05 PM
À : Stripes Users List
Objet : Re: [Stripes-users] Injectable ExceptionHandlers

 

Nice!  

 

I just started implementing this.  Will this still handle exception handlers that are not annotated with AutoExceptionHandler?

 

On Mon, Oct 20, 2014 at 6:55 AM, Poitras Christian <[hidden email]> wrote:

Hi,

 

My bet is that it should be easy if exception handler classes are implementing AutoExceptionHandler. Then you only need to override the addHandler(Class) method in DelegatingExceptionHandler to get an actual instance of the exception handler using Guice’s injector before delegating the call to addHandler(Object).

 

Christian

 

De : Nathan Maves [mailto:[hidden email]]
Envoyé : October-20-14 1:55 AM
À : Stripes Users List
Objet : [Stripes-users] Injectable ExceptionHandlers

 

I was curious how hard it would be to add an ExceptionHandlerFactory like the TypeConverterFactory which would allow for plugins like the stripes-guice framework to inject these ExceptionHandlers.

 

If there is a better way I am all ears and will update the current stripes-guice project to use it.

 

Nathan


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users

 


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users

 


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users