title: Spring AOP: Passing parameter in aspect method
body: <p>I am new to Spring AOP and trying to create a demo using <code>aop:around</code>.</p>
  
  <p>A simple bean class:</p>
  
  <pre><code>public class Employee {
  
  private String name;
  public String getName() {
      System.out.println("Name: " + name);
      return name;
  }
  public void setName(String name) {
      this.name = name;
  }
  }
  </code></pre>
  
  <p>Aspect implementation:</p>
  
  <pre><code>public class PrintingAspect {
  
  public void performPrinting(ProceedingJoinPoint point){
      try {
          System.out.println("Before Printing!!!");
          point.proceed();        
          System.out.println("After Printing!!!");
      } catch (Throwable e) {         
          System.out.println("Exception Printing");
      }
  }
  }
  </code></pre>
  
  <p>Context XML:</p>
  
  <pre><code>&lt;bean id="aspect" class="com.aop.aspect.PrintingAspect"&gt;        
  &lt;/bean&gt;    
  &lt;bean id="employee" class="com.aop.model.Employee"&gt;
      &lt;property name="name" value="XXX"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;aop:config&gt;
      &lt;aop:pointcut id="empName" expression="execution(* com.aop.model.Employee.getName(..))"/&gt;
      &lt;aop:aspect ref="aspect"&gt;            
          &lt;aop:around pointcut-ref="empName" method="performPrinting"/&gt;
      &lt;/aop:aspect&gt;
  &lt;/aop:config&gt;
  </code></pre>
  
  <p>App.java</p>
  
  <pre><code>public class App 
  {
  public static void main( String[] args )
  {
      ApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");
      Employee empl = (Employee)context.getBean("employee");
      System.out.println("Employee Names: " + empl.getName());
  }
  }
  </code></pre>
  
  <p>The o/p I am getting is:</p>
  
  <p>Before Printing!!!
  Name: XXX
  After Printing!!!
  Employee Names: null</p>
  
  <p>Why is the last one null ?</p>