Home Tutorial Spring Spring3 Aop Spring AOP concurency Throttle Interceptor


Share on Google+Share on Google+
Spring AOP concurency Throttle Interceptor
Posted on: September 15, 2010 at 12:00 AM
In this tutorial you will see how Interceptor throttles concurrent access.

AOP concurrency Throttle Interceptor

In this example you will see, Interceptor that throttles concurrent access, blocking invocations if a specified concurrency limit is reached.


package roseindia.net;

public class StudentBean {
	String studentName;
	String studentCourse;

	public String getStudentName() {
		return studentName;

	public void setStudentName(String studentName) {
		this.studentName = studentName;

	public String getStudentCourse() {
		return studentCourse;

	public void setStudentCourse(String studentCourse) {
		this.studentCourse = studentCourse;

	public void showValue() {
		System.out.println("Show Results:" + this.studentName + " "
				+ this.studentCourse);


package roseindia.net;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

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


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

  <bean id="testBean" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="target">
      <bean class="roseindia.net.StudentBean">
        <property name="studentName" value="James Bond," />
        <property name="studentCourse" value="B.Tech" />
    <property name="interceptorNames">
        <idref bean="nameMatchMethodPointcutAdvisor" />
    <property name="proxyTargetClass" value="true" />
  <bean id="nameMatchMethodPointcutAdvisor"
    <property name="advice" ref="concurrencyThrottleInterceptor" />
    <property name="mappedName" value="showValue" />
  <bean id="concurrencyThrottleInterceptor"
    <property name="concurrencyLimit" value="1" />


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

Show Results:James Bond, B.Tech

Download this example code


Related Tags for Spring AOP concurency Throttle Interceptor:

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.

Posted on: September 15, 2010

Recommend the tutorial

Advertisements Advertisements