Lazy initialization of ldap-server
Hi everyone,
I'm building an application that allow the user to choose between LDAP or DB when deploying it into the server.
He can define a property value ("ldap" or "db") that will be used by a PropertyPlaceholderConfigurer to choose between two aliases :
Code:
<http use-expressions="true" authentication-manager-ref="${authProvider}AuthManager">
...
</http>
<authentication-manager alias="ldapAuthManager">
<ldap-authentication-provider user-dn-pattern="${ldap.userDn}" >
</ldap-authentication-provider>
</authentication-manager>
<authentication-manager alias="dbAuthManager">
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"/>
</authentication-provider>
</authentication-manager>
The (big) problem is : I must declare <ldap-server /> and if the user isn't using one, I get an error because URL is not specified (the user don't specify the "ldap.serverUrl" property:
Code:
<ldap-server url="${ldap.serverUrl}" />
So, I've got an obvious solution : using the <bean> syntax to use lazy-init="true" to avoid the ldap-server bean to be created on application start. But I really like this syntax :-)
Do you guys have a better solution ?
BR,