use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class ScannerTest method testJarProtocol.
@Test
public void testJarProtocol() throws Exception {
File war = buildWar();
addPackageToClasspath(war);
final VirtualFile warVirtualFile = VFS.getChild(war.getAbsolutePath());
Closeable closeable = VFS.mountZip(warVirtualFile, warVirtualFile, tempFileProvider);
try {
ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor(warVirtualFile.toURL());
AbstractScannerImpl.ResultCollector resultCollector = new AbstractScannerImpl.ResultCollector(new StandardScanOptions());
archiveDescriptor.visitArchive(new AbstractScannerImpl.ArchiveContextImpl(new PersistenceUnitDescriptorAdapter(), true, resultCollector));
validateResults(resultCollector, org.hibernate.jpa.test.pack.war.ApplicationServer.class, org.hibernate.jpa.test.pack.war.Version.class);
} finally {
closeable.close();
}
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class IronJacamarDeploymentParsingProcessor method process.
public static IronJacamarXmlDescriptor process(VirtualFile deploymentRoot, boolean resolveProperties) throws DeploymentUnitProcessingException {
IronJacamarXmlDescriptor xmlDescriptor = null;
if (deploymentRoot == null || !deploymentRoot.exists())
return null;
final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
VirtualFile serviceXmlFile = null;
if (deploymentRootName.endsWith(".rar")) {
serviceXmlFile = deploymentRoot.getChild("/META-INF/ironjacamar.xml");
}
if (serviceXmlFile == null || !serviceXmlFile.exists())
return null;
InputStream xmlStream = null;
Activation result = null;
try {
xmlStream = serviceXmlFile.openStream();
IronJacamarParser ironJacamarParser = new IronJacamarParser();
ironJacamarParser.setSystemPropertiesResolved(resolveProperties);
result = ironJacamarParser.parse(xmlStream);
if (result != null) {
xmlDescriptor = new IronJacamarXmlDescriptor(result);
} else
throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile);
} catch (Exception e) {
throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile);
} finally {
VFSUtils.safeClose(xmlStream);
}
return xmlDescriptor;
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class RaDeploymentParsingProcessor method process.
public static ConnectorXmlDescriptor process(boolean resolveProperties, VirtualFile file, VirtualFile alternateDescriptor, String deploymentName) throws DeploymentUnitProcessingException {
// Locate the descriptor
final VirtualFile serviceXmlFile;
if (alternateDescriptor != null) {
serviceXmlFile = alternateDescriptor;
} else {
serviceXmlFile = file.getChild("/META-INF/ra.xml");
}
InputStream xmlStream = null;
Connector result = null;
try {
if (serviceXmlFile != null && serviceXmlFile.exists()) {
xmlStream = serviceXmlFile.openStream();
RaParser raParser = new RaParser();
raParser.setSystemPropertiesResolved(resolveProperties);
result = raParser.parse(xmlStream);
if (result == null)
throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(serviceXmlFile);
}
File root = file.getPhysicalFile();
URL url = root.toURI().toURL();
return new ConnectorXmlDescriptor(result, root, url, deploymentName);
} catch (Exception e) {
throw ConnectorLogger.ROOT_LOGGER.failedToParseServiceXml(e, serviceXmlFile);
} finally {
VFSUtils.safeClose(xmlStream);
}
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class DsXmlDeploymentParsingProcessor method deploy.
/**
* Process a deployment for standard ra deployment 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 {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
boolean resolveProperties = Util.shouldResolveJBoss(deploymentUnit);
final PropertyResolver propertyResolver = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_RESOLVER);
final PropertyReplacer propertyReplacer = deploymentUnit.getAttachment(org.jboss.as.ee.metadata.property.Attachments.FINAL_PROPERTY_REPLACER);
final Set<VirtualFile> files = dataSources(deploymentUnit);
boolean loggedDeprication = false;
for (VirtualFile f : files) {
InputStream xmlStream = null;
try {
xmlStream = new FileInputStream(f.getPhysicalFile());
DsXmlParser parser = new DsXmlParser(propertyResolver, propertyReplacer);
parser.setSystemPropertiesResolved(resolveProperties);
DataSources dataSources = parser.parse(xmlStream);
if (dataSources != null) {
if (!loggedDeprication) {
loggedDeprication = true;
ConnectorLogger.ROOT_LOGGER.deprecated();
}
for (DataSource ds : dataSources.getDataSource()) {
if (ds.getDriver() == null) {
throw ConnectorLogger.ROOT_LOGGER.FailedDeployDriverNotSpecified(ds.getJndiName());
}
}
deploymentUnit.addToAttachmentList(DATA_SOURCES_ATTACHMENT_KEY, dataSources);
}
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e.getMessage(), e);
} finally {
VFSUtils.safeClose(xmlStream);
}
}
}
use of org.jboss.vfs.VirtualFile in project wildfly by wildfly.
the class RaNativeProcessor method process.
public static void process(VirtualFile deploymentRoot) throws DeploymentUnitProcessingException {
if (deploymentRoot == null || !deploymentRoot.exists())
return;
final String deploymentRootName = deploymentRoot.getName().toLowerCase(Locale.ENGLISH);
if (!deploymentRootName.endsWith(".rar")) {
return;
}
try {
List<VirtualFile> libs = deploymentRoot.getChildrenRecursively(new LibraryFilter());
if (libs != null && libs.size() > 0) {
for (VirtualFile vf : libs) {
String fileName = vf.getName().toLowerCase(Locale.ENGLISH);
ROOT_LOGGER.tracef("Processing library: %s", fileName);
try {
File f = vf.getPhysicalFile();
System.load(f.getAbsolutePath());
ROOT_LOGGER.debugf("Loaded library: %s", f.getAbsolutePath());
} catch (Throwable t) {
ROOT_LOGGER.debugf("Unable to load library: %s", fileName);
}
}
}
} catch (Exception e) {
throw ConnectorLogger.ROOT_LOGGER.failedToLoadNativeLibraries(e);
}
}
Aggregations