[ https://issues.apache.org/jira/browse/VFS-621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15415889#comment-15415889 ]
Gary Gregory commented on VFS-621: ---------------------------------- I had to use the reflection code above (see the description) when running a product within IBM JCICS, which is a Java CICS layer (There's also a servlet layer in there) running inside a reusable JVM running inside CICS on an IBM mainframe. In addition, JCICS re-uses the same JVM and caches all statics from Java classes. It's a quite complex set up and use-case but a real-life one none-the-less. So, you may be correct that this does not fit a perfect OSGi scenario but that's what I had to deal with. > 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)