Results 1 to 5 of 5

Thread: How do I define a String property as an inner bean value

  1. #1
    Join Date
    Apr 2007
    Posts
    6

    Default How do I define a String property as an inner bean value

    Hi all,

    The RmiProxyFactoryBean expects a String property for its serviceUrl. My problem is that I will not know this until another bean has been instantiated.

    The bit in bold I know doesn't work, but I'm wondering what should i put in there to reference the String property of my bean as an inner bean?

    Thanks

    Code:
    <bean id="remoteCommunicationService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
      
            <property name="serviceUrl">
                <value>networkService.serviceURL</value>
            </property>
    	<property name="serviceInterface" value="foo.bar.CommunicationService"/>
    
    </bean>
    
      <bean id="networkService" class="foo.bar.NetworkService">
             
        </bean>
    Code:
    public class NetworkService{
    private String serviceURL;
    public String getServiceURL()
    {
    return serviceURL;
    }
    
    public void setServiceURL(String s)
    {
    serviceURL = s;
    }
    
    }

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Have a look at org.springframework.beans.factory.config.PropertyP athFactoryBean. This should do what you want to achive. In the Javadoc for this class a usage example is provided.

    Regards,
    Andreas

  3. #3
    Join Date
    Apr 2007
    Posts
    6

    Default

    I will do.. thanks for your quick reply.

  4. #4
    Join Date
    Apr 2007
    Posts
    6

    Default

    ok for future reference the solution to my problem was to add:

    Code:
     <bean id="networkService.serviceURL" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
    to my applicationContext.xml.

    Thanks again.

  5. #5
    Join Date
    Oct 2004
    Location
    Fareham, England
    Posts
    313

    Default

    This might also be of interest if you are using Spring 2.0...

    http://static.springframework.org/sp...-property-path

    Cheers
    Rick

Posting Permissions

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