ArchiveDeployment dep = newDeployment(unit);
dep.setRootFile(new VirtualFileAdaptor(((VFSDeploymentUnit)unit).getRoot()));
dep.setRuntimeClassLoader(unit.getClassLoader());
dep.setType(getDeploymentType());
Service service = dep.getService();
JBossMetaData jbmd = unit.getAttachment(JBossMetaData.class);
if (jbmd == null)
throw new IllegalStateException("Deployment unit does not contain application meta data");
WebservicesMetaData wsMetaData = getWebservicesMetaData(unit);
if (wsMetaData == null)
throw new IllegalStateException("Deployment unit does not contain webservices meta data");
WebServiceDeployment webServiceDeployment = unit.getAttachment(WebServiceDeployment.class);
if (webServiceDeployment == null)
throw new IllegalStateException("Deployment unit does not contain webServiceDeployment");
// Copy the attachments
dep.addAttachment(WebservicesMetaData.class, wsMetaData);
dep.addAttachment(JBossMetaData.class, jbmd);
dep.addAttachment(WebServiceDeployment.class, webServiceDeployment);
for (WebserviceDescriptionMetaData wsd : wsMetaData.getWebserviceDescriptions())
{
for (PortComponentMetaData pcmd : wsd.getPortComponents())
{
String ejbLink = pcmd.getEjbLink();
if (ejbLink == null)
throw new IllegalStateException("ejb-link cannot be null");
JBossEnterpriseBeanMetaData beanMetaData = jbmd.getEnterpriseBean(ejbLink);
if (beanMetaData == null)
throw new IllegalStateException("Cannot obtain bean meta data for: " + ejbLink);
String ejbClass = beanMetaData.getEjbClass();
// Create the endpoint
Endpoint ep = newEndpoint(ejbClass);
ep.setShortName(ejbLink);
service.addEndpoint(ep);
}
}
return dep;
}