use of org.jboss.as.web.common.WarMetaData in project wildfly by wildfly.
the class JSFDependencyProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final DeploymentUnit tl = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
// Set default when no default version has been set on the war file
String jsfVersion = JsfVersionMarker.getVersion(tl).equals(JsfVersionMarker.NONE) ? JSFModuleIdFactory.getInstance().getDefaultSlot() : JsfVersionMarker.getVersion(tl);
String defaultJsfVersion = JSFModuleIdFactory.getInstance().getDefaultSlot();
if (JsfVersionMarker.isJsfDisabled(deploymentUnit)) {
if (jsfVersion.equals(defaultJsfVersion) && !moduleIdFactory.isValidJSFSlot(jsfVersion)) {
throw JSFLogger.ROOT_LOGGER.invalidDefaultJSFImpl(defaultJsfVersion);
}
addJSFAPI(JsfVersionMarker.JSF_2_0, moduleSpecification, moduleLoader);
return;
}
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit) && !DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
return;
}
if (jsfVersion.equals(JsfVersionMarker.WAR_BUNDLES_JSF_IMPL)) {
// if Jakarta Server Faces is provided by the application we leave it alone
return;
}
if (!moduleIdFactory.isValidJSFSlot(jsfVersion)) {
JSFLogger.ROOT_LOGGER.unknownJSFVersion(jsfVersion, defaultJsfVersion);
jsfVersion = defaultJsfVersion;
}
if (jsfVersion.equals(defaultJsfVersion) && !moduleIdFactory.isValidJSFSlot(jsfVersion)) {
throw JSFLogger.ROOT_LOGGER.invalidDefaultJSFImpl(defaultJsfVersion);
}
addJSFAPI(jsfVersion, moduleSpecification, moduleLoader);
addJSFImpl(jsfVersion, moduleSpecification, moduleLoader);
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JSF_SUBSYSTEM, false, false, true, false));
addJSFInjection(jsfVersion, moduleSpecification, moduleLoader);
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData != null) {
addCDIFlag(warMetaData, deploymentUnit);
}
}
use of org.jboss.as.web.common.WarMetaData 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.web.common.WarMetaData in project wildfly by wildfly.
the class JaxrsScanningProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!JaxrsDeploymentMarker.isJaxrsDeployment(deploymentUnit)) {
return;
}
final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
final Map<ModuleIdentifier, ResteasyDeploymentData> deploymentData;
if (deploymentUnit.getParent() == null) {
deploymentData = Collections.synchronizedMap(new HashMap<ModuleIdentifier, ResteasyDeploymentData>());
deploymentUnit.putAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA, deploymentData);
} else {
deploymentData = parent.getAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA);
}
final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER);
ResteasyDeploymentData resteasyDeploymentData = new ResteasyDeploymentData();
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
try {
if (warMetaData == null) {
resteasyDeploymentData.setScanAll(true);
scan(deploymentUnit, module.getClassLoader(), resteasyDeploymentData);
deploymentData.put(moduleIdentifier, resteasyDeploymentData);
} else {
scanWebDeployment(deploymentUnit, warMetaData.getMergedJBossWebMetaData(), module.getClassLoader(), resteasyDeploymentData);
scan(deploymentUnit, module.getClassLoader(), resteasyDeploymentData);
// must check context param for Application subclass declaration
if (resteasyDeploymentData.getScannedResourceClasses().isEmpty() && !resteasyDeploymentData.isDispatcherCreated() && hasBootClasses(warMetaData.getMergedJBossWebMetaData())) {
checkOtherParams(deploymentUnit, warMetaData.getMergedJBossWebMetaData(), module.getClassLoader(), resteasyDeploymentData);
}
}
deploymentUnit.putAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA, resteasyDeploymentData);
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException(e);
}
}
use of org.jboss.as.web.common.WarMetaData in project wildfly by wildfly.
the class JaxrsSpringProcessor method deploy.
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (deploymentUnit.getParent() != null) {
return;
}
final List<DeploymentUnit> deploymentUnits = new ArrayList<DeploymentUnit>();
deploymentUnits.add(deploymentUnit);
deploymentUnits.addAll(deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS));
boolean found = false;
for (DeploymentUnit unit : deploymentUnits) {
WarMetaData warMetaData = unit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null) {
continue;
}
JBossWebMetaData md = warMetaData.getMergedJBossWebMetaData();
if (md == null) {
continue;
}
if (md.getContextParams() != null) {
boolean skip = false;
for (ParamValueMetaData prop : md.getContextParams()) {
if (prop.getParamName().equals(ENABLE_PROPERTY)) {
boolean explicitEnable = Boolean.parseBoolean(prop.getParamValue());
if (explicitEnable) {
found = true;
} else {
skip = true;
}
break;
} else if (prop.getParamName().equals(DISABLE_PROPERTY) && "true".equals(prop.getParamValue())) {
skip = true;
JaxrsLogger.JAXRS_LOGGER.disablePropertyDeprecated();
break;
}
}
if (skip) {
continue;
}
}
if (md.getListeners() != null) {
for (ListenerMetaData listener : md.getListeners()) {
if (SPRING_LISTENER.equals(listener.getListenerClass())) {
found = true;
break;
}
}
}
if (md.getServlets() != null) {
for (JBossServletMetaData servlet : md.getServlets()) {
if (SPRING_SERVLET.equals(servlet.getServletClass())) {
found = true;
break;
}
}
}
if (found) {
try {
// actual close is done by the MSC service above
MountHandle mh = new MountHandle(null);
ResourceRoot resourceRoot = new ResourceRoot(getResteasySpringVirtualFile(), mh);
ModuleRootMarker.mark(resourceRoot);
deploymentUnit.addToAttachmentList(Attachments.RESOURCE_ROOTS, resourceRoot);
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e);
}
return;
}
}
}
use of org.jboss.as.web.common.WarMetaData in project wildfly by wildfly.
the class JwtActivationProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null) {
return;
}
JBossWebMetaData mergedMetaData = warMetaData.getMergedJBossWebMetaData();
LoginConfigMetaData loginConfig = mergedMetaData != null ? mergedMetaData.getLoginConfig() : null;
if (loginConfig != null && !JWT_AUTH_METHOD.equals(loginConfig.getAuthMethod())) {
// An auth-method has been defined, this is not MP-JWT
return;
}
if (loginConfig == null) {
final CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
List<AnnotationInstance> annotations = index.getAnnotations(LOGIN_CONFIG_DOT_NAME);
for (AnnotationInstance annotation : annotations) {
// First we must be sure the annotation is on an Application class.
AnnotationTarget target = annotation.target();
if (target.kind() == Kind.CLASS && extendsApplication(target.asClass(), index)) {
loginConfig = new LoginConfigMetaData();
AnnotationValue authMethodValue = annotation.value(AUTH_METHOD);
if (authMethodValue == null) {
throw ROOT_LOGGER.noAuthMethodSpecified();
}
loginConfig.setAuthMethod(authMethodValue.asString());
AnnotationValue realmNameValue = annotation.value(REALM_NAME);
if (realmNameValue != null) {
loginConfig.setRealmName(realmNameValue.asString());
}
mergedMetaData.setLoginConfig(loginConfig);
break;
}
ROOT_LOGGER.loginConfigInvalidTarget(target.toString());
}
}
if (loginConfig != null && JWT_AUTH_METHOD.equals(loginConfig.getAuthMethod())) {
ROOT_LOGGER.tracef("Activating JWT for deployment %s.", deploymentUnit.getName());
JwtDeploymentMarker.mark(deploymentUnit);
VirtualDomainMarkerUtility.virtualDomainRequired(deploymentUnit);
}
}
Aggregations