1) If you're willing to upgrade to Spring 2.5 (which is still a release
candidate, but due for release in 3 days), you can use
<<context:component-scan> to do exactly what you're looking for. See
http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-scanning-autodetection
2) I'm no expert on Spring-AOP, but I'm pretty sure you can at least get
rid of the proxy factory bean by using the AOP namespace and pointcut
expression that matches all of your DAO object.s
Hope this helps,
Adam
Edward Sumerfield wrote:
> Two questions today:
>
> 1) I have hibernate 3 annotations buzzing along just fine all
> configured in Spring 2 but, being a lazy fellow, I don't want to have
> to add every entity into the Spring config file. Instead, I would like
> an autodiscovery mechanism to find the @Entity annotated classes and
> add them to Spring config automatically.
>
> Before I go off an write such a thing perhaps someone knows of an
> existing solution.
>
> <property name="annotatedClasses">
> <list>
> <value>org.acme.entity.Customer </value>
> </list>
> </property>
>
> 2) I am using the HibernateDaoSupport class and so have two beans
> configured for every Dao that I write. Is there a simple way to
> condense the bean declarations needed to add a Dao? This is what I
> have at the moment for a single Dao and the only difference between
> Daos is the word "Acme", all the rest is vanilla template code.
>
> Is there a simpler way than code generation?
>
> <bean
> id="acmeDaoTarget"
> class="org.acme.dao.AcmeDaoImpl"
> autowire="byName" />
>
> <bean
> id="org.acme.dao.AcmeDao"
> class="org.springframework.aop.framework.ProxyFactoryBean">
> <property name="proxyInterfaces">
> <value> org.acme.dao.AcmeDao</value>
> </property>
> <property name="interceptorNames">
> <list>
> <value>hibernateInterceptor</value>
> <value>acmeDaoTarget</value>
> </list>
> </property>
> </bean>
>
> --
> Ed
|