• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VFS类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: buildArchiveDescriptor

import org.jboss.vfs.VFS; //导入依赖的package包/类
@Override
public ArchiveDescriptor buildArchiveDescriptor(URL url, String entryBase) {
    try {
        return new VirtualFileSystemArchiveDescriptor( VFS.getChild( url.toURI() ), entryBase );
    }
    catch (URISyntaxException e) {
        throw new IllegalArgumentException( e );
    }
}
 
开发者ID:jipijapa,项目名称:jipijapa,代码行数:10,代码来源:VirtualFileSystemArchiveDescriptorFactory.java


示例17: getFile

import org.jboss.vfs.VFS; //导入依赖的package包/类
/**
 * Get the virtual file.
 * Create file from root url and path if it doesn't exist yet.
 *
 * @return virtual file root
 * @throws IOException for any error
 */
@SuppressWarnings("deprecation")
protected VirtualFile getFile() throws IOException
{
	if (file == null)
	{
		file = VFS.getChild( path );
	}
	return file;
}
 
开发者ID:jipijapa,项目名称:jipijapa,代码行数:17,代码来源:VirtualFileAdaptor.java


示例18: testJarProtocol

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


示例19: testZippedJar

import org.jboss.vfs.VFS; //导入依赖的package包/类
@Test
public void testZippedJar() 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(
				virtualFile.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,代码行数:29,代码来源:ScannerTest.java


示例20: getFile

import org.jboss.vfs.VFS; //导入依赖的package包/类
private VirtualFile getFile(URL url) {
    try {
        return VFS.getChild(url.toURI());
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:jipijapa,项目名称:jipijapa,代码行数:8,代码来源:HibernateAnnotationScanner.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LoggerTooFarBehindException类代码示例发布时间:2022-05-22
下一篇:
Java XPathSelector类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap