/** * Returns the ldap urls to get configuration information from. Currently only one ldap url is * returned, and only if the LDAPINFORMATION property or env var is populated. * * @return the list of ldap urls */ public static List<String> getLdapContexts(ApplicationInformation ai) { List<String> ldap = new ArrayList<String>(); String ldapInfo = ConfigUtils.getPropOrEnv("LDAPINFORMATION"); if (ldapInfo != null) { int indexOfAt = ldapInfo.indexOf('@'); if (indexOfAt != -1 && ai.containsKey("ldapHostPort") && ldapInfo.charAt(indexOfAt + 1) == '/') { ldapInfo = ldapInfo.substring(0, indexOfAt + 1) + ai.get("ldapHostPort") + ldapInfo.substring(indexOfAt + 1); } else if (indexOfAt != -1 && !ai.containsKey("ldapHostPort") && ldapInfo.charAt(indexOfAt + 1) == '/') { throw new RuntimeException("Ldap host/port not set"); } if (!ldapInfo.contains("application=") && ai.containsKey("applicationName")) ldapInfo = addToUrlEnd(ldapInfo, "application=" + ai.get("applicationName")); if (!ldapInfo.contains("version=") && ai.containsKey("configVersion")) ldapInfo = addToUrlEnd(ldapInfo, "version=" + ai.get("configVersion")); if (!ldapInfo.contains("scope=")) ldapInfo = addToUrlEnd(ldapInfo, "scope=" + ai.get("scope")); } if (!CommonUtils.isEmptyTrimmed(ldapInfo)) ldap.add(ldapInfo); return ldap; }
@Override protected void onRefresh() throws BeansException { super.onRefresh(); ApplicationInformation ai = getApplicationInformation(); if (ai != null) ai.onRefresh(this); }