it was my first question about the openejb jndi tree, i don't know where this context is accessible.
ill verify but i think we doesn't need the mapping file but it will be loaded before the entitymanager factory (of course ;)) so in your opinion i should load in the configurationfactory the validation.xml, put it in Info objects then copy it in modules to finally bind validatorfactory/validator in module contexts? i find it a bit complicated for a simple need, no? Romain 2011/4/1 David Blevins <[email protected]> > > On Apr 1, 2011, at 1:13 PM, Romain Manni-Bucau wrote: > > > 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(); > > } > > One quick thought would be to maybe put the ValidatorFactory instance in > the ModuleContext object. Should eliminate the need for any mapping/caching > which often ends up leaky. We might even (someday) want to redo some of the > EntityManagerFactory stuff that way -- we didn't have an AppContext or > ModuleContext when that code was written. > > On the URL note. The Info object tree passed from the ConfigurationFactory > to the Assembler doesn't allow URL or Class or any other thing tied to a > classloader. If we were to create a set of Info objects to represent the > validation.xml, how complex would that tree be? For the beans.xml and > persistence.xml it was pretty simple. > > The validation configuration file looks really simple. The mapping file is > complex. I'm not sure if we need both or just one of them like in JPA (we > handle persistence.xml and the provider handles the mapping files) > > -David > >
