use of org.jboss.vfs.VirtualFile 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.vfs.VirtualFile in project jersey by jersey.
the class VFSSchemeResourceFinderTest method testClassEnumeration.
/**
* Test case for JERSEY-2197, JERSEY-2175.
*/
@Test
public void testClassEnumeration() throws Exception {
// Count actual entries.
int actualEntries = 0;
try (JarFile jarFile = new JarFile(jaxRsApiPath)) {
final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
if (entry.getName().endsWith(".class")) {
actualEntries++;
}
}
}
// Scan entries using VFS scanner.
final VirtualFile mountDir = VFS.getChild("content");
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
try (TempFileProvider provider = TempFileProvider.create("test", executor, false);
Closeable mount = VFS.mountZip(VFS.getChild(jaxRsApiPath), mountDir, provider)) {
ResourceFinder finder = new VfsSchemeResourceFinderFactory().create(new URI(mountDir.toURI().toString() + "/javax/ws/rs"), true);
int scannedEntryCount = 0;
while (finder.hasNext()) {
// Fetch next entry.
finder.next();
try (InputStream classStream = finder.open()) {
scannedEntryCount++;
}
}
assertThat("Failed to enumerate all contents of javax.ws.rs-api.", scannedEntryCount, equalTo(actualEntries));
} finally {
executor.shutdownNow();
}
}
use of org.jboss.vfs.VirtualFile 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.vfs.VirtualFile 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.vfs.VirtualFile 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