Announcement Announcement Module
Collapse
No announcement yet.
spring method injection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring method injection

    Hello guys .. I am trying to do simple method injection but i am having problem so please help me .... I have a class "NewClass " -----
    package lookupMethodInjection;

    public class NewClass {

    public String getMessage() {
    String makedUpMessage = "UUM say some thing -- ";
    makedUpMessage = makedUpMessage + makeUpMessage();
    return makedUpMessage;
    }

    public String makeUpMessage() {
    return "";
    }
    }
    then I have a second class "Helper " -----
    package lookupMethodInjection;

    public class Helper {

    public String makeUpMessage() {
    return "Hello ";
    }
    }
    and the XML Definition is ----
    <bean id="helpersss" class="lookupMethodInjection.Helper" scope="prototype" ></bean>
    <bean id="newClasss" class="lookupMethodInjection.NewClass">
    <lookup-method bean="helpersss" name="makeUpMessage"/>
    </bean>
    now when i tried to run using NetBeans IDE it shows "The module has not been deployed."

    so someone please tell me what is the problem . Is it in the class or in the XML definition...

    Thank
    Last edited by paragxx; Mar 2nd, 2011, 02:38 AM.

  • #2
    Is this the way you want

    Code:
      <bean id="helpersss" class="java.lang.String" scope="prototype" >
    	 	<constructor-arg value="initialTarget"/>
    	  </bean>
    		<bean id="newClasss" class="lookupMethodInjection.NewClass">
    			<lookup-method bean="helpersss" name="makeUpMessage"/>
    		</bean>

    your class


    Code:
    public abstract class NewClass {
    
    	public String getMessage() {
    	String makedUpMessage = "UUM say some thing -- ";
    	makedUpMessage = makedUpMessage + makeUpMessage();
    	return makedUpMessage;
    	}
    
    	public abstract String makeUpMessage() ; 
    	}



    out put will be


    UUM say some thing -- initialTarget

    Comment


    • #3
      OR

      your XML

      Code:
       <bean id="helpersss" class="com.spring.forum.Helper" scope="prototype" >
      	  
      	  </bean>
      		<bean id="newClasss" class="lookupMethodInjection.NewClass">
      			<lookup-method bean="helpersss" name="makeUpMessage"/>
      		</bean>

      Your clas


      Code:
      public abstract class NewClass {
      
      	public String getMessage() {
      	String makedUpMessage = "UUM say some thing -- ";
      	makedUpMessage = makedUpMessage + makeUpMessage().makeUpMessage();
      	return makedUpMessage;
      	}
      
      	public abstract Helper makeUpMessage() ; 
      	}

      OUTPUT


      UUM say some thing -- Hello

      Comment

      Working...
      X