Hi all,

to implement bean validation, is it a good idea to do like it (i tried to
write something simple but understandable, say me if i failed ;)):

<[email protected]>1) create a builder ValidatorBuilder class
    i) method createValidatorFactory(ModuleType type {WEBAPP, OTHER}, URL
validationUrl {null or not}) returning a ValidatorFactory
2) in Assembler::createApplication()
    i) bind a dynamic proxy in "VALIDATOR_FACTORY_NAMING_CONTEXT +
ValidatorFactory" (same idea for Validator) -
containerSystem.getJNDIContext().bind("...", vfProxy)
   ii) IMHO it should be done before the persistence building (to put it as
parameter in the entity manager factory creation) but will it not break
something about the weaving (i saw some comments about it)?
3) the proxy/proxies
    i) manage a map/cache of ValidatorFactory and Validator (is it necessary
for validator?). The key will be the module (maybe the path? it should only
be unique)
    ii) invoke(...) {
            type = getModuleTypeFromClassLoader();
            if (!validatorFactoryExistsForModule(currentModule())) {
                vf = ValidatorBuilder::createValidatorFactory(type);
            }
            return whatWeWantByReflection();
        }


Romain

Reply via email to