//because it is not needed
final List<ParamValueMetaData> params = webdata.getContextParams();
if(params != null) {
Iterator<ParamValueMetaData> it = params.iterator();
while(it.hasNext()) {
final ParamValueMetaData param = it.next();
if(param.getParamName().equals("resteasy.scan")) {
it.remove();
JAXRS_LOGGER.resteasyScanWarning();
}
}
}
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) {
for (ModuleDependency dep : moduleSpec.getAllDependencies()) {
if (attachmentMap.containsKey(dep.getIdentifier())) {
additionalData.add(attachmentMap.get(dep.getIdentifier()));
}
}
resteasy.merge(additionalData);
}
if (!resteasy.getScannedResourceClasses().isEmpty()) {
StringBuffer buf = null;
for (String resource : resteasy.getScannedResourceClasses()) {
if (buf == null) {
buf = new StringBuffer();
buf.append(resource);
} else {
buf.append(",").append(resource);
}
}
String resources = buf.toString();
JAXRS_LOGGER.debugf("Adding JAX-RS resource classes: %s", resources);
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_SCANNED_RESOURCES, resources);
}
if (!resteasy.getScannedProviderClasses().isEmpty()) {
StringBuffer buf = null;
for (String provider : resteasy.getScannedProviderClasses()) {
if (buf == null) {
buf = new StringBuffer();
buf.append(provider);
} else {
buf.append(",").append(provider);
}
}
String providers = buf.toString();
JAXRS_LOGGER.debugf("Adding JAX-RS provider classes: %s", providers);
setContextParameter(webdata, ResteasyContextParameters.RESTEASY_SCANNED_PROVIDERS, providers);
}
if (!resteasy.getScannedJndiComponentResources().isEmpty()) {
StringBuffer buf = null;
for (String resource : resteasy.getScannedJndiComponentResources()) {
if (buf == null) {
buf = new StringBuffer();
buf.append(resource);
} else {
buf.append(",").append(resource);
}
}
String providers = buf.toString();
JAXRS_LOGGER.debugf("Adding JAX-RS 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 (resteasy.hasBootClasses() || resteasy.isDispatcherCreated())
return;
//if there are no JAX-RS classes in the app just return
if (resteasy.getScannedApplicationClass() == null
&& resteasy.getScannedJndiComponentResources().isEmpty()
&& resteasy.getScannedProviderClasses().isEmpty()
&& resteasy.getScannedResourceClasses().isEmpty()) return;
boolean useScannedClass = false;
String servletName;
if (resteasy.getScannedApplicationClass() == null) {
//if there is no scanned application we must add a servlet with a name of
//javax.ws.rs.core.Application
JBossServletMetaData servlet = new JBossServletMetaData();
servlet.setName(JAX_RS_SERVLET_NAME);
servlet.setServletClass(HttpServlet30Dispatcher.class.getName());
servlet.setAsyncSupported(true);
addServlet(webdata, servlet);
servletName = JAX_RS_SERVLET_NAME;
} else {
//now there are two options.
//if there is already a servlet defined with an init param
//we don't do anything.
//Otherwise we install our filter
//JAVA-RS seems somewhat confused about the difference between a context param
//and an init param.
ParamValueMetaData param = findInitParam(webdata, SERVLET_INIT_PARAM);
if (param != null) {
//we need to promote the init param to a context param
servletName = param.getParamValue();
setContextParameter(webdata, "javax.ws.rs.Application", servletName);
} else {
ParamValueMetaData contextParam = findContextParam(webdata, "javax.ws.rs.Application");
if (contextParam == null) {
setContextParameter(webdata, "javax.ws.rs.Application", resteasy.getScannedApplicationClass().getName());
useScannedClass = true;
servletName = resteasy.getScannedApplicationClass().getName();
} else {
servletName = contextParam.getParamValue();
}
}
}
boolean mappingSet = false;