Spring Java

File: IBusinessLogic.java
public interface IBusinessLogic
{
   public void foo();
}
File: MainApplication.java
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class MainApplication
{
   public static void main(String [] args)
   {
      ApplicationContext ctx = new FileSystemXmlApplicationContext("build/springconfig.xml");
      IBusinessLogic testObject = (IBusinessLogic) ctx.getBean("businesslogicbean");
      testObject.foo();
   }
}
File: springconfig.xml



  
    class="org.springframework.aop.framework.ProxyFactoryBean">
    
      IBusinessLogic
    
    
      
    
    
      
        theTracingBeforeAdvisor
        theTracingAfterAdvisor
      

    
  
  
    class="BusinessLogic"/>
  
  
    class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    
      
    
    
      .*
    
  
  
  
  
    class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    
      
    
    
      .*
    
  
  
    class="TracingBeforeAdvice"/>
    class="TracingAfterAdvice"/>

File: TracingAfterAdvice.java
import java.lang.reflect.Method;
import org.springframework.aop.AfterReturningAdvice;
public class TracingAfterAdvice implements AfterReturningAdvice
{
   public void afterReturning(Object object, Method m, Object[] args, Object target) throws Throwable
   {
       System.out.println("Hello world! (by " + this.getClass().getName() + ")");
   }
}
File: TracingBeforeAdvice.java
import java.lang.reflect.Method;
import org.springframework.aop.MethodBeforeAdvice;
public class TracingBeforeAdvice implements MethodBeforeAdvice
{
   public void before(Method m, Object[] args, Object target) throws Throwable
   {
      System.out.println("Hello world! (by " + this.getClass().getName() + ")");
   }
}
File: BusinessLogic.java
public class BusinessLogic implements IBusinessLogic
{
     public void foo() 
     {
       System.out.println("Inside BusinessLogic.foo()");
     }
}
           
       
Spring-SpringTracingAspect.zip( 1,538 k)