Announcement Announcement Module
Collapse
No announcement yet.
Proxy created for beans that do not match the pointcut expression Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Proxy created for beans that do not match the pointcut expression

    Hi,

    I have following AOP configuration:

    Code:
    	<aop:config>
    		<aop:aspect id="operatorAuditAspect" ref="operatorAPIAuditor">
    			<aop:pointcut id="auditedOperation" expression="within(com.abc..*) &amp;&amp; (@target(com.abc.Audited) || @annotation(com.abc.Audited))" />
    			<aop:after pointcut-ref="auditedOperation" method="doAudit" />
    		</aop:aspect>
    	</aop:config>
    This works OK, the advice is executed for all beans in package com.abc.. with @Audited annotation. However, it seems that ALL beans with types in package com.abc are now proxied, which results in exceptions when I want to inject beans with concrete types.

    e.g.

    No matching bean of type [com.abc.Foo] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.

    Is this normal?

  • #2
    Which is correct and this has to do with your pointcut expression. It consists of a static part and part that is checked at runtime. The within is the static part, for this match proxies are created (basically everything in the package). The @target and @annotation are checked at runtime.

    I suggest a read of the AspectJ reference guide or the excellent AspectJ in Action (2nd edition).

    Comment


    • #3
      Thanks, I got it working by changing @target to @within.

      Comment

      Working...
      X