本文整理汇总了Java中org.jboss.vfs.VFS.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java VFS.getChild方法的具体用法?Java VFS.getChild怎么用?Java VFS.getChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.vfs.VFS
的用法示例。
在下文中一共展示了VFS.getChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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();
}
}
示例3: 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();
}
}
示例4: 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);
}
}
示例5: 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;
}
示例6: 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);
}
示例7: 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);
}
}
}
}
示例8: 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);
}
}
}
}
示例9: 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;
}
示例10: 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);
}
}
示例11: getValue
import org.jboss.vfs.VFS; //导入方法依赖的package包/类
@Override
public VirtualFile getValue() {
if (deploymentRoot == null) {
throw new IllegalStateException();
}
return VFS.getChild(deploymentRoot.toAbsolutePath().toString());
}
示例12: 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 );
}
}
示例13: 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;
}
示例14: 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();
}
}
示例15: 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();
}
}