use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class ScannerTest method testNestedJarProtocol.
@Test
public void testNestedJarProtocol() throws Exception {
File defaultPar = buildDefaultPar();
File nestedEar = buildNestedEar(defaultPar);
addPackageToClasspath(nestedEar);
final VirtualFile nestedEarVirtualFile = VFS.getChild(nestedEar.getAbsolutePath());
Closeable closeable = VFS.mountZip(nestedEarVirtualFile, nestedEarVirtualFile, tempFileProvider);
try {
VirtualFile parVirtualFile = nestedEarVirtualFile.getChild("defaultpar.par");
Closeable closeable2 = VFS.mountZip(parVirtualFile, parVirtualFile, tempFileProvider);
try {
ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(parVirtualFile.toURL());
AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
validateResults(resultCollector, ApplicationServer.class, Version.class);
} finally {
closeable2.close();
}
} finally {
closeable.close();
}
File nestedEarDir = buildNestedEarDir(defaultPar);
final VirtualFile nestedEarDirVirtualFile = VFS.getChild(nestedEarDir.getAbsolutePath());
try {
VirtualFile parVirtualFile = nestedEarDirVirtualFile.getChild("defaultpar.par");
closeable = VFS.mountZip(parVirtualFile, parVirtualFile, tempFileProvider);
try {
ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(parVirtualFile.toURL());
AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
validateResults(resultCollector, ApplicationServer.class, Version.class);
} finally {
closeable.close();
}
} finally {
closeable.close();
}
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class MessagingXmlParsingDeploymentUnitProcessor method messageDestinations.
private Set<VirtualFile> messageDestinations(final DeploymentUnit deploymentUnit) {
final VirtualFile deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
if (deploymentRoot == null || !deploymentRoot.exists()) {
return Collections.emptySet();
}
final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
if (deploymentRootName.endsWith("-jms.xml")) {
return Collections.singleton(deploymentRoot);
}
final Set<VirtualFile> ret = new HashSet<VirtualFile>();
for (String location : LOCATIONS) {
final VirtualFile loc = deploymentRoot.getChild(location);
if (loc.exists()) {
for (final VirtualFile file : loc.getChildren()) {
if (file.getName().endsWith("-jms.xml")) {
ret.add(file);
}
}
}
}
return ret;
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class KernelDeploymentParsingProcessor method deploy.
/**
* Process a deployment for jboss-beans.xml files.
* Will parse the xml file and attach a configuration discovered during processing.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*
*/
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
DeploymentUnit unit = phaseContext.getDeploymentUnit();
if (unit.hasAttachment(Attachments.OSGI_MANIFEST))
return;
final VirtualFile deploymentRoot = unit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
parseDescriptors(unit, deploymentRoot);
final List<ResourceRoot> resourceRoots = unit.getAttachmentList(Attachments.RESOURCE_ROOTS);
for (ResourceRoot root : resourceRoots) parseDescriptors(unit, root.getRoot());
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class PersistenceUnitParseProcessor method handleJarDeployment.
private void handleJarDeployment(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!isEarDeployment(deploymentUnit) && !isWarDeployment(deploymentUnit) && (!appClientContainerMode || DeploymentTypeMarker.isType(DeploymentType.APPLICATION_CLIENT, deploymentUnit))) {
// handle META-INF/persistence.xml
// ordered list of PUs
List<PersistenceUnitMetadataHolder> listPUHolders = new ArrayList<PersistenceUnitMetadataHolder>(1);
// handle META-INF/persistence.xml
final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
VirtualFile persistence_xml = deploymentRoot.getRoot().getChild(META_INF_PERSISTENCE_XML);
parse(persistence_xml, listPUHolders, deploymentUnit);
PersistenceUnitMetadataHolder holder = normalize(listPUHolders);
// save the persistent unit definitions
// deploymentUnit.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
deploymentRoot.putAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS, holder);
markDU(holder, deploymentUnit);
ROOT_LOGGER.tracef("parsed persistence unit definitions for jar %s", deploymentRoot.getRootName());
incrementPersistenceUnitCount(deploymentUnit, holder.getPersistenceUnits().size());
addApplicationDependenciesOnProvider(deploymentUnit, holder);
}
}
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);
}
}
Aggregations