You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2016/08/10 00:05:20 UTC

[jira] [Resolved] (VFS-621) Add API VFS.setManager(FileSystemManager)

     [ https://issues.apache.org/jira/browse/VFS-621?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved VFS-621.
------------------------------
    Resolution: Fixed

In trunk.

{noformat}
commit -m "[VFS-621] Add API VFS.setManager(FileSystemManager)." -N E:/vcs/svn/apache/commons/trunks-proper/vfs/core/src/main/java/org/apache/commons/vfs2/VFS.java E:/vcs/svn/apache/commons/trunks-proper/vfs/core/src/test/java/org/apache/commons/vfs2/VFSTest.java
    Sending        E:/vcs/svn/apache/commons/trunks-proper/vfs/core/src/main/java/org/apache/commons/vfs2/VFS.java
    Adding         E:/vcs/svn/apache/commons/trunks-proper/vfs/core/src/test/java/org/apache/commons/vfs2/VFSTest.java
    Transmitting file data ...
    Unknown action received: commit finalizing
    Committed revision 1755658.
{noformat}


> Add API VFS.setManager(FileSystemManager)
> -----------------------------------------
>
>                 Key: VFS-621
>                 URL: https://issues.apache.org/jira/browse/VFS-621
>             Project: Commons VFS
>          Issue Type: New Feature
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>             Fix For: 2.2
>
>
> Add API {{VFS.setManager(FileSystemManager)}}.
> Initialize VFS with the right class loader for OSGi types of scenarios to work. Must be called before any VFS APIs are called.
> Instead of:
> {code:java}
>         final StandardFileSystemManager fsm = new StandardFileSystemManager();
>         final ClassLoader classLoader = fsm.getClass().getClassLoader();
>         fsm.setClassLoader(classLoader);
>         try {
>             FieldUtils.writeDeclaredStaticField(VFS.class, "instance", fsm, true);
>             fsm.init();
>         } catch (final FileSystemException | IllegalAccessException e) {
>             ...
>         }
> {code}
> do:
> {code:java}
>         final StandardFileSystemManager fsm = new StandardFileSystemManager();
>         final ClassLoader classLoader = fsm.getClass().getClassLoader();
>         fsm.setClassLoader(classLoader);
>         VFS.setManager(fsm);
>         fsm.init();
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)