Search in sources :

Example 1 with CdiValidatorFactoryService

use of org.jboss.as.weld.CdiValidatorFactoryService in project wildfly by wildfly.

the class CdiBeanValidationFactoryProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final DeploymentUnit topLevelDeployment = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
    final ServiceName weldStartService = topLevelDeployment.getServiceName().append(ServiceNames.WELD_START_SERVICE_NAME);
    if (!WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
        return;
    }
    if (!deploymentUnit.hasAttachment(BeanValidationAttachments.VALIDATOR_FACTORY)) {
        return;
    }
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    final ServiceName serviceName = deploymentUnit.getServiceName().append(CdiValidatorFactoryService.SERVICE_NAME);
    final CdiValidatorFactoryService cdiValidatorFactoryService = new CdiValidatorFactoryService(deploymentUnit);
    serviceTarget.addService(serviceName, cdiValidatorFactoryService).addDependency(ServiceNames.beanManagerServiceName(deploymentUnit), new CastingInjector<BeanManager>(cdiValidatorFactoryService.getBeanManagerInjector(), BeanManager.class)).addDependency(weldStartService).install();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) CdiValidatorFactoryService(org.jboss.as.weld.CdiValidatorFactoryService) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) BeanManager(javax.enterprise.inject.spi.BeanManager)

Aggregations

BeanManager (javax.enterprise.inject.spi.BeanManager)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 CdiValidatorFactoryService (org.jboss.as.weld.CdiValidatorFactoryService)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1