Loggable.java

package com.mugil.shapes;
public @interface Loggable {
}

.java

@Aspect
public class LoggingAspect 
{
@Around("@annotation(com.mugil.shapes.Loggable)")
	public void LoggingAdvice2(ProceedingJoinPoint pjp)
	{
		Object objObject = null;		
		
		try {
			System.out.println("Code before Method Execution Goes here");			
			objObject = pjp.proceed();
			System.out.println("Code after Method Execution Goes here");
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Triangle.xml

public class Triangle 
{
   private String name;

   @Loggable
   public String getName() 
   {
     return name;
   }
.
.
}
Posted in AOP.

Comments are closed.