Search in sources :

Example 1 with LazyValidatorFactory

use of org.jboss.as.ee.beanvalidation.LazyValidatorFactory in project wildfly by wildfly.

the class CdiValidatorFactoryService method start.

@Override
public void start(final StartContext context) throws StartException {
    final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
    try {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
        BeanManager beanManager = beanManagerInjector.getValue();
        // Get the CDI-enabled ValidatorFactory
        ValidatorFactory validatorFactory = getReference(ValidatorFactory.class, beanManager);
        // Replace the delegate of LazyValidatorFactory
        LazyValidatorFactory lazyValidatorFactory = (LazyValidatorFactory) (deploymentUnit.getAttachment(BeanValidationAttachments.VALIDATOR_FACTORY));
        lazyValidatorFactory.replaceDelegate(validatorFactory);
    } finally {
        WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl);
    }
}
Also used : LazyValidatorFactory(org.jboss.as.ee.beanvalidation.LazyValidatorFactory) ValidatorFactory(javax.validation.ValidatorFactory) LazyValidatorFactory(org.jboss.as.ee.beanvalidation.LazyValidatorFactory) BeanManager(javax.enterprise.inject.spi.BeanManager)

Aggregations

BeanManager (javax.enterprise.inject.spi.BeanManager)1 ValidatorFactory (javax.validation.ValidatorFactory)1 LazyValidatorFactory (org.jboss.as.ee.beanvalidation.LazyValidatorFactory)1