Results 1 to 3 of 3

Thread: spring method injection

  1. #1
    Join Date
    Feb 2011
    Posts
    9

    Default 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 at 01:38 AM.

  2. #2
    Join Date
    Dec 2009
    Location
    Pune,India
    Posts
    60

    Default

    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

  3. #3
    Join Date
    Dec 2009
    Location
    Pune,India
    Posts
    60

    Default

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •