当前位置: 首页>>代码示例>>Java>>正文


Java VFS类代码示例

本文整理汇总了Java中org.jboss.vfs.VFS的典型用法代码示例。如果您正苦于以下问题:Java VFS类的具体用法?Java VFS怎么用?Java VFS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VFS类属于org.jboss.vfs包,在下文中一共展示了VFS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createResourceRoot

import org.jboss.vfs.VFS; //导入依赖的package包/类
/**
 * Creates a {@link ResourceRoot} for the passed {@link VirtualFile file} and adds it to the list of {@link ResourceRoot}s
 * in the {@link DeploymentUnit deploymentUnit}
 *
 *
 * @param file           The file for which the resource root will be created
 * @return Returns the created {@link ResourceRoot}
 * @throws java.io.IOException
 */
private synchronized ResourceRoot createResourceRoot(final VirtualFile file, final DeploymentUnit deploymentUnit, final VirtualFile deploymentRoot) throws DeploymentUnitProcessingException {
    try {
        Map<String, MountedDeploymentOverlay> overlays = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_OVERLAY_LOCATIONS);

        String relativeName = file.getPathNameRelativeTo(deploymentRoot);
        MountedDeploymentOverlay overlay = overlays.get(relativeName);
        Closeable closable = null;
        if(overlay != null) {
            overlay.remountAsZip(false);
        } else if(file.isFile()) {
            closable = VFS.mountZip(file, file, TempFileProviderService.provider());
        }
        final MountHandle mountHandle = new MountHandle(closable);
        final ResourceRoot resourceRoot = new ResourceRoot(file, mountHandle);
        ModuleRootMarker.mark(resourceRoot);
        ResourceRootIndexer.indexResourceRoot(resourceRoot);
        return resourceRoot;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:31,代码来源:ManifestClassPathProcessor.java

示例2: loadVfs

import org.jboss.vfs.VFS; //导入依赖的package包/类
public static List<URL> loadVfs(URL resource) throws IOException
{
  List<URL> result = new LinkedList<>();

  try
  {
    VirtualFile r = VFS.getChild(resource.toURI());
    if (r.exists() && r.isDirectory())
    {
      for (VirtualFile f : r.getChildren())
      {
        result.add(f.asFileURL());
      }
    }
  }
  catch (URISyntaxException e)
  {
    System.out.println("Problem reading resource '" + resource + "':\n " + e.getMessage());
    log.error("Exception thrown", e);
  }

  return result;
}
 
开发者ID:ngageoint,项目名称:mrgeo,代码行数:24,代码来源:ClassLoaderUtil.java

示例3: testInputStreamZippedJar

import org.jboss.vfs.VFS; //导入依赖的package包/类
@Test
public void testInputStreamZippedJar() throws Exception {
	File defaultPar = buildDefaultPar();
	addPackageToClasspath( defaultPar );

	final VirtualFile virtualFile = VFS.getChild( defaultPar.getAbsolutePath() );
	Closeable closeable = VFS.mountZip( virtualFile, virtualFile, tempFileProvider );

	try {
		ArchiveDescriptor archiveDescriptor = VirtualFileSystemArchiveDescriptorFactory.INSTANCE.buildArchiveDescriptor( defaultPar.toURI().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();
	}
}
 
开发者ID:jipijapa,项目名称:jipijapa,代码行数:26,代码来源:ScannerTest.java

示例4: removeAllContent

import org.jboss.vfs.VFS; //导入依赖的package包/类
public void removeAllContent() throws IOException {
    IOException exception = null;
    for (URI uri : this.index.values()) {
        VirtualFile file = VFS.getChild(uri);
        file.delete();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:8,代码来源:SwarmContentRepository.java

示例5: start

import org.jboss.vfs.VFS; //导入依赖的package包/类
@Override
public void start(StartContext startContext) throws StartException {
    this.fsMount = VFS.getChild("wildfly-swarm-deployments");
    try {
        this.fsCloseable = VFS.mount(this.fsMount, this.fs);
    } catch (IOException e) {
        throw new StartException(e);
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:10,代码来源:SwarmContentRepository.java

示例6: mount

import org.jboss.vfs.VFS; //导入依赖的package包/类
public static VirtualFile mount(URL url) throws IOException, URISyntaxException {
	//we treat each zip as unique if it's possible that it 
	String fileName = "teiid-vdb-" + url.toExternalForm(); //$NON-NLS-1$
	VirtualFile root = VFS.getChild(fileName);
	File f = new File(url.toURI());
	if (root.exists()) {
		long lastModified = f.lastModified();
		if (root.getLastModified() != lastModified) {
			fileName += counter.get();
			//TODO: should check existence
			root = VFS.getChild(fileName);
		}
	}
   	if (!root.exists()) {
		final Closeable c = VFS.mount(root, new PureZipFileSystem(f));
		//in theory we don't need to track the closable as we're not using any resources
		AutoCleanupUtil.setCleanupReference(root, new Removable() {
			
			@Override
			public void remove() {
				try {
					c.close();
				} catch (IOException e) {
				}
			}
		});
   	}
   	return root;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:30,代码来源:PureZipFileSystem.java

示例7: exampleTransformationMetadata

import org.jboss.vfs.VFS; //导入依赖的package包/类
private TransformationMetadata exampleTransformationMetadata()
		throws TranslatorException {
	Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
	Datatype dt = new Datatype();
	dt.setName(DataTypeManager.DefaultDataTypes.STRING);
	dt.setJavaClassName(String.class.getCanonicalName());
       datatypes.put(DataTypeManager.DefaultDataTypes.STRING, dt);
	MetadataFactory mf = new MetadataFactory(null, 1, "x", datatypes, new Properties(), null); //$NON-NLS-1$
	mf.addProcedure("y"); //$NON-NLS-1$
	
	Table t = mf.addTable("foo");
	mf.addColumn("col", DataTypeManager.DefaultDataTypes.STRING, t);
	
	MetadataFactory mf1 = new MetadataFactory(null, 1, "x1", datatypes, new Properties(), null); //$NON-NLS-1$
	mf1.addProcedure("y"); //$NON-NLS-1$
	
	Table table = mf1.addTable("doc");
	table.setSchemaPaths(Arrays.asList("../../x.xsd"));
	table.setResourcePath("/a/b/doc.xmi");
	
	HashMap<String, VDBResources.Resource> resources = new HashMap<String, VDBResources.Resource>();
	resources.put("/x.xsd", new VDBResources.Resource(VFS.getRootVirtualFile()));
	
	CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.asMetadataStore(), mf1.asMetadataStore()));
	
	VDBMetaData vdb = new VDBMetaData();
	vdb.setName("vdb");
	vdb.setVersion(1);
	
	vdb.addModel(buildModel("x"));
	vdb.addModel(buildModel("x1"));
	vdb.addModel(buildModel("y"));
	
	return new TransformationMetadata(vdb, cms, resources, RealMetadataFactory.SFM.getSystemFunctions(), null);
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:36,代码来源:TestTransformationMetadata.java

示例8: beforeClass

import org.jboss.vfs.VFS; //导入依赖的package包/类
@BeforeClass public static void beforeClass() throws IOException {
   	FileWriter f = new FileWriter(UnitTestUtil.getTestScratchPath()+"/foo");
   	f.write("ResourceContents");
   	f.close();
   	
   	root = VFS.getChild("location");
   	fileMount = VFS.mountReal(new File(UnitTestUtil.getTestScratchPath()), root);		
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:9,代码来源:TestMetadataFactory.java

示例9: find

import org.jboss.vfs.VFS; //导入依赖的package包/类
protected void find(PackageScanFilter test, String packageName, ClassLoader loader, Set<Class<?>> classes) {
    if (LOG.isTraceEnabled()) {
        LOG.tracef("Searching for: %s in package: %s using classloader: %s", 
                new Object[]{test, packageName, loader.getClass().getName()});
    }

    Enumeration<URL> urls;
    try {
        urls = getResources(loader, packageName);
        if (!urls.hasMoreElements()) {
            LOG.trace("No URLs returned by classloader");
        }
    } catch (IOException ioe) {
        ExtensionLogger.ROOT_LOGGER.cannotReadPackage(packageName, ioe);
        return;
    }

    while (urls.hasMoreElements()) {
        URL url = urls.nextElement();
        LOG.tracef("URL from classloader: %s", url);
        
        if (url.toString().startsWith("vfs:")) {
            try {
                VirtualFile vfsDir = VFS.getChild(url);
                handleDirectory(vfsDir, null, classes, test);
            } catch (URISyntaxException uriEx) {
                ExtensionLogger.ROOT_LOGGER.failedToParseURL(url.toString(), uriEx);
            }
        }
            
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:33,代码来源:JBoss7PackageScanClassResolver.java

示例10: copyResources

import org.jboss.vfs.VFS; //导入依赖的package包/类
/**
 * Copies resources to target folder.
 *
 * @param resourceUrl
 * @param targetPath
 * @return
 */
static void copyResources(URL resourceUrl, File targetPath) throws IOException, URISyntaxException {
    if (resourceUrl == null) {
        return;
    }

    URLConnection urlConnection = resourceUrl.openConnection();

    /**
     * Copy resources either from inside jar or from project folder.
     */
    if (urlConnection instanceof JarURLConnection) {
        copyJarResourceToPath((JarURLConnection) urlConnection, targetPath);
    } else if (VFS_PROTOCOL.equals(resourceUrl.getProtocol())) {
        VirtualFile virtualFileOrFolder = VFS.getChild(resourceUrl.toURI());
        copyFromWarToFolder(virtualFileOrFolder, targetPath);
    } else {
        File file = new File(resourceUrl.getPath());
        if (file.isDirectory()) {
            for (File resourceFile : FileUtils.listFiles(file, null, true)) {
                int index = resourceFile.getPath().lastIndexOf(targetPath.getName()) + targetPath.getName().length();
                File targetFile = new File(targetPath, resourceFile.getPath().substring(index));
                if (!targetFile.exists() || targetFile.length() != resourceFile.length()) {
                    if (resourceFile.isFile()) {
                        FileUtils.copyFile(resourceFile, targetFile);
                    }
                }
            }
        } else {
            if (!targetPath.exists() || targetPath.length() != file.length()) {
                FileUtils.copyFile(file, targetPath);
            }
        }
    }
}
 
开发者ID:nguyenq,项目名称:tess4j,代码行数:42,代码来源:LoadLibs.java

示例11: getAssetPaths

import org.jboss.vfs.VFS; //导入依赖的package包/类
@Override
public Set<String> getAssetPaths(URL url, final Pattern filterExpr, ClassLoader... classLoaders) {
    HashSet<String> assetPaths = new HashSet<String>();
    try {
        final VirtualFile virtualFile = VFS.getChild(url.toURI());
        List<VirtualFile> children = virtualFile.getChildrenRecursively(new VirtualFileFilter() {
            @Override
            public boolean accepts(VirtualFile file) {
                if (file.isDirectory()) {
                    return false;
                }
                int prefixIndex = file.getPathName().indexOf(WEBJARS_PATH_PREFIX);
                if (prefixIndex == -1) {
                    return false;
                }

                final String relativePath = file.getPathName().substring(prefixIndex);

                return file.isFile() && filterExpr.matcher(relativePath).matches();
            }
        });
        for (VirtualFile child : children) {
            assetPaths.add(child.getPathName().substring(child.getPathName().indexOf(WEBJARS_PATH_PREFIX)));
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    return assetPaths;
}
 
开发者ID:mwanji,项目名称:webjars-locator-jboss-vfs,代码行数:31,代码来源:JbossUrlProtocolHandler.java

示例12: addRolloutPlan

import org.jboss.vfs.VFS; //导入依赖的package包/类
void addRolloutPlan(ModelNode dmr) throws Exception {
    File systemTmpDir = new File(System.getProperty("java.io.tmpdir"));
    File tempDir = new File(systemTmpDir, "test" + System.currentTimeMillis());
    tempDir.mkdir();
    File file = new File(tempDir, "content");
    this.vf = VFS.getChild(file.toURI());

    try (final PrintWriter out = new PrintWriter(Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8))){
        dmr.writeString(out, true);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:SyncModelServerStateTestCase.java

示例13: handleExplodedEntryWithDirParent

import org.jboss.vfs.VFS; //导入依赖的package包/类
@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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:9,代码来源:DeferredDeploymentOverlayDeploymentUnitProcessor.java

示例14: remountAsZip

import org.jboss.vfs.VFS; //导入依赖的package包/类
public void remountAsZip(boolean expanded) throws IOException {
    IoUtils.safeClose(closeable);
    if(expanded) {
        closeable = VFS.mountZipExpanded(realFile, mountPoint, tempFileProvider);
    } else {
        closeable = VFS.mountZip(realFile, mountPoint, tempFileProvider);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:9,代码来源:MountedDeploymentOverlay.java

示例15: getValue

import org.jboss.vfs.VFS; //导入依赖的package包/类
@Override
public VirtualFile getValue() {
    if (deploymentRoot == null) {
        throw new IllegalStateException();
    }
    return VFS.getChild(deploymentRoot.toAbsolutePath().toString());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:8,代码来源:ManagedExplodedContentServitor.java


注:本文中的org.jboss.vfs.VFS类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。