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

  • AOP ambiguous situation

    Hello,

    I had a scenario like i need to log the statements for method start and end of each and every public method.

    I had opted for spring AOP as it suits my requirements best..


    Now i had flow like this

    Code:
    Controller --> Builder --> Delegator --> DAO
    I used CGLib for proxy. so i had added this statement to my beans-config.xml

    Code:
    <aop:aspectj-autoproxy proxy-target-class="true" />

    Now the problem is i can see logs for Builders,Delgators and DAOs only.

    is it due to Controllers implementing something and rest not ?

    Could any body please help me how to overcome this...?

    i need the log statements to be printed for all the layers...

    Many thanks in advance

  • #2
    proxies only apply to the same applicationcontext they are defined in. My guess, aop:aspectj stuff and your builder etc. are defined in the context loaded by the ContextLoaderListener, your controllers are discovered/loaded in the DispatcherServlet.

    Comment


    • #3
      Thanks for your response

      all the layers that i had defined where in the same application context .

      i even had VO layers inbetween them and i cant see their loggings as well.

      i suspect the reson for that not is due i\to it implementing serializable...

      if i had not got clearly what you said can you please be more clear ...?

      Comment


      • #4
        I guess there is
        - still a difference in where the stuff is loaded (at least your proxy mechanism)
        - You are duplicating your Controllers (detected in root and dispatcher servlet which renders the root ones useless)
        - Your pointcut is wrong.

        Post your web.xml and relevant configuratin files.

        Comment


        • #5
          here is my point cut

          Code:
          @Pointcut("within(com.aaa.bbb..*)")

          and my web .xml is

          Code:
          <?xml version="1.0" encoding="UTF-8"?>
          <web-app xmlns="http://java.sun.com/xml/ns/javaee"
          	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
          	version="2.5">
          
          	
          
          	<servlet>
          		<description>Spring MVC Dispatcher Servlet</description>
          		<servlet-name>springweb</servlet-name>
          		<servlet-class>
          			org.springframework.web.servlet.DispatcherServlet
          		</servlet-class>
          		<load-on-startup>2</load-on-startup>
          	</servlet>
          	<servlet-mapping>
          		<servlet-name>springweb</servlet-name>
          		<url-pattern>*.html</url-pattern>
          	</servlet-mapping>
          	
          	
          
          	<listener>
          		<listener-class>
          			org.springframework.web.context.ContextLoaderListener
          		</listener-class>
          	</listener>
          	<context-param>
          		<param-name>contextConfigLocation</param-name>
          		<param-value>
          			
          		</param-value>
          	</context-param>
          	
          	
          	
          </web-app>

          Comment


          • #6
            im importing different layers separately using import statement in beans.xml like this

            Code:
            <import resource="data-access-context.xml" />
            		<import resource="webmvc-context.xml" />

            Comment

            Working...
            X