本文整理汇总了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);
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例15: getValue
import org.jboss.vfs.VFS; //导入依赖的package包/类
@Override
public VirtualFile getValue() {
if (deploymentRoot == null) {
throw new IllegalStateException();
}
return VFS.getChild(deploymentRoot.toAbsolutePath().toString());
}