News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

Advice Parameters-1

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

Previous topic - Next topic

thiruvasagamani

Advice Parameters-1

In the previous section we have seen how do we create a before advice on methods which has void parameters. We can also advise the methods which accept parameters with some modification in the code.

Lets revisit the example. Instead of having the void method we have now created the method which accept name. So the interface and implementation class  is changed as follows:-

package com.visualbuilder.aop;

public interface Service {

    public void testAdvice(String name);

}


public class ServiceImpl implements Service{

    public void testAdvice(String name) {

        System.out.println("This is the Test Advice Method for Name " + name);

    }

}

AdviceClass.java:- This class now accept the method parameter same as the target method testAdvice().

package com.visualbuilder.aop;



public class AdviceClass {

public void beforeMethod(String name){

     if(name != null && name.equalsIgnoreCase("visualbuilder")){

         System.out.println("The method is advised.");

     }

}

}
Thiruvasakamani Karnan