title: Spring AOP @Before in service - Before Advice check security
body: <p>file applicationContext.xml</p>
  
  <pre><code>&lt;bean id="employee" class="com.my.Employee"&gt;
  &lt;/bean&gt;
  &lt;bean id="observer" class="com.my.Observer" /&gt;
  </code></pre>
  
  <p>Employee.java</p>
  
  <pre><code>public Employee() {
      System.out.println("Employee constructor executed");
  }
  
  private String name;
  private String company;
  
  public void setName(String name) {
      this.name = name;
  }
  
  public String getName() {
      return name;
  }
  
  public String getCompany() {
      return company;
  }
  
  public void setCompany(String company) {
      this.company = company;
  }
  </code></pre>
  
  <p>Observer.java</p>
  
  <pre><code>@Before("execution(* com.my.*.get*()) ")
      public void beforeAdvice(JoinPoint jp) {
      Employee emp = (Employee) jp.getTarget();
      if("admin".equals(emp.getName())){
          // access method get*()
          }
      else {
          // can't access method get*()
      }
  }
  </code></pre>
  
  <p>AOPTest.java</p>
  
  <pre><code>public static void main(String[] args) {
      ApplicationContext context = new ClassPathXmlApplicationContext(
              "applicationContext.xml");
      Employee employee = (Employee) context.getBean("employee");
      employee.setName("admin");
      employee.setCompany("IBM");
      System.out.println("1 = "+employee.getName());
      System.out.println("2 = " + employee.getCompany());
  }
  </code></pre>
  
  <p>If i change  </p>
  
  <pre><code>employee.setName("user");
  </code></pre>
  
  <blockquote>
    <blockquote>
      <p>// can't access method get*(). But method getName() and getCompany() is still running.
      How can i control this. If setName("user")  >>> can't access to method getName and getCompany().
      Help me ! plz </p>
    </blockquote>
  </blockquote>