use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class TracingDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext deploymentPhaseContext) throws DeploymentUnitProcessingException {
ROOT_LOGGER.processingDeployment();
final DeploymentUnit deploymentUnit = deploymentPhaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
return;
}
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
try {
final WeldCapability weldCapability = support.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
if (!weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
// SmallRye Jakarta RESTful Web Services require Jakarta Contexts and Dependency Injection. Without Jakarta Contexts and Dependency Injection, there's no integration needed
ROOT_LOGGER.noCdiDeployment();
return;
}
} catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
// We should not be here since the subsystem depends on weld capability. Just in case ...
throw new DeploymentUnitProcessingException(ROOT_LOGGER.deploymentRequiresCapability(deploymentPhaseContext.getDeploymentUnit().getName(), WELD_CAPABILITY_NAME));
}
injectTracer(deploymentPhaseContext, support);
}
use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class JaxrsCdiIntegrationProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
if (!JaxrsDeploymentMarker.isJaxrsDeployment(deploymentUnit)) {
return;
}
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
return;
}
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
final JBossWebMetaData webdata = warMetaData.getMergedJBossWebMetaData();
try {
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (support.hasCapability(WELD_CAPABILITY_NAME)) {
final WeldCapability api = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get();
if (api.isWeldDeployment(deploymentUnit)) {
// don't set this param if Jakarta Contexts and Dependency Injection is not in classpath
module.getClassLoader().loadClass(CDI_INJECTOR_FACTORY_CLASS);
JAXRS_LOGGER.debug("Found Jakarta Contexts and Dependency Injection, adding injector factory class");
setContextParameter(webdata, "resteasy.injector.factory", CDI_INJECTOR_FACTORY_CLASS);
}
}
} catch (ClassNotFoundException ignored) {
}
}
use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class JaxrsDependencyProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
boolean deploymentBundlesClientBuilder = isClientBuilderInDeployment(deploymentUnit);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
addDependency(moduleSpecification, moduleLoader, JAXRS_API, false, false);
addDependency(moduleSpecification, moduleLoader, JAXB_API, false, false);
addDependency(moduleSpecification, moduleLoader, JSON_API, false, false);
// we need to add these from all deployments, as they could be using the Jakarta RESTful Web Services client
addDependency(moduleSpecification, moduleLoader, RESTEASY_ATOM, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_VALIDATOR, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_CLIENT, true, deploymentBundlesClientBuilder);
addDependency(moduleSpecification, moduleLoader, RESTEASY_CLIENT_API, true, deploymentBundlesClientBuilder);
addDependency(moduleSpecification, moduleLoader, RESTEASY_CORE, true, deploymentBundlesClientBuilder);
addDependency(moduleSpecification, moduleLoader, RESTEASY_CORE_SPI, true, deploymentBundlesClientBuilder);
addDependency(moduleSpecification, moduleLoader, RESTEASY_CLIENT_MICROPROFILE, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_JAXB, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_JACKSON2, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_JSON_P_PROVIDER, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_JSON_B_PROVIDER, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_JSAPI, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_MULTIPART, true, false);
addDependency(moduleSpecification, moduleLoader, RESTEASY_CRYPTO, true, false);
addDependency(moduleSpecification, moduleLoader, JACKSON_DATATYPE_JDK8, true, false);
addDependency(moduleSpecification, moduleLoader, JACKSON_DATATYPE_JSR310, true, false);
addDependency(moduleSpecification, moduleLoader, MP_REST_CLIENT, true, false);
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
if (support.hasCapability(WELD_CAPABILITY_NAME)) {
final WeldCapability api = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get();
if (api.isPartOfWeldDeployment(deploymentUnit)) {
addDependency(moduleSpecification, moduleLoader, RESTEASY_CDI, true, false);
}
}
}
use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class DeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
final WeldCapability weldCapability;
try {
weldCapability = support.getCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class);
} catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
// We should not be here since the subsystem depends on weld capability. Just in case ...
throw MicroProfileHealthLogger.LOGGER.deploymentRequiresCapability(deploymentUnit.getName(), WELD_CAPABILITY_NAME);
}
if (weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
final MicroProfileHealthReporter healthReporter = (MicroProfileHealthReporter) phaseContext.getServiceRegistry().getService(MicroProfileHealthSubsystemDefinition.HEALTH_REPORTER_SERVICE).getValue();
weldCapability.registerExtensionInstance(new CDIExtension(healthReporter, module), deploymentUnit);
}
}
use of org.jboss.as.weld.WeldCapability in project wildfly by wildfly.
the class OpenTelemetryDependencyProcessor method addDependencies.
private void addDependencies(DeploymentUnit deploymentUnit) {
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
try {
CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
WeldCapability weldCapability = support.getCapabilityRuntimeAPI(Capabilities.WELD_CAPABILITY_NAME, WeldCapability.class);
if (weldCapability.isPartOfWeldDeployment(deploymentUnit)) {
weldCapability.registerExtensionInstance(new OpenTelemetryCdiExtension(), deploymentUnit);
// Export the -api module only if CDI is available
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, API_MODULE, false, true, true, false));
}
// Export all other modules regardless of CDI availability
for (String module : EXPORTED_MODULES) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, module, false, true, true, false));
}
} catch (CapabilityServiceSupport.NoSuchCapabilityException e) {
throw new IllegalStateException();
}
}
Aggregations