Results 1 to 3 of 3

Thread: Accessing value specified in xml config file in custom UserDetailsService

  1. #1
    Join Date
    Mar 2012
    Posts
    6

    Default Accessing value specified in xml config file in custom UserDetailsService

    Hello,

    I am planning to implement a custom UserDetailsService for which I would like to specify configuration
    values in the xml configuration file. Would something like this make sense where the property named
    prop1 is meaningful for my custom implementation and if so, how would I then
    access the property in my UserDetailsService implemenation? Is there a class with a
    getProperty() or similar available in Spring that I can use?

    <beans:bean id="myUserDetailsService"
    class="org.mycompany.CustomUserDetailsService">
    <beansroperty name="prop1" value="value1"/>
    </beans:bean>

    I am a newbie to this with limited Java experience under tight schedule so any help
    is greatly appreciated.

    Thanks.

  2. #2
    Join Date
    Mar 2012
    Posts
    13

    Default

    If i have understood your question correctly, below is the response to that:-

    If you specify the above in the application context xml, spring will create the CustomUserDetailsService class and set the property (instance variable in CustomUserDetailsService) to value1. The value1 should be another bean which should also be specified as a bean declaration in the xml.

  3. #3
    Join Date
    Dec 2010
    Location
    Singapore
    Posts
    287

    Default

    @srivenkat, if you do
    Code:
    <beansroperty name="prop1" value="value1"/>
    then you should have a string variable called prop1 in your CustomUserDetailsService

    @tomcyjohn, value1 should be another bean if the declaration was like following, note the highlighted part

    Code:
    <beans:bean id="myUserDetailsService"
    class="org.mycompany.CustomUserDetailsService">
    <beansroperty name="prop1" ref="value1"/>
    </beans:bean>
    Amila Domingo

Posting Permissions

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