Example and Steps for Creating Advice -1

Started by thiruvasagamani, Sep 24, 2008, 11:16 AM

Previous topic - Next topic

thiruvasagamani

Example and Steps for Creating Advice -1

The following are the steps which need to follow for creating advices.


   1. Create an interface for the Service Bean for which is the target object for Advise.

   2. Create the implementation of that interface.

   3. Create an Aspect Bean class which has method which is used to advice the target objects.

   4. Declare all the beans in the config file i.e. beans.xml

   5. Declare the <aop:config> and <aop:aspect> with pointcuts and advice type settings.

   6. Create the Class which will call get the object and call the advised method.


Lets see all the steps and settings with the help of example.

Step 1:- Lets have the following interface Service which has testAdvice method.


package com.visualbuilder.aop;

public interface Service {

      public void testAdvice();

}




Step2:- Following is the implementation for the Service interface.


package com.visualbuilder.aop;



public class ServiceImpl implements Service{

public void testAdvice() {

        System.out.println("This is the Test Advice Method");

    }


}
Thiruvasakamani Karnan