Why AOP?

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>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s