public static ValidatorResources getValidatorResources()
{
final FacesContext context = FacesContext.getCurrentInstance();
final ExternalContext external = context.getExternalContext();
final Map applicationMap = external.getApplicationMap();
ValidatorResources validatorResources = (ValidatorResources)applicationMap.get(VALIDATOR_RESOURCES_KEY);
if (validatorResources == null)
{
final String rulesResource = RULES_LOCATION;
final String validationResource = "/WEB-INF/validation.xml";
final InputStream rulesInput = external.getResourceAsStream(rulesResource);
if (rulesInput == null)
{
throw new JSFValidatorException("Could not find rules file '" + rulesResource + "'");
}
final InputStream validationInput = external.getResourceAsStream(validationResource);
if (validationInput != null)
{
final InputStream[] inputs = new InputStream[] {rulesInput, validationInput};
try
{
validatorResources = new ValidatorResources(inputs);
applicationMap.put(
VALIDATOR_RESOURCES_KEY,
validatorResources);
}
catch (final Throwable throwable)