use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class PersistenceUnitParseProcessor method handleWarDeployment.
private void handleWarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!appClientContainerMode && isWarDeployment(deploymentUnit)) {
int puCount;
// ordered list of PUs
List<PersistenceUnitMetadataHolder> listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
// handle WEB-INF/classes/META-INF/persistence.xml
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
VirtualFile persistence_xml = deploymentRoot.getRoot().getChild(WEB_PERSISTENCE_XML);
parse(persistence_xml, listPUHolders, deploymentUnit);
PersistenceUnitMetadataHolder holder = normalize(listPUHolders);
deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
addApplicationDependenciesOnProvider(deploymentUnit, holder);
markDU(holder, deploymentUnit);
puCount = holder.getPersistenceUnits().size();
// look for persistence.xml in jar files in the META-INF/persistence.xml directory (these are not currently
// handled as subdeployments)
List<ResourceRoot> resourceRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS);
for (ResourceRoot resourceRoot : resourceRoots) {
if (resourceRoot.getRoot().getName().toLowerCase(Locale.ENGLISH).endsWith(JAR_FILE_EXTENSION)) {
listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
persistence_xml = resourceRoot.getRoot().getChild(META_INF_PERSISTENCE_XML);
parse(persistence_xml, listPUHolders, deploymentUnit);
holder = normalize(listPUHolders);
resourceRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
addApplicationDependenciesOnProvider(deploymentUnit, holder);
markDU(holder, deploymentUnit);
puCount += holder.getPersistenceUnits().size();
}
}
ROOT_LOGGER.tracef("parsed persistence unit definitions for war %s", deploymentRoot.getRootName());
incrementPersistenceUnitCount(deploymentUnit, puCount);
}
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class WSIntegrationProcessorJAXWS_JMS method getWsdlResourceRoot.
private static ResourceRoot getWsdlResourceRoot(final DeploymentUnit unit, final String wsdlPath) {
final AttachmentList<ResourceRoot> resourceRoots = new AttachmentList<ResourceRoot>(ResourceRoot.class);
final ResourceRoot root = unit.getAttachment(DEPLOYMENT_ROOT);
resourceRoots.add(root);
final AttachmentList<ResourceRoot> otherResourceRoots = unit.getAttachment(RESOURCE_ROOTS);
if (otherResourceRoots != null) {
resourceRoots.addAll(otherResourceRoots);
}
for (final ResourceRoot resourceRoot : resourceRoots) {
VirtualFile file = resourceRoot.getRoot().getChild(wsdlPath);
if (file.exists())
return resourceRoot;
}
return null;
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class WSIntegrationProcessorJAXWS_JMS method deploy.
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, unit)) {
return;
}
final List<AnnotationInstance> webServiceAnnotations = getAnnotations(unit, WEB_SERVICE_ANNOTATION);
// TODO: how about @WebServiceProvider JMS based endpoints?
//group @WebService annotations in the deployment by wsdl contract location
Map<String, List<AnnotationInstance>> map = new HashMap<String, List<AnnotationInstance>>();
for (AnnotationInstance webServiceAnnotation : webServiceAnnotations) {
final AnnotationValue wsdlLocation = webServiceAnnotation.value(WSDL_LOCATION);
final AnnotationValue port = webServiceAnnotation.value(PORT_NAME);
final AnnotationValue service = webServiceAnnotation.value(SERVICE_NAME);
//support for contract-first development only: pick-up @WebService annotations referencing a provided wsdl contract only
if (wsdlLocation != null && port != null && service != null) {
String key = wsdlLocation.asString();
List<AnnotationInstance> annotations = map.get(key);
if (annotations == null) {
annotations = new LinkedList<AnnotationInstance>();
map.put(key, annotations);
}
annotations.add(webServiceAnnotation);
}
}
//extract SOAP-over-JMS 1.0 bindings
List<JMSEndpointMetaData> list = new LinkedList<JMSEndpointMetaData>();
if (!map.isEmpty()) {
for (String wsdlLocation : map.keySet()) {
try {
final ResourceRoot resourceRoot = getWsdlResourceRoot(unit, wsdlLocation);
if (resourceRoot == null)
continue;
final VirtualFile wsdlLocationFile = resourceRoot.getRoot().getChild(wsdlLocation);
final URL url = wsdlLocationFile.toURL();
SOAPAddressWSDLParser parser = new SOAPAddressWSDLParser(url);
for (AnnotationInstance ai : map.get(wsdlLocation)) {
String port = ai.value(PORT_NAME).asString();
String service = ai.value(SERVICE_NAME).asString();
AnnotationValue targetNS = ai.value(TARGET_NAMESPACE);
String tns = targetNS != null ? targetNS.asString() : null;
QName serviceName = new QName(tns, service);
QName portName = new QName(tns, port);
String soapAddress = parser.filterSoapAddress(serviceName, portName, SOAPAddressWSDLParser.SOAP_OVER_JMS_NS);
if (soapAddress != null) {
ClassInfo webServiceClassInfo = (ClassInfo) ai.target();
String beanClassName = webServiceClassInfo.name().toString();
//service name ?
list.add(new JMSEndpointMetaData(beanClassName, port, beanClassName, wsdlLocation, soapAddress));
}
}
} catch (Exception ignore) {
WSLogger.ROOT_LOGGER.cannotReadWsdl(wsdlLocation);
}
}
}
unit.putAttachment(JMS_ENDPOINT_METADATA_KEY, new JMSEndpointsMetaData(list));
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class WebservicesDescriptorDeploymentProcessor method deploy.
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
final ResourceRoot deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final URL webservicesDescriptorURL = getWebServicesDescriptorURL(deploymentRoot);
if (webservicesDescriptorURL != null) {
final WebservicesPropertyReplaceFactory webservicesFactory = new WebservicesPropertyReplaceFactory(webservicesDescriptorURL, JBossDescriptorPropertyReplacement.propertyReplacer(unit));
final WebservicesMetaData webservicesMD = webservicesFactory.load(webservicesDescriptorURL);
unit.putAttachment(WSAttachmentKeys.WEBSERVICES_METADATA_KEY, webservicesMD);
if (hasJaxRpcMapping(webservicesMD)) {
throw WSLogger.ROOT_LOGGER.jaxRpcNotSupported();
}
}
}
use of org.jboss.as.server.deployment.module.ResourceRoot in project wildfly by wildfly.
the class AbstractDeploymentModelBuilder method newDeployment.
/**
* Creates new Web Service deployment.
*
* @param unit deployment unit
* @return archive deployment
*/
private ArchiveDeployment newDeployment(final DeploymentUnit unit) {
WSLogger.ROOT_LOGGER.tracef("Creating new unified WS deployment model for %s", unit);
final ResourceRoot deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT);
final VirtualFile root = deploymentRoot != null ? deploymentRoot.getRoot() : null;
final ClassLoader classLoader;
final Module module = unit.getAttachment(Attachments.MODULE);
if (module == null) {
classLoader = unit.getAttachment(CLASSLOADER_KEY);
if (classLoader == null) {
throw WSLogger.ROOT_LOGGER.classLoaderResolutionFailed(unit);
}
} else {
classLoader = module.getClassLoader();
}
ArchiveDeployment parentDep = null;
if (unit.getParent() != null) {
final Module parentModule = unit.getParent().getAttachment(Attachments.MODULE);
if (parentModule == null) {
throw WSLogger.ROOT_LOGGER.classLoaderResolutionFailed(deploymentRoot);
}
WSLogger.ROOT_LOGGER.tracef("Creating new unified WS deployment model for %s", unit.getParent());
parentDep = this.newDeployment(null, unit.getParent().getName(), parentModule.getClassLoader(), null);
}
final UnifiedVirtualFile uvf = root != null ? new VirtualFileAdaptor(root) : new ResourceLoaderAdapter(classLoader);
final ArchiveDeployment dep = this.newDeployment(parentDep, unit.getName(), classLoader, uvf);
//add an AnnotationInfo attachment that uses composite jandex index
dep.addAttachment(AnnotationsInfo.class, new JandexAnnotationsInfo(unit));
return dep;
}
Aggregations