Gary Gregory created VFS-621:
--------------------------------
Summary: 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)