In this example you will learn how to match the method name using BeanFactory.
In this example you will learn how to match the method name using BeanFactory.A pointcut is a bunch of codes that picks out join points and exposes data from the execution context of those join points.Following is an example of NameMethodMatch using springConfig.xml.
SimpleBean.java
package roseindia.net.bean;
public class SimpleBean {
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void displayName() {
System.out.println("Hello " + this.name);
}
}
MainClaz.java
package roseindia.net.main;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import roseindia.net.bean.SimpleBean;
public class MainClaz {
public static void main(String[] args) throws Exception {
BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(
"springconfig/config.xml"));
SimpleBean simpleBean = (SimpleBean) beanFactory.getBean("testBean");
simpleBean.displayName();
}
}
config.xml
<?xml version="1.0" encoding="UTF-8"?>
|
| Hello Vinay |