title: Prototype Bean injected in a singleton bean in Spring
body: <p>I have injected a prototyte bean 'B' in a singleton bean 'A' as given below..</p>
  
  <pre><code>&lt;bean id="a" class="com.user.processor.A" &gt;
  &lt;property name="objectb" ref="b"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="b" class="com.user.processor.B" scope="prototype"&gt;
  &lt;aop:scoped-proxy/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>public class A { 
  
      private B objectb; 
  
      public String process() { 
  
          objectb.setX("asdf"); 
          System.out.println("value of x : " objectb.getX() ); 
  
      } 
  
      public void setobjectb(B objectb){ 
          this.objectb = objectb; 
      } 
  
  } 
  </code></pre>
  
  <hr>
  
  <p>The prototype bean 'B' contains variables and getters &amp; setters for those variables. </p>
  
  <p>In one of the methods of A I'm accessing setter method of B to set a variable, after setting if I print that variable using getter method NULL is returned. </p>
  
  <p>Each time while accessing a method in B its returning a new object of B.  </p>
  
  <p>I want new B object to be returned only when bean A is invoked.. not for the invocation of each method in B... How can i do this... </p>