use of org.jboss.as.server.deployment.module.ModuleDependency in project wildfly by wildfly.
the class UndertowDependencyProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
// add the api classes for every deployment
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, SERVLET_API, false, false, true, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JSP_API, false, false, true, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, WEBSOCKET_API, false, false, true, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JSTL, false, false, false, false));
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
// Skip non web deployments
return;
}
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_CORE, false, false, true, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_SERVLET, false, false, true, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_JSP, false, false, true, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, UNDERTOW_WEBSOCKET, false, false, true, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, CLUSTERING_API, true, false, false, false));
}
use of org.jboss.as.server.deployment.module.ModuleDependency in project keycloak by keycloak.
the class KeycloakDependencyProcessor method addCommonModules.
private void addCommonModules(ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
// ModuleDependency(ModuleLoader moduleLoader, ModuleIdentifier identifier, boolean optional, boolean export, boolean importServices, boolean userSpecified)
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_JBOSS_CORE_ADAPTER, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE_ADAPTER, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_CORE, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_COMMON, false, false, false, false));
}
use of org.jboss.as.server.deployment.module.ModuleDependency in project keycloak by keycloak.
the class KeycloakDependencyProcessorWildFly method addPlatformSpecificModules.
@Override
protected void addPlatformSpecificModules(DeploymentPhaseContext phaseContext, ModuleSpecification moduleSpecification, ModuleLoader moduleLoader) {
if (isElytronEnabled(phaseContext)) {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_ELYTRON_ADAPTER, true, false, false, false));
} else {
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_WILDFLY_ADAPTER, false, false, true, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, KEYCLOAK_UNDERTOW_ADAPTER, false, false, false, false));
}
}
use of org.jboss.as.server.deployment.module.ModuleDependency in project wildfly by wildfly.
the class IIOPDependencyProcessor method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, CORBA_ID, false, false, false, false));
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, JAVAX_RMI_API_ID, false, false, false, false));
// we need to add iiop, as the orb is initialized from the context class loader of the deployment
moduleSpecification.addSystemDependency(new ModuleDependency(moduleLoader, IIOP_OPENJDK_ID, false, false, false, false));
}
use of org.jboss.as.server.deployment.module.ModuleDependency in project wildfly by wildfly.
the class JaxrsIntegrationProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!JaxrsDeploymentMarker.isJaxrsDeployment(deploymentUnit)) {
return;
}
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
return;
}
final DeploymentUnit parent = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
final JBossWebMetaData webdata = warMetaData.getMergedJBossWebMetaData();
setConfigParameters(phaseContext, webdata);
final ResteasyDeploymentData resteasy = deploymentUnit.getAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA);
if (resteasy == null)
return;
deploymentUnit.getDeploymentSubsystemModel(JaxrsExtension.SUBSYSTEM_NAME);
final List<ParamValueMetaData> params = webdata.getContextParams();
boolean entityExpandEnabled = false;
if (params != null) {
Iterator<ParamValueMetaData> it = params.iterator();
while (it.hasNext()) {
final ParamValueMetaData param = it.next();
if (param.getParamName().equals(ResteasyContextParameters.RESTEASY_EXPAND_ENTITY_REFERENCES)) {
entityExpandEnabled = true;
}
}
}
// don't expand entity references by default
if (!entityExpandEnabled) {
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_EXPAND_ENTITY_REFERENCES, "false");
}
final Map<ModuleIdentifier, ResteasyDeploymentData> attachmentMap = parent.getAttachment(JaxrsAttachments.ADDITIONAL_RESTEASY_DEPLOYMENT_DATA);
final List<ResteasyDeploymentData> additionalData = new ArrayList<ResteasyDeploymentData>();
final ModuleSpecification moduleSpec = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
if (moduleSpec != null && attachmentMap != null) {
final Set<ModuleIdentifier> identifiers = new HashSet<ModuleIdentifier>();
for (ModuleDependency dep : moduleSpec.getAllDependencies()) {
// make sure we don't double up
if (!identifiers.contains(dep.getIdentifier())) {
identifiers.add(dep.getIdentifier());
if (attachmentMap.containsKey(dep.getIdentifier())) {
additionalData.add(attachmentMap.get(dep.getIdentifier()));
}
}
}
resteasy.merge(additionalData);
}
if (!resteasy.getScannedResourceClasses().isEmpty()) {
StringBuilder buf = null;
for (String resource : resteasy.getScannedResourceClasses()) {
if (buf == null) {
buf = new StringBuilder();
buf.append(resource);
} else {
buf.append(",").append(resource);
}
}
String resources = buf.toString();
JAXRS_LOGGER.debugf("Adding Jakarta RESTful Web Services resource classes: %s", resources);
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_SCANNED_RESOURCES, resources);
}
if (!resteasy.getScannedProviderClasses().isEmpty()) {
StringBuilder buf = null;
for (String provider : resteasy.getScannedProviderClasses()) {
if (buf == null) {
buf = new StringBuilder();
buf.append(provider);
} else {
buf.append(",").append(provider);
}
}
String providers = buf.toString();
JAXRS_LOGGER.debugf("Adding Jakarta RESTful Web Services provider classes: %s", providers);
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_SCANNED_PROVIDERS, providers);
}
if (!resteasy.getScannedJndiComponentResources().isEmpty()) {
StringBuilder buf = null;
for (String resource : resteasy.getScannedJndiComponentResources()) {
if (buf == null) {
buf = new StringBuilder();
buf.append(resource);
} else {
buf.append(",").append(resource);
}
}
String providers = buf.toString();
JAXRS_LOGGER.debugf("Adding Jakarta RESTful Web Services jndi component resource classes: %s", providers);
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_SCANNED_JNDI_RESOURCES, providers);
}
if (!resteasy.isUnwrappedExceptionsParameterSet()) {
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_UNWRAPPED_EXCEPTIONS, "javax.ejb.EJBException");
}
if (findContextParam(webdata, ResteasyContextParameters.RESTEASY_PREFER_JACKSON_OVER_JSONB) == null) {
final String prop = WildFlySecurityManager.getPropertyPrivileged(ResteasyContextParameters.RESTEASY_PREFER_JACKSON_OVER_JSONB, null);
if (prop != null) {
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_PREFER_JACKSON_OVER_JSONB, prop);
} else {
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_PREFER_JACKSON_OVER_JSONB, Boolean.toString(hasJacksonAnnotations(deploymentUnit)));
}
}
boolean managementAdded = false;
if (!resteasy.getScannedApplicationClasses().isEmpty() || resteasy.hasBootClasses() || resteasy.isDispatcherCreated()) {
addManagement(deploymentUnit, resteasy);
managementAdded = true;
}
if (resteasy.hasBootClasses() || resteasy.isDispatcherCreated())
return;
// ignore any non-annotated Application class that doesn't have a servlet mapping
Set<Class<? extends Application>> applicationClassSet = new HashSet<>();
for (Class<? extends Application> clazz : resteasy.getScannedApplicationClasses()) {
if (clazz.isAnnotationPresent(ApplicationPath.class) || servletMappingsExist(webdata, clazz.getName())) {
applicationClassSet.add(clazz);
}
}
// add default servlet
if (applicationClassSet.isEmpty()) {
JBossServletMetaData servlet = new JBossServletMetaData();
servlet.setName(JAX_RS_SERVLET_NAME);
servlet.setServletClass(HttpServlet30Dispatcher.class.getName());
servlet.setAsyncSupported(true);
addServlet(webdata, servlet);
setServletMappingPrefix(webdata, JAX_RS_SERVLET_NAME, servlet);
} else {
for (Class<? extends Application> applicationClass : applicationClassSet) {
String servletName = null;
servletName = applicationClass.getName();
JBossServletMetaData servlet = new JBossServletMetaData();
// must load on startup for services like JSAPI to work
servlet.setLoadOnStartup("" + 0);
servlet.setName(servletName);
servlet.setServletClass(HttpServlet30Dispatcher.class.getName());
servlet.setAsyncSupported(true);
setServletInitParam(servlet, SERVLET_INIT_PARAM, applicationClass.getName());
addServlet(webdata, servlet);
if (!servletMappingsExist(webdata, servletName)) {
try {
// no mappings, add our own
List<String> patterns = new ArrayList<String>();
// for some reason the spec requires this to be decoded
String pathValue = URLDecoder.decode(applicationClass.getAnnotation(ApplicationPath.class).value().trim(), "UTF-8");
if (!pathValue.startsWith("/")) {
pathValue = "/" + pathValue;
}
String prefix = pathValue;
if (pathValue.endsWith("/")) {
pathValue += "*";
} else {
pathValue += "/*";
}
patterns.add(pathValue);
setServletInitParam(servlet, "resteasy.servlet.mapping.prefix", prefix);
ServletMappingMetaData mapping = new ServletMappingMetaData();
mapping.setServletName(servletName);
mapping.setUrlPatterns(patterns);
if (webdata.getServletMappings() == null) {
webdata.setServletMappings(new ArrayList<ServletMappingMetaData>());
}
webdata.getServletMappings().add(mapping);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
} else {
setServletMappingPrefix(webdata, servletName, servlet);
}
}
}
if (!managementAdded && webdata.getServletMappings() != null) {
for (ServletMappingMetaData servletMapMeta : webdata.getServletMappings()) {
if (JAX_RS_SERVLET_NAME.equals(servletMapMeta.getServletName())) {
addManagement(deploymentUnit, resteasy);
break;
}
}
}
// suppress warning for EAR deployments, as we can't easily tell here the app is properly declared
if (deploymentUnit.getParent() == null && (webdata.getServletMappings() == null || webdata.getServletMappings().isEmpty())) {
JAXRS_LOGGER.noServletDeclaration(deploymentUnit.getName());
}
}
Aggregations