Announcement Announcement Module
Collapse
No announcement yet.
aop dependencies Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


    • #3
      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.

      Comment


      • #4
        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).

        Comment


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

          Comment


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

            Comment


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

              Comment


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

                Comment

                Working...
                X