Results 1 to 3 of 3

Thread: problem running simple aop!

  1. #1

    Default problem running simple aop!

    I am trying to run simple example of MethodBeforeAdvice. For some reason, method calls are not intercepted. Any suggestions? thanks in advance.

    Iitem is an interface. Book2 implements the interface.

    Code:
    my xml:
    <!-- simple bean implements Iitem--> 
    <bean id="book2" class="spring.test.Book2"/>    
    	
    <!-- The interceptor class --> 
    <bean id="before" class="spring.test.LogBefore"/>
    	
    <!--Proxying --> 
    <bean id="something" class="org.springframework.aop.framework.ProxyFactoryBean"> 
    <property name="proxyInterfaces"><value>spring.test.Iitem</value></property> 
    <property name="target"><ref local="book2"/></property> 
      <property name="interceptorNames"> 
      <list> 
      <value>before</value> 
      </list> 
      </property> 
     </bean> 
    
    code&#58;
    
    public class MainApplication &#123;
    
    public static void main&#40;String&#91;&#93; args&#41; &#123;
            ApplicationContext ctx =
              new FileSystemXmlApplicationContext&#40;"spring/test/test-servlet.xml"&#41;;
    
            Iitem book2 = &#40;Iitem&#41;ctx.getBean&#40;"book2"&#41;;
            //somethig should happen here!
           book2.setName&#40;"book1"&#41;;
           System.out.println&#40;book2.getName&#40;&#41;&#41;;
    	
    &#125;
    
    &#125;

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default Re: problem running simple aop!

    Quote Originally Posted by khalidhajsaleh
    Iitem book2 = (Iitem)ctx.getBean("book2");
    You have to retrieve the proxied bean, which is "something".

    Regards,
    Andreas

  3. #3

    Default Re:

    Thanks for the help!

    Iitem book2 = (Iitem)ctx.getBean("something");

Similar Threads

  1. Replies: 13
    Last Post: Feb 5th, 2010, 12:31 AM
  2. Problem with Simple RMI Sample
    By con19m32 in forum Remoting
    Replies: 2
    Last Post: Jun 27th, 2007, 12:38 AM
  3. Replies: 5
    Last Post: Aug 25th, 2005, 04:16 PM
  4. Replies: 0
    Last Post: May 24th, 2005, 04:43 PM
  5. Problem running PetClinic in JRun4
    By tcheung in forum Web
    Replies: 3
    Last Post: Oct 29th, 2004, 11:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •