SpringDataSourceBeanPostProcessor too late

71 views
Skip to first unread message

Roger Villars

unread,
Apr 3, 2012, 9:17:00 AM4/3/12
to javamelody
Hi,

I tried to monitor my C3P0 DataSource configured by Spring using
javamelody's SpringDataSourceBeanPostProcessor defined in monitoring-
spring.xml.

It didn't work.
After looking through the code I found out that actually the
configured PersistenceExceptionTranslationPostProcessor seems to load
the entire persistence configuration (entityManagerFactory,
dataSource, etc.) before the SpringDataSourceBeanPostProcessor is even
registered. Therefore the data source isn't processed by the
SpringDataSourceBeanPostProcessor.

This is because BeanPostProcessors don't seem the be ordered as they
appear in the context configuration. Instead there are special
interfaces which define the order.

1. PriorityOrdered (Highest and lowest precedence)
2. Ordered (Highest and lowest precedence)
3. no interface (NonOrdered)

PersistenceExceptionTranslationPostProcessor implements the "Ordered"
interface with LOWEST_PRECEDENCE. The
SpringDataSourceBeanPostProcessor needs to implement at least
"PriorityOrdered" with LOWEST_PRECEDENCE so it could be registered
before the data source ("Ordered" with highest does not seem to work).

Deriving from SpringDataSourceBeanPostProcessor and implementing the
PriorityOrdered interface seems to do the trick but I think it would
be better to add this directly to the original processor so monitoring-
spring.xml can be used as described in the manual.

Should I create an bug issue for this or does anyone see problems with
this approach?

Roger

evernat

unread,
Apr 5, 2012, 9:21:44 AM4/5/12
to javamelody
Hi,

It seems good to implement PriorityOrdered, with LOWEST_PRECEDENCE as
the default order, in SpringDataSourceBeanPostProcessor.
And it would be great to have the view of other people, such as David
Karlsen, on this.

bye,
Emeric

David Karlsen

unread,
Apr 5, 2012, 11:02:34 AM4/5/12
to javam...@googlegroups.com
I think it's a good idea as it gives better control over the proxying order.

2012/4/5 evernat <eve...@free.fr>:

--
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Vernat Emeric

unread,
Apr 5, 2012, 6:40:47 PM4/5/12
to javam...@googlegroups.com
Thanks David to be here.

I have committed the SpringDataSourceBeanPostProcessor with
PriorityOrdered in trunk
(See http://code.google.com/p/javamelody/source/detail?r=2724)
and it is ready for the next release (1.37)

So the Spring post-processor to monitor the jdbc datasources will be
initialized before most other beans.

I have made a new build from the current trunk and it is available at:
http://javamelody.googlecode.com/files/javamelody-20120406.jar

bye,
Emeric

Le 05/04/2012 17:02, David Karlsen a �crit :

Roger Villars

unread,
Apr 13, 2012, 7:49:28 AM4/13/12
to javamelody
Sorry for the late answer.
Just wanted to say thanks for the fast reply, the change and the good
work you guys are doing.
The new build works great.

On 6 Apr., 00:40, Vernat Emeric <ever...@free.fr> wrote:
> Thanks David to be here.
>
> I have committed the SpringDataSourceBeanPostProcessor with
> PriorityOrdered in trunk
> (Seehttp://code.google.com/p/javamelody/source/detail?r=2724)
> and it is ready for the next release (1.37)
>
> So the Spring post-processor to monitor the jdbc datasources will be
> initialized before most other beans.
>
> I have made a new build from the current trunk and it is available at:http://javamelody.googlecode.com/files/javamelody-20120406.jar
>
> bye,
> Emeric
>
> Le 05/04/2012 17:02, David Karlsen a crit :
>
>
>
>
>
>
>
> > I think it's a good idea as it gives better control over the proxying order.
>
> > 2012/4/5 evernat<ever...@free.fr>:
Reply all
Reply to author
Forward
0 new messages