Announcement Announcement Module
Collapse
No announcement yet.
@Configurable does not work? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Configurable does not work?

    I have tried to bring domain object ioc to my codes, but failed. I am not familiar with @Aspectj, but really like this 2.0 feature. Can anybody help?

    Following is my code (in blue), and result (in red). Only two classes and a beans.xml. Class 'ModelTester' is the domain object, and 'Test' is a simple test. I run these as LTW, (use -javaagent:./lib/aspectjweaver.jar)

    package net.netPerson.domain.user.model;

    import org.springframework.beans.factory.annotation.Confi gurable;

    @Configurable("modelTester")
    public class ModelTester{
    private String pro;

    public String getPro() {
    return pro;
    }

    public void setPro(String pro) {
    this.pro = pro;
    }

    }

    public class Test {
    public static void main(String[] args) {
    ModelTester modelTester=new ModelTester();
    System.out.print( modelTester.getPro());
    }
    }


    <?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:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd">

    <aop:spring-configured/>
    <bean id="modelTester" class="net.netPerson.domain.user.model.ModelTester " singleton="false">
    <property name="pro" value="i am a pro"/>
    </bean>
    </beans>


    2006-9-12 10:32:03 org.springframework.aop.aspectj.AspectJWeaverMessa geHandler handleMessage
    信息: [AspectJ] register aspect org.springframework.beans.factory.aspectj.Annotati onBeanConfigurerAspect
    2006-9-12 10:32:04 org.springframework.aop.aspectj.AspectJWeaverMessa geHandler handleMessage
    信息: [AspectJ] register aspect org.springframework.transaction.aspectj.Annotation TransactionAspect
    2006-9-12 10:32:04 org.springframework.aop.aspectj.AspectJWeaverMessa geHandler handleMessage
    信息: [AspectJ] weaving 'net/netPerson/domain/user/model/Test'
    2006-9-12 10:32:04 org.springframework.aop.aspectj.AspectJWeaverMessa geHandler handleMessage
    严重: [AspectJ] trouble in:
    public class net.netPerson.domain.user.model.Test extends java.lang.Object:
    public void <init>():
    ALOAD_0 // Lnet/netPerson/domain/user/model/Test; this (line 3)
    INVOKESPECIAL java.lang.Object.<init> ()V
    constructor-execution(void net.netPerson.domain.user.model.Test.<init>())
    | RETURN
    constructor-execution(void net.netPerson.domain.user.model.Test.<init>())
    end public void <init>()

    public static void main(String[]):
    NEW net.netPerson.domain.user.model.ModelTester (line 5)
    DUP
    INVOKESPECIAL net.netPerson.domain.user.model.ModelTester.<init> ()V
    ASTORE_1
    GETSTATIC java.lang.System.out Ljava/io/PrintStream; (line 6)
    ALOAD_1 // Lnet/netPerson/domain/user/model/ModelTester; modelTester
    INVOKEVIRTUAL net.netPerson.domain.user.model.ModelTester.getPro ()Ljava/lang/String;
    INVOKEVIRTUAL java.io.PrintStream.print (Ljava/lang/StringV
    RETURN (line 7)
    end public static void main(String[])

    end public class net.netPerson.domain.user.model.Test

    2006-9-12 10:32:04 org.springframework.aop.aspectj.AspectJWeaverMessa geHandler handleMessage
    信息: [AspectJ] weaving 'net/netPerson/domain/user/model/ModelTester'
    2006-9-12 10:32:04 org.springframework.aop.aspectj.AspectJWeaverMessa geHandler handleMessage
    严重: [AspectJ] trouble in:
    public class net.netPerson.domain.user.model.ModelTester extends java.lang.Object:
    private String pro
    public void <init>():
    ALOAD_0 // Lnet/netPerson/domain/user/model/ModelTester; this (line 6)
    INVOKESPECIAL java.lang.Object.<init> ()V
    constructor-execution(void net.netPerson.domain.user.model.ModelTester.<init> ())
    | RETURN
    constructor-execution(void net.netPerson.domain.user.model.ModelTester.<init> ())
    end public void <init>()

    public String getPro():
    ALOAD_0 // Lnet/netPerson/domain/user/model/ModelTester; this (line 10)
    GETFIELD net.netPerson.domain.user.model.ModelTester.pro Ljava/lang/String;
    ARETURN
    end public String getPro()

    public void setPro(String):
    ALOAD_0 // Lnet/netPerson/domain/user/model/ModelTester; this (line 14)
    ALOAD_1 // Ljava/lang/String; pro
    PUTFIELD net.netPerson.domain.user.model.ModelTester.pro Ljava/lang/String;
    RETURN (line 15)
    end public void setPro(String)

    end public class net.netPerson.domain.user.model.ModelTester

    null

  • #2
    Hi

    You might have run into bug 153572, which occurs with Spring2.0rc3 and AspectJ 1.5.2:

    https://bugs.eclipse.org/bugs/show_bug.cgi?id=153572

    if you switch to the AspectJ 1.5.2a jars it should work.

    Comment


    • #3
      It works very fine, thanks a lot.

      Comment

      Working...
      X