ArchiveDeployment dep = newDeployment(di);
dep.setRootFile(new URLLoaderAdapter(di.localUrl));
dep.setRuntimeClassLoader(null);
dep.setType(getDeploymentType());
Service service = dep.getService();
WebMetaData webMetaData = (WebMetaData)di.metaData;
if (webMetaData == null)
throw new IllegalStateException("Deployment unit does not contain web meta data");
WebservicesMetaData wsMetaData = getWebservicesMetaData(di, "WEB-INF/webservices.xml");
if (wsMetaData == null)
throw new IllegalStateException("Deployment unit does not contain webservices meta data");
// Copy the attachments
dep.addAttachment(WebservicesMetaData.class, wsMetaData);
dep.addAttachment(WebMetaData.class, webMetaData);
for (WebserviceDescriptionMetaData wsd : wsMetaData.getWebserviceDescriptions())
{
for (PortComponentMetaData pcmd : wsd.getPortComponents())
{
String servletLink = pcmd.getServletLink();
if (servletLink == null)
throw new IllegalStateException("servlet-link cannot be null");
Servlet servlet = getServletForName(webMetaData, servletLink);
String servletClass = servlet.getServletClass();
try
{
ClassLoader loader = dep.getInitialClassLoader();
Class<?> epBean = loader.loadClass(servletClass.trim());
// If this is a servlet we defer the the bean creation
if (javax.servlet.Servlet.class.isAssignableFrom(epBean))
servletClass = null;
}
catch (ClassNotFoundException ex)
{
log.warn("Cannot load servlet class: " + servletClass);
}
// Create the endpoint
Endpoint ep = newEndpoint(servletClass);
ep.setShortName(servletLink);
service.addEndpoint(ep);
}
}
return dep;
}