本文整理了Java中org.apache.commons.vfs.VFS.getManager()
方法的一些代码示例,展示了VFS.getManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VFS.getManager()
方法的具体详情如下:
包路径:org.apache.commons.vfs.VFS
类名称:VFS
方法名:getManager
[英]Returns the default FileSystemManager instance
[中]返回默认的FileSystemManager实例
代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib
public RepositoryManager() {
try {
fsManager = VFS.getManager();
} catch (FileSystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
代码示例来源:origin: org.jbpm/jbpm-form-services
protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException {
if (url.toExternalForm().startsWith("vfs")) {
FileObject to = VFS.getManager().resolveFile(url.toExternalForm());
File tmpFile = File.createTempFile("xxFilexx", ".json");
FileUtils.writeStringToFile(tmpFile, json);
FileObject from = VFS.getManager().toFileObject(tmpFile);
to.copyFrom(from, new AllFileSelector());
FileUtils.deleteQuietly(tmpFile);
} else {
FileUtils.writeStringToFile(FileUtils.toFile(url), json);
}
}
代码示例来源:origin: org.jbpm/form-services
protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException {
if (url.toExternalForm().startsWith("vfs")) {
FileObject to = VFS.getManager().resolveFile(url.toExternalForm());
File tmpFile = File.createTempFile("xxFilexx", ".json");
FileUtils.writeStringToFile(tmpFile, json);
FileObject from = VFS.getManager().toFileObject(tmpFile);
to.copyFrom(from, new AllFileSelector());
FileUtils.deleteQuietly(tmpFile);
} else {
FileUtils.writeStringToFile(FileUtils.toFile(url), json);
}
}
代码示例来源:origin: org.jbpm/form-services
protected String readURL(URL url) throws FileNotFoundException, IOException {
if (url.toExternalForm().startsWith("vfs")) {
FileObject from = VFS.getManager().resolveFile(url.toExternalForm());
return IOUtils.toString(from.getContent().getInputStream());
} else {
return FileUtils.readFileToString(FileUtils.toFile(url));
}
}
}
代码示例来源:origin: org.jbpm/jbpm-form-services
protected String readURL(URL url) throws FileNotFoundException, IOException {
if (url.toExternalForm().startsWith("vfs")) {
FileObject from = VFS.getManager().resolveFile(url.toExternalForm());
return IOUtils.toString(from.getContent().getInputStream());
} else {
return FileUtils.readFileToString(FileUtils.toFile(url));
}
}
}
代码示例来源:origin: net.sourceforge.tink/tink-model
protected void logout() throws TinkException, IOException
{
VFS.getManager().closeFileSystem(remote.getFileSystem());
}
代码示例来源:origin: org.apache.excalibur.components/excalibur-sourceresolve
/**
* Constructor, creates instance of class.
*
* @param location location to resolve
* @param parameters protocol specific parameters
* @throws FileSystemException if an error occurs
*/
public CommonsVFSSource(final String location, final Map parameters)
throws FileSystemException {
m_location = location;
m_manager = VFS.getManager();
m_fileObject = m_manager.resolveFile(location); // REVISIT: parameters
m_fileContent = m_fileObject.getContent();
}
代码示例来源:origin: org.motechproject/motech-platform-server-config
private void setupLocation() throws FileSystemException {
ConfigLocation configLocation = coreConfigurationService.getConfigLocation();
monitoredDir = VFS.getManager().resolveFile(configLocation.getLocation());
fileMonitor.addFile(monitoredDir);
LOGGER.info(String.format("Setting up monitoring for location: %s", monitoredDir));
}
代码示例来源:origin: org.apache.kalumet/org.apache.kalumet.common
/**
* Private constructor to init the singleton.
*
* @throws FileManipulatorException in <code>FileManipulator</code> init failed.
*/
public FileManipulator()
throws FileManipulatorException
{
try
{
LOGGER.debug( "Creating VFS file system manager ..." );
this.fileSystemManager = VFS.getManager();
// this.fileSystemManager = new StandardFileSystemManager();
// fileSystemManager.setCacheStrategy(CacheStrategy.ON_CALL);
( (StandardFileSystemManager) this.fileSystemManager ).setReplicator( new KalumetFileReplicator() );
// fileSystemManager.init();
}
catch ( Exception e )
{
throw new FileManipulatorException( e );
}
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Creates a VFS file handler with the default file system manager.
*/
public VFSFileHandler()
{
try
{
this.fileSystemManager = VFS.getManager();
}
catch (FileSystemException e)
{
throw new CargoException("Failed to get VFS system manager", e);
}
}
代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib
/**
* Constructor
*
* @param rootFileUrl
*/
public WebDAVRepository(String rootFileUrl) {
try {
this.setFsManager(VFS.getManager());
this.root = this.fsManager.resolveFile(rootFileUrl);
this.fsManager.createFileSystem(root);
} catch (FileSystemException e) {
e.printStackTrace();
}
}
代码示例来源:origin: Wimmics/corese
public static URI extractResourceDir(String dirname, boolean overwrite) throws FileSystemException, URISyntaxException {
URL dir_url = EmbeddedJettyServer.class.getClassLoader().getResource(dirname);
FileObject dir_jar = VFS.getManager().resolveFile(dir_url.toString());
String tempDir = FileUtils.getTempDirectory() + File.separator + System.getProperty("user.name").replace(" ", "");
FileObject tmpF = VFS.getManager().resolveFile(tempDir);
FileObject localDir = tmpF.resolveFile(dirname);
if (!localDir.exists()) {
logger.info("Extracting directory " + dirname + " to " + tmpF.getName());
localDir.createFolder();
localDir.copyFrom(dir_jar, new AllFileSelector());
} else {
if (overwrite) {
logger.info("Overwritting directory " + dirname + " in " + tmpF.getName());
localDir.delete(new FileDepthSelector(0, 5));
localDir.createFolder();
localDir.copyFrom(dir_jar, new AllFileSelector());
}
}
resourceURI = localDir.getURL().toURI();
return resourceURI;
}
代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib
/**
* Constructor
*
* @param rootFileUrl
* The root directory of the repository.
*/
public LocalRepository(String rootFileUrl) {
try {
this.setFsManager(VFS.getManager());
this.root = this.fsManager.resolveFile(rootFileUrl);
this.fsManager.createFileSystem(root);
} catch (FileSystemException e) {
e.printStackTrace();
}
}
代码示例来源:origin: fr.inria.corese/corese-server
public static URI extractResourceDir(String dirname, boolean overwrite) throws FileSystemException, URISyntaxException {
URL dir_url = EmbeddedJettyServer.class.getClassLoader().getResource(dirname);
FileObject dir_jar = VFS.getManager().resolveFile(dir_url.toString());
String tempDir = FileUtils.getTempDirectory() + File.separator + System.getProperty("user.name").replace(" ", "");
FileObject tmpF = VFS.getManager().resolveFile(tempDir);
FileObject localDir = tmpF.resolveFile(dirname);
if (!localDir.exists()) {
logger.info("Extracting directory " + dirname + " to " + tmpF.getName());
localDir.createFolder();
localDir.copyFrom(dir_jar, new AllFileSelector());
} else {
if (overwrite) {
logger.info("Overwritting directory " + dirname + " in " + tmpF.getName());
localDir.delete(new FileDepthSelector(0, 5));
localDir.createFolder();
localDir.copyFrom(dir_jar, new AllFileSelector());
}
}
resourceURI = localDir.getURL().toURI();
return resourceURI;
}
代码示例来源:origin: net.sourceforge.tink/tink-model
protected void login() throws TinkException, IOException
{
URI location = getConfig().getRemote();
StaticUserAuthenticator auth = new StaticUserAuthenticator(null, getConfig().getUser(), getConfig().getPassword());
FileSystemOptions opts = new FileSystemOptions();
FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
remote = VFS.getManager().resolveFile(location.toString(), opts);
}
代码示例来源:origin: org.geoserver.importer/importer-core
/**
* Extracts the archive file {@code archiveFile} to {@code targetFolder}; both shall previously
* exist.
*/
public void extractTo(File archiveFile, File targetFolder) throws IOException {
FileSystemManager manager = VFS.getManager();
String sourceURI = resolveArchiveURI(archiveFile);
// String targetURI = resolveArchiveURI(targetFolder);
FileObject source = manager.resolveFile(sourceURI);
if (manager.canCreateFileSystem(source)) {
source = manager.createFileSystem(source);
}
FileObject target = manager.createVirtualFileSystem(manager.resolveFile(targetFolder
.getAbsolutePath()));
FileSelector selector = new AllFileSelector() {
@Override
public boolean includeFile(FileSelectInfo fileInfo) {
LOGGER.fine("Uncompressing " + fileInfo.getFile().getName().getFriendlyURI());
return true;
}
};
target.copyFrom(source, selector);
source.close();
manager.closeFileSystem(source.getFileSystem());
}
代码示例来源:origin: org.sonatype.gshell.commands/gshell-vfs
/**
* Attaches this file object to its file resource.
*/
protected void doAttach() throws Exception {
if (file == null) {
LayeredFileName layeredFileName = (LayeredFileName) getName();
String fileName = layeredFileName.getOuterName().getRootURI() + layeredFileName.getOuterName().getPathDecoded();
FileObject outer = getFileSystem().resolveFile(fileName);
if (outer instanceof TruezipFileObject) {
fileName = layeredFileName.getOuterName().getPathDecoded() + getName().getPathDecoded();
file = new File(fileName, ArchiveDetector.ALL);
}
else {
fileObject = outer;
DefaultFileSystemManager dfsMgr = (DefaultFileSystemManager) VFS.getManager();
file = new File(dfsMgr.getTemporaryFileStore().allocateFile(getName().getBaseName()));
}
}
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test the creation of a config directory when the target directory exists and is empty.
* @throws Exception If anything goes wrong.
*/
public void testCreateConfigDirWhenDirectoryExistButIsEmpty() throws Exception
{
String configDir = "ram:///cargo/testCreateConfigDirWhenDirectoryExistButIsEmpty";
FileObject configDirObject = VFS.getManager().resolveFile(configDir);
FileObject timestampFileObject = configDirObject.resolveFile(".cargo");
configDirObject.createFolder();
TestableAbstractStandaloneConfiguration configuration =
new TestableAbstractStandaloneConfiguration(configDir);
configuration.setFileHandler(new VFSFileHandler());
configuration.setupConfigurationDir();
assertTrue("Cargo timestamp should have existed", timestampFileObject.exists());
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test the creation of a config directory when the target directory exists and is not empty.
* @throws Exception If anything goes wrong.
*/
public void testCreateConfigDirWhenDirectoryNotEmpty() throws Exception
{
String configDir = "ram:///cargo/testCreateConfigDirWhenDirectoryNotEmpty";
FileObject configDirObject = VFS.getManager().resolveFile(configDir);
configDirObject.resolveFile("somefile").createFile();
TestableAbstractStandaloneConfiguration configuration =
new TestableAbstractStandaloneConfiguration(configDir);
configuration.setFileHandler(new VFSFileHandler());
try
{
configuration.setupConfigurationDir();
fail("Should have thrown a ContainerException as the directory is not empty");
}
catch (ContainerException expected)
{
assertEquals("Invalid configuration dir "
+ "[ram:///cargo/testCreateConfigDirWhenDirectoryNotEmpty]. When using standalone "
+ "configurations, the configuration dir must point to an empty directory. Note "
+ "that everything in that dir will get deleted by Cargo.", expected.getMessage());
}
}
代码示例来源:origin: codehaus-cargo/cargo
/**
* Test the creation of a config directory when the target directory does not exist yet.
* @throws Exception If anything goes wrong.
*/
public void testCreateConfigDirWhenDirectoryDoesNotExist() throws Exception
{
String configDir = "ram:///cargo/testCreateConfigDirWhenDirectoryDoesNotExist";
FileObject configDirObject = VFS.getManager().resolveFile(configDir);
FileObject timestampFileObject = configDirObject.resolveFile(".cargo");
configDirObject.delete(new AllFileSelector());
TestableAbstractStandaloneConfiguration configuration =
new TestableAbstractStandaloneConfiguration(configDir);
configuration.setFileHandler(new VFSFileHandler());
configuration.setupConfigurationDir();
assertTrue("Config dir should have been created", configDirObject.exists());
assertTrue("Cargo timestamp should have existed", timestampFileObject.exists());
}
内容来源于网络,如有侵权,请联系作者删除!