Results 1 to 8 of 8

Thread: aop dependencies

  1. #1
    Join Date
    Mar 2007
    Posts
    5

    Default aop dependencies

    Can I use spring(2.0.3) aop without aspectj?
    I dont want to use aspectj at all and I dont want to include it on my classpath.
    When I dont include it, I get a class not found error.
    Here is the aop code that causes the error and the error itself:

    <aop:config>
    <aopointcut id="mainServiceMethods" expression="execution(* testing.*Service.*(..))"/>
    </aop:config>

    Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

    The README for the spring download doesnt mention aspectj as a dependency for the spring aop module.

    Is there a bug with this release, is aspectj mandatory, or have I made a mistake?

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

    Default

    The pointcut expression that you are using is an AspectJ expression. Spring, therefore, needs the AspectJ libraries to parse that expression.

    What's the reason you don't want AspectJ on you classpath?

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

  3. #3
    Join Date
    Mar 2007
    Posts
    5

    Default

    I just want to use pure java dynamic proxy aop. i.e. no bytecode fancy business.

    If spring just uses it to parse the expression, that's OK.

    Although, if people on my team see aspectj jars, they may think that we're using it.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    It uses it just to parse the expression. If some people on your team have problem with it, you might want to consider not using the expression but just the old Spring AOP way.

    However when using AspectJ it doesn't mean you have to use it for bytecode manipulation but still use jdk proxies (Although the latter won't work if you need class proxies).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Default

    Marten,

    Does this means aspectj with spring still uses jdk proxy approach, not a byte code transformation ?

    In that case if we need to enable byte code transformation instead of jdk proxy to enhance performance, could you suggest some way to achieve it.

    Shiv

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

    Default

    The use of JDK proxies vs. bytecode proxies is determined by whether the bean being advised implements interface or not. The use of AspectJ or Spring's traditional AOP is not a governing factor here.

    You can, however, explicitly indicate the use of bytecode-based proxy by setting proxy-target-class=true in <aop:aspectj-autoproxy> or <aop:config> elements. The option attribute for Spring's traditional AOP is optimize=true when you define a proxy factory bean.

    Just to be clear: AspectJ has bytecode-based weaving (not to be confused with bytecode-based proxy). That is an entirely different thing, enabled by built-time or load-time AspectJ weaving.

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

  7. #7

    Default

    Thanks Ramnivas for your input.

    I have gone through few earlier threads and blogs which confirms that aspectj and spring AOP are thread safe.

    Could you please suggest me few optimizations to configure aspectj AOP better performant.

    Does enabling bytecode-based weaving is going to help us bettering the performance.

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

    Default

    You are welcome!

    My suggestion is to not worry about performance of proxy until you determine that such optimization will improve overall performance. This must be determined through benchmark with real entries (database etc.). You are most likely to find out that proxy mechanism (whichever kind you use) adds insignificant overhead.

    -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
  •