Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.makeandbuild.validation;
 
 import java.util.List;
 import java.util.Map;
 
ValidationProxyManager implementation User: Jeremy Dyer Date: 3/6/14 Time: 4:59 PM
@SuppressWarnings({ "unused""rawtypes" })
    implements ValidationProxyManager {
    Log logger = LogFactory.getLog(getClass());
    //Cached Map of Spring validator(s)
    private final Map<Class<?>, List<Validator>> cachedValidatorsMap = new HashMap<Class<?>, List<Validator>>();
    @Override
    public Object newBeanValidatorProxy(Dao obj) {
        return BeanValidationProxy.newInstance(obj);
    }
    @Override
    public Object newSecurityValidatorProxy(Dao obj) {
        return SecurityValidationProxy.newInstance(obj);
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContextthrows BeansException {
        this. = applicationContext;
        //Gets all of the Validator beans from the application Context.
        Map<StringValidatorbeanValidators = applicationContext.getBeansOfType(Validator.class);
        String[] mnbDaoBeans = applicationContext.getBeanNamesForType(BaseDao.class);
        for (int i = 0; i < mnbDaoBeans.lengthi++) {
            //Gets the Class type that the Dao handles
            BaseDao type = (BaseDaoapplicationContext.getBean(mnbDaoBeans[i]);
            Iterator<Stringitr = beanValidators.keySet().iterator();
            List<Validatorvalidators = new ArrayList<Validator>();
            while (itr.hasNext()) {
                String key = itr.next();
                Validator validator = beanValidators.get(key);
                if (validator.supports(type.getEntityClass())) {
                    validators.add(validator);
                }
            }
            if (validators.size() > 0) {
                this..put(type.getEntityClass(), validators);
            }
        }
        .info("Validation Framework is bootstrapped and ready to roll");
    }
    @Override
    public Object newBeanValidatorProxy(Dao objString... validationTypes) {
        return BeanValidationProxy.newInstance(objvalidationTypes);
    }
New to GrepCode? Check out our FAQ X