Why AOP?

2008 March 31
by Frank Mao

AOP, Aspect Oriented Programing, we need it because we want to do logging, security, and all those crosscutting concerns in the right way.

Business Objects, or domain object should not involved those because they should be clean and simple. Those crosscutting concerns can be injected into, by introducing AOP, through Castle Windsor Container, creating an object implementing IInterceptor interface, then inject it into the target BO by changing configuration file. Example can be found at Matthew’s old blog, and new blog.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <components>
    <component id="repository"
               service="WindsorInterceptor.IRepository`1, WindsorInterceptor"
               type="WindsorInterceptor.Repository`1, WindsorInterceptor">
      <interceptors>
        <interceptor>${logInterceptor}</interceptor>
      </interceptors>
    </component>
    <component id="logInterceptor"
               service="WindsorInterceptor.ConsoleLogInterceptor, WindsorInterceptor"
               type="WindsorInterceptor.ConsoleLogInterceptor, WindsorInterceptor"
               lifestyle="transient">
    </component>
  </components>
</configuration>

No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS