-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Spring thoughts: DAO implementation interceptor
PostPosted: Thu Mar 25, 2004 9:53 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
this follows Returning ScrollableResults using Spring topic, about applying AOP interceptor instead of HibernateCallbacks use, answered by Juergen.

Applying AOP interceptor requires to have an interface for any class you use. Hopefully when designing DAOs, one would typically design them to be implementable with any persistence technologie (being JDBC, ORM, JDO, etc.). So it doesn't matter much.
But since I integrated Spring in my apps, I had to get rid of my DAOFactory in which I could specify the type of DAO to be implemented. So I could dynamically specify the implementation to use via a parameter.

I have some services (managers) that requires JdbcDAO AND HibernateDAO
Since Spring integration I had no other choice than providing 2 different DAOs to my Service via applicationContext.xml. I-e, the type of DAO used by the service is hardcoded in the service.

It's not really due to Spring, since before its integration I anyway had to specify a parameter to the Factory for it to know which implementation to give back. So it was also kind of hardcoded.

But this Interceptor stuff makes me realise I could have an interceptor between service definition and DAO def. in the applicationContext.xml. I-e when the Service tries to load its DAO an Interceptor gives him the desired implementation following specification in a xml file.

I wouldn't need something like this anymore (with 2 different adherentDAO)
Code:
    <!-- AdherentService -->
    <bean id="adherentServiceTarget" class="org.xx.adherent.service.AdherentService" singleton="true">
        <property name="transactionManager">
            <ref bean="transactionManager"/>
        </property>
        <property name="adherentDAO">
            <ref bean="adherentDAO"/>
        </property>
        <property name="adherentDAOJdbc">
            <ref bean="adherentDAOJdbc"/>
        </property>
        <property name="commonDAO">
            <ref bean="commonDAO"/>
        </property>
    </bean>


but only:

Code:
    <!-- AdherentService -->
    <bean id="adherentServiceTarget" class="org.xx.adherent.service.AdherentService" singleton="true">
        <property name="transactionManager">
            <ref bean="transactionManager"/>
        </property>
        <property name="adherentDAO">
            <ref bean="adherentDAO"/>
        </property>
        <property name="commonDAO">
            <ref bean="commonDAO"/>
        </property>
    </bean>


Am I any clear?
I think of something that could dynamically associates beans following an xml configuration.

such method 1 of such classA: HibernateDAO
such method 2 of such classB: JdbcDAO

being an AOP framweork, would it be possible to plug something like this on Spring?? Interceptor between Beans??? Or would it require some refactoring? Or is it even already possible?

OUps! I think I'm realizing the power of AOP !!!
I'm a real beginner in AOP so it would probably takes me ages to understand how Spring effectively works, but it sound really usefull to be able to implement Interceptor. (which is an AOP concept, isn't it?)

Any thought on this is welcome.


Last edited by nodje on Tue Jun 03, 2008 5:35 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 25, 2004 12:02 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It is possible to implement DAO's as interceptor, see http://voruta.sf.net, the same can be used for HQL queries. You can fork this code and implement "dynamic" DAO's for hibernate (it has pluggable interface for query languages, but it is tested with sql only in practice).[/url]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.