private WebEnvironment webEnvironmentFromServiceLoader() {

        WebEnvironment webEnvironment = null;
        // try to load WebEnvironment as a service
        Iterator<WebEnvironment> iterator = doLoadWebEnvironmentsFromServiceLoader();

        // Use the first one
        if (iterator.hasNext()) {
            webEnvironment = iterator.next();
        }
        // if there are others, throw an error
        if (iterator.hasNext()) {
            List<String> allWebEnvironments = new ArrayList<String>();
            allWebEnvironments.add(webEnvironment.getClass().getName());
            while (iterator.hasNext()) {
                allWebEnvironments.add(iterator.next().getClass().getName());
            }
            throw new ConfigurationException("ServiceLoader for class [" + WebEnvironment.class + "] returned more then one "
                    + "result.  ServiceLoader must return zero or exactly one result for this class. Select one using the "
                    + "servlet init parameter '" + ENVIRONMENT_CLASS_PARAM + "'. Found: " + allWebEnvironments);
        }
        return webEnvironment;
    }
Return the WebEnvironment implementation class to use, either the default
{@link IniWebEnvironment} or a custom class if specified.

@param servletContext current servlet context
@return the WebEnvironment implementation class to use
@see #ENVIRONMENT_CLASS_PARAM
@see IniWebEnvironment
@see #determineWebEnvironment(ServletContext)
@see #getDefaultWebEnvironmentClass(ServletContext)
@deprecated This method is not longer used by Shiro, and will be removed in future versions,
use {@link #determineWebEnvironment(ServletContext)} or {@link #determineWebEnvironment(ServletContext)}
web/src/main/java/org/apache/shiro/web/env/EnvironmentLoader.java