Announcement Announcement Module
Collapse
No announcement yet.
Configuring Environment specific LDAP context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configuring Environment specific LDAP context

    I am using spring-LDAP 1.1.1. The context configuration is as below.

    <bean id="contextSource" class="org.springframework.ldap.support.LdapContex tSource">
    <property name="url" value="ldap://<hostname>:389" />
    <property name="base" value="<base>" />
    <property name="userName" value="<user ID>" />
    <property name="password" value="<password>" />
    </bean>
    <bean id="ldapTemplate" class="org.springframework.ldap.LdapTemplate">
    <constructor-arg ref="contextSource" />
    </bean>

    In my code, I use the ldapTemplate to interact with LDAP.

    When the code is moved to a different environment, the properties change. One way I thought to handle it is - to define the beans something like contextSource_DEV, contextSource_STAGING, contextSource_PROD and use them accordingly depending on the environment specific system property.

    Is there any other better way of doing it - doing it just with the configuration, without having to change the code. Let me know if there is any documentation for the same.

    Thanks
    santosh

  • #2
    This should be managed using configuration properties. In short you can refer from your bean definition file to an external .properties file and use these properties in your context file using the '{}' notation. You will then use different .properties files in the different environments.

    The above is documented in the Spring Framework main reference documentation. Look for PropertyPlaceholderConfigurer.

    Comment


    • #3
      It works. Thanks.

      Comment

      Working...
      X