Announcement Announcement Module
Collapse
No announcement yet.
Accessing value specified in xml config file in custom UserDetailsService Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      @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>

      Comment

      Working...
      X