Results 1 to 2 of 2

Thread: @Configurable not working

  1. #1
    Join Date
    Sep 2006
    Posts
    7

    Default @Configurable not working

    Hello to all.

    I've the following problem. I've a ConfigurableRowMapper class that I want to make @Configurable.
    I marked it with the annotation and I put a protected field in it annotated with the @Resource (or @Autowired, the result is the same) annotation, like this:

    @Configurable
    public class PropertyRowMapper implements ParameterizedRowMapper<Property>
    {
    @Resource(name = "lobHandler")
    protected LobHandler lobHandler;

    // Do something....
    }
    The application context is configured like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
    default-autowire="byName">

    <context:component-scan base-package="..." />
    <context:spring-configured />

    <bean id="lobHandler" class="org.springframework.jdbc.support.lob.Defaul tLobHandler" />
    </beans>
    I use compile time weaving using the aspectj maven plugin with the following dependencies:
    • spring-aspects-2.5.6.jar
    • aspectjrt-1.6.1.jar
    • aspectjweaver-1.6.1.jar
    • aspectjtools-1.6.1.jar


    Compilation ends correctly and using showWeaveInfo the output is the following:
    ...
    22/12/08 11.15.41 CET: [INFO] Join point 'initialization(void com.cedac.commons.propertyset.impl.PropertyRowMapp er.<init>())' in Type 'com.cedac.commons.propertyset.impl.PropertyRowMap per' (PropertyRowMapper.java:35) advised by afterReturning advice from 'org.springframework.beans.factory.aspectj.Annotat ionBeanConfigurerAspect' (spring-aspects-2.5.6.jar!AbstractDependencyInjectionAspect.class: 87(from AbstractDependencyInjectionAspect.aj)) [with runtime test]
    ...
    Now the problem is that, when running tests, the PropertyRowMapper class is not injected with the LobHandler declared in the application context.
    I've tried different approaches to this problem but none of them seems to work.
    I've also noticed that Eclipse AJDT plugin doesn't annotate the code line with his marker (usually this happens).
    In the first I've suspected an Eclipse problem, but running tests from command line produce the same results.

    There is someone that can help me?
    This problem is driving me crazy.
    Thank you.

    Mauro

  2. #2
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    I just tried your code (in AJDT, not Maven). It works fine for me. I did make two modifications, although I don't think they matter:
    1. I changed <Property> to <String>, since I don't know which Property class you are using.
    2. I changed the namespace declaration as follows:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
                                  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                                  http://www.springframework.org/schema/aop 
                                  http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                                  http://www.springframework.org/schema/context 
                                  http://www.springframework.org/schema/context/spring-context-2.5.xsd">
                                  
    	<context:spring-configured />
    
    	<bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" />
    </beans>
    When compiling using AJDT, did you put spring-aspects.jar in the AspectPath tab?

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •