@Override public File getFile() { try { return file.getPhysicalFile(); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Adds the content of the {@link InputStream} to the zip in a location that mirrors where {@link VirtualFile file} is located. * * For example if {@code file} is at {@code /tmp/foo/bar} and {@code $JBOSS_HOME} is {@code tmp} then the destination will be {@code JBOSSHOME/foo/bar} * * @param file {@link VirtualFile} where metadata is read from * @param is content to write to the zip file * @throws Exception */ public void add(VirtualFile file, InputStream is) throws Exception { String name = "JBOSS_HOME" + file.getPhysicalFile().getAbsolutePath().substring(this.jbossHome.length()); this.add(is, name); }
public static boolean isSymlink(VirtualFile vFile) throws IOException { File file = vFile.getPhysicalFile(); if(Utils.isWindows()){ return false; } File fileInCanonicalDir = null; if (file.getParent() == null) { fileInCanonicalDir = file; } else { File canonicalDir = file.getParentFile().getCanonicalFile(); fileInCanonicalDir = new File(canonicalDir, file.getName()); } if (fileInCanonicalDir.getCanonicalFile().equals(fileInCanonicalDir.getAbsoluteFile())) { return false; } else { return true; } }
public ServletResourceManager(final VirtualFile resourcesRoot, final Collection<VirtualFile> overlays, boolean explodedDeployment, boolean followSymlink, boolean disableFileWatchService, List<String> externalOverlays) throws IOException { this.explodedDeployment = explodedDeployment; Path physicalFile = resourcesRoot.getPhysicalFile().toPath().toRealPath(); deploymentResourceManager = new PathResourceManager(physicalFile, TRANSFER_MIN_SIZE, true, followSymlink, !disableFileWatchService); this.overlays = overlays; if(externalOverlays == null) { this.externalOverlays = new ResourceManager[0]; } else { this.externalOverlays = new ResourceManager[externalOverlays.size()]; for (int i = 0; i < externalOverlays.size(); ++i) { String path = externalOverlays.get(i); PathResourceManager pr = new PathResourceManager(Paths.get(path).toRealPath(), TRANSFER_MIN_SIZE, true, followSymlink, !disableFileWatchService); this.externalOverlays[i] = pr; } } }
private Closeable exportExplodedWar(final boolean war, final VirtualFile file, final DeploymentUnit deploymentUnit) throws IOException { if (isExplodedWarInArchiveEar(war, file, deploymentUnit)) { File warContent = file.getPhysicalFile(); VFSUtils.recursiveCopy(file, warContent.getParentFile()); return VFS.mountReal(warContent, file); } return null; }
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); } }
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ModuleSpecification attachment = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION); if (attachment == null) { return; } final List<PermissionFactory> permissions = attachment.getPermissionFactories(); final Enumeration<Permission> e = DEFAULT_PERMISSIONS.elements(); while (e.hasMoreElements()) { permissions.add(new ImmediatePermissionFactory(e.nextElement())); } //make sure they can read the contents of the deployment ResourceRoot root = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); try { File file = root.getRoot().getPhysicalFile(); if(file != null && file.isDirectory()) { FilePermission permission = new FilePermission(file.getAbsolutePath() + File.separatorChar + "-", "read"); permissions.add(new ImmediatePermissionFactory(permission)); } } catch (IOException ex) { throw new DeploymentUnitProcessingException(ex); } }
VirtualFile child = overlay.getChild(p); if (child.exists()) { VirtualFileResource vfsResource = new VirtualFileResource(overlay.getPhysicalFile(), child, path); for (Resource c : vfsResource.list()) { ret.add(new ServletResource(this, c));
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); } }
return new ServletResource(this, new VirtualFileResource(overlay.getPhysicalFile(), child, canonical)); } catch (IllegalArgumentException ignore) {
@Override public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { DeploymentUnit unit = context.getDeploymentUnit(); if (!unit.hasAttachment(SingletonDeploymentDependencyProcessor.CONFIGURATION_KEY)) { VirtualFile file = unit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot().getChild(SINGLETON_DEPLOYMENT_DESCRIPTOR); if (file.exists()) { try { unit.putAttachment(SingletonDeploymentDependencyProcessor.CONFIGURATION_KEY, this.parse(unit, file.getPhysicalFile())); } catch (IOException e) { throw new DeploymentUnitProcessingException(e); } } } }
InputStream xmlStream = null; try { xmlStream = new FileInputStream(f.getPhysicalFile()); DsXmlParser parser = new DsXmlParser(propertyResolver, propertyReplacer); parser.setSystemPropertiesResolved(resolveProperties);
ejbClientDeploymentDescriptorFile = descriptorFile.getPhysicalFile(); } catch (IOException e) { throw EeLogger.ROOT_LOGGER.failedToProcessEJBClientDescriptor(e);
/** * Get a physical URI for a virtual file. See the warnings on the {@link VirtualFile#getPhysicalFile()} method * before using this method. * * @param file the virtual file * @return the physical file URL * @throws IOException if an I/O error occurs getting the physical file */ public static URI getPhysicalURI(VirtualFile file) throws IOException { return file.getPhysicalFile().toURI(); }
protected void handleExplodedEntryWithDirParent(DeploymentUnit deploymentUnit, VirtualFile content, VirtualFile mountPoint, Map<String, MountedDeploymentOverlay> mounts, String overLayPath) throws IOException{ copyFile(content.getPhysicalFile(), mountPoint.getPhysicalFile()); }
import org.jboss.vfs.*; String filename = ...; URLConnection conn = new URL("vfs:/...").openConnection(); VirtualFile vf = (VirtualFile)conn.getContent(); File contentsFile = vf.getPhysicalFile(); File dir = contentsFile.getParentFile(); File physicalFile = new File(dir, filename); InputStream is = new FileInputStream(physicalFile);
/** * {@inheritDoc} */ public File getFile(VirtualFile mountPoint, VirtualFile target) throws IOException { return getExistingFile(mountPoint, target).getPhysicalFile(); }
/** * This method is a hack to make sure the WAR is fully exploded. Currently * this is only needed for WARs that come through the DeclaredStructure * deployer. This should be removed when the DeclaredStructure deployer * correctly support exploding WARs. */ private VirtualFile getExplodedApplication(VirtualFile virtualFile) throws IOException { File physicalRoot = virtualFile.getPhysicalFile(); virtualFile = VFS.getChild( physicalRoot.getAbsolutePath() ); return virtualFile; }
@Override protected void handleExplodedEntryWithDirParent(DeploymentUnit deploymentUnit, VirtualFile content, VirtualFile mountPoint, Map<String, MountedDeploymentOverlay> mounts, String overLayPath) throws IOException { Closeable handle = VFS.mountReal(content.getPhysicalFile(), mountPoint); MountedDeploymentOverlay mounted = new MountedDeploymentOverlay(handle, content.getPhysicalFile(), mountPoint, TempFileProviderService.provider()); deploymentUnit.addToAttachmentList(MOUNTED_FILES, mounted); mounts.put(overLayPath, mounted); }
private Closeable exportExplodedWar(final boolean war, final VirtualFile file, final DeploymentUnit deploymentUnit) throws IOException { if (isExplodedWarInArchiveEar(war, file, deploymentUnit)) { File warContent = file.getPhysicalFile(); VFSUtils.recursiveCopy(file, warContent.getParentFile()); return VFS.mountReal(warContent, file); } return null; }