Announcement Announcement Module
Collapse
No announcement yet.
Aspect on Servlet Doesn't Execute Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Aspect on Servlet Doesn't Execute

    Hello - I'm trying to use a spring aop aspect with a servlet.

    I have the following spring configuration:

    <aop:aspectj-autoproxy proxy-target-class="true"/>
    <aop:config>
    <aopointcut id="monitorScope" expression="(execution(* com.probuild.intranet.web.servlet..doGet(..)))" />

    <aop:aspect id="myMonitoringAspect" ref="monitoringAspect">
    <aop:around method="monitor" pointcut-ref="monitorScope" />
    </aop:aspect>

    </aop:config>

    <bean id="monitoringAspect" class="com.probuild.aspects.AroundAspect" />

    and the following web configuration:

    <servlet>
    <servlet-name>AssetServlet</servlet-name>
    <servlet-class>
    com.probuild.intranet.web.servlet.IntraAssetServle t
    </servlet-class>
    <init-param>
    <param-name>folderFilter</param-name>
    <param-value>/intranet/resources</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>AssetServlet</servlet-name>
    <url-pattern>/asset</url-pattern>
    </servlet-mapping>


    When deployed, the monitoringAspect does not get executed when the doGet method is called. I've tried a variety of configurations but as of yet have not been able to find the sweet spot. Does anyone see anything obviously wrong with this config? Or better still, does anyone have any suggestions that I might try?

    Thanks in advance for your help.

  • #2
    Originally posted by kconway View Post
    ...
    When deployed, the monitoringAspect does not get executed when the doGet method is called. I've tried a variety of configurations but as of yet have not been able to find the sweet spot. Does anyone see anything obviously wrong with this config? Or better still, does anyone have any suggestions that I might try?

    Thanks in advance for your help.
    Spring AOP is proxy-based. That means that the client of AOP-advised bean should perform the call not against the bean itself but on its proxy. When the proxy is called AOP logic is applied if necessary and the call is dispatched to the backing bean. Check corresponding reference section about that - 6.6.1. Understanding AOP proxies. It seems that your call is processed on the 'raw' bean.

    You can check your configuration in order to make sure that the proxy processes the call to be AOP-advised. Another approach is to use aspectj-weaving.

    Comment


    • #3
      Thanks for the response. Turns out that what I really needed to do was rtfm :-D I think I have a solution for my problem. Cheers!

      Comment

      Working...
      X