Why AOP?
2008 March 31
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>