Uploaded image for project: 'JBoss VFS'
  1. JBoss VFS
  2. JBVFS-207

Provide way to retrieve VirtualFile instance from url.openConnection()

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • 3.5.0.Alpha1, 3.2.15
    • None
    • None
    • None

    Description

      It is not possible to obtain VirtualFile (and by extensions it's physicalFile) instance wrapped in VirtualFileURLConnection without using reflection.

      Code snippet from Drools [1], where they try to get hold of VirtualFile#getPhysicalFile():

          private static Object findVirtualFile( URL url ) throws IOException {
              URLConnection urlConnection = url.openConnection();
              try {
                  if ( urlConnection.getClass().getName().equals( "org.jboss.vfs.protocol.VirtualFileURLConnection" ) ) {
                      Field f = urlConnection.getClass().getDeclaredField( "file" );
                      f.setAccessible( true );
                      return f.get( urlConnection );
                  }
              } catch (NoSuchFieldException | IllegalAccessException e) {
                  // ignored
              }
              return urlConnection.getContent();
          }
      

      [1] https://github.com/kiegroup/drools/commit/2a36f67a29ed06d0f980a60ff1c81fa897e8147a

      Attachments

        Issue Links

          Activity

            People

              thofman Tomas Hofman
              thofman Tomas Hofman
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: