Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:02:10+00:00 2026-05-23T09:02:10+00:00

For efficiency reasons, I am interested in limiting the number of threads that simultaneously

  • 0

For efficiency reasons, I am interested in limiting the number of threads that simultaneously uses the beans of the Spring application context (I don’t want an unlimited number of threads proccessing in my limited memory).

I have found here (spring documentation) a way to achieve this by pooling the beans in a EJB style, by doing the following:

  • Declare the target bean as scope “prototype”.
  • Declare a Pool provider that will deliver a limited number of pooled “target” instances.
  • Declare a “ProxyFactoryBean” which function is not clear to me.

Here is the declaration of this beans:

<bean id="businessObjectTarget" class="com.mycompany.MyBusinessObject" 
    scope="prototype">
  ... properties omitted
</bean>

<bean id="poolTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">
  <property name="targetBeanName" value="businessObjectTarget"/>
  <property name="maxSize" value="25"/>
</bean>

<bean id="businessObject" class="org.springframework.aop.framework.ProxyFactoryBean">
  <property name="targetSource" ref="poolTargetSource"/>
  <property name="interceptorNames" value="myInterceptor"/>
</bean>

My problem is that when I will declare another bean to use pooled instances of the “businessObjectTarget”, how should I do it? I mean, when i try to do something like this:

<bean id="clientBean" class="com.mycompany.ClientOfTheBusinessObject">
  <property name="businessObject" ref="WHAT TO PUT HERE???"/>
</bean>

What should be the value of the “ref” ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:02:11+00:00Added an answer on May 23, 2026 at 9:02 am

    You cannot use properties to get instances of prototypes.
    One option is to use the lookup methods (see chapter 3.3.7.1)
    Another option to get your bean in code: make your com.mycompany.ClientOfTheBusinessObject to implement the ApplicationContextAware interface and then call context.getBean("clientBean")

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that creating too many threads in an application isn't being what you
For efficiency reasons, I always avoid writing loops like this: for(std::size_t i = 0;
I have an application (C++) that I think would be well served by an
My application includes some .txt files that it needs to read. I used to
I'm writing a web application that should show very large results on a search
What's the relative efficiency of integer comparison in java? == >= <= > <
Is there a fast/efficiency way to check if a table is empty? DECLARE @StartEndTimes
In terms of performance and efficiency, is it better to use lots of small
I was reading another question pertaining the efficiency of two lines of code, and
I'm trying to test the efficiency of the Google App Engine Datastore database. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.