synchronized (createEnvironmentLock) {
// create a default environment if needed
if (defaultParams.getEnvironment() == null) {
Application application = context.getApplication();
String environmentName = getAppParameter(application, LibraryRequestParams.PARAM_ENVIRONMENT, LibraryRequestParams.DEFAULT_ENVIRONMENT);
SBTEnvironment environment = (SBTEnvironment) context.getBean(environmentName);
if (environment == null) {
ServletConfig config = getServletConfig();
String defaultEndpoints = getAppParameter(application, LibraryRequestParams.PARAM_ENDPOINTS, LibraryRequestParams.DEFAULT_ENDPOINTS);
String endpoints = getInitParameter(config, LibraryRequestParams.PARAM_ENDPOINTS, defaultEndpoints);
String defaultClientProps = getAppParameter(application, LibraryRequestParams.PARAM_CLIENT_PROPERTIES, LibraryRequestParams.DEFAULT_CLIENT_PROPERTIES);
String clientProps = getInitParameter(config, LibraryRequestParams.PARAM_CLIENT_PROPERTIES, defaultClientProps);
environmentName = getInitParameter(config, LibraryRequestParams.PARAM_ENVIRONMENT, LibraryRequestParams.DEFAULT_ENVIRONMENT);
environment = new SBTEnvironment();
environment.setName(environmentName);
environment.setEndpoints(endpoints);
environment.setProperties(clientProps);
}
defaultParams.setEnvironment(environment);
}
}