Share on Google+Share on Google+

Pointcut NameMethodMatch using BeanFactory

In this example you will learn how to match the method name using BeanFactory.

Pointcut NameMethodMatch 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.


public class SimpleBean {
	String name;

	public String getName() {
		return name;

	public void setName(String name) { = name;

	public void displayName() {
		System.out.println("Hello " +;


import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;


public class MainClaz {
	public static void main(String[] args) throws Exception {
		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(
		SimpleBean simpleBean = (SimpleBean) beanFactory.getBean("testBean");


<?xml version="1.0" encoding="UTF-8"?>

  <bean id="testBean" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="target">
      <bean class="">
        <property name="name" value="Vinay" />
    <property name="interceptorNames">
        <idref bean="methodMatchPintcut" />
    <property name="proxyTargetClass" value="true" />
  <bean id="methodMatchPintcut"
    <property name="advice" ref="concurrencyThrottleInterceptor" />
    <property name="mappedName" value="displayName" />
  <bean id="concurrencyThrottleInterceptor"
    <property name="concurrencyLimit" value="10" />


When you run this application it will display message as shown below:

Hello Vinay

Download this example code


Posted on: September 8, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.