@Override public void init() throws ServletException { parseAndStore( getInitParameter(PARAM_CORS_ALLOWED_ORIGINS, DEFAULT_ALLOWED_ORIGINS), getInitParameter(PARAM_CORS_ALLOWED_METHODS, DEFAULT_ALLOWED_HTTP_METHODS), getInitParameter(PARAM_CORS_ALLOWED_HEADERS, DEFAULT_ALLOWED_HTTP_HEADERS), getInitParameter(PARAM_CORS_EXPOSED_HEADERS, DEFAULT_EXPOSED_HEADERS), getInitParameter(PARAM_CORS_SUPPORT_CREDENTIALS, DEFAULT_SUPPORTS_CREDENTIALS), getInitParameter(PARAM_CORS_PREFLIGHT_MAXAGE, DEFAULT_PREFLIGHT_MAXAGE), getInitParameter(PARAM_CORS_REQUEST_DECORATE, DEFAULT_DECORATE_REQUEST) ); }
@Override public void init() throws ServletException { parseAndStore( getInitParameter(PARAM_CORS_ALLOWED_ORIGINS, DEFAULT_ALLOWED_ORIGINS), getInitParameter(PARAM_CORS_ALLOWED_METHODS, DEFAULT_ALLOWED_HTTP_METHODS), getInitParameter(PARAM_CORS_ALLOWED_HEADERS, DEFAULT_ALLOWED_HTTP_HEADERS), getInitParameter(PARAM_CORS_EXPOSED_HEADERS, DEFAULT_EXPOSED_HEADERS), getInitParameter(PARAM_CORS_SUPPORT_CREDENTIALS, DEFAULT_SUPPORTS_CREDENTIALS), getInitParameter(PARAM_CORS_PREFLIGHT_MAXAGE, DEFAULT_PREFLIGHT_MAXAGE), getInitParameter(PARAM_CORS_REQUEST_DECORATE, DEFAULT_DECORATE_REQUEST) ); }
/** * This method returns the parameter's value if it exists, or defaultValue * if not. * * @param name The parameter's name * * @param defaultValue The default value to return if the parameter does * not exist * * @return The parameter's value or the default value if the parameter does * not exist */ private String getInitParameter(String name, String defaultValue) { String value = getInitParameter(name); if (value != null) { return value; } return defaultValue; }
/** * This method returns the parameter's value if it exists, or defaultValue * if not. * * @param name The parameter's name * * @param defaultValue The default value to return if the parameter does * not exist * * @return The parameter's value or the default value if the parameter does * not exist */ private String getInitParameter(String name, String defaultValue) { String value = getInitParameter(name); if (value != null) { return value; } return defaultValue; }