Logo Search packages:      
Sourcecode: icedtea-web version File versions  Download package

void net::sourceforge::jnlp::runtime::JNLPClassLoader::activateNative ( JARDesc  jar  )  [inline, protected]

Search for and enable any native code contained in a JAR by copying the native files into the filesystem. Called in the security context of the classloader.

Definition at line 772 of file JNLPClassLoader.java.

References net::sourceforge::jnlp::cache::ResourceTracker::getCacheFile(), net::sourceforge::jnlp::JARDesc::getLocation(), getNativeDir(), nativeDir, and tracker.

Referenced by activateJars().

                                               {
        if (JNLPRuntime.isDebug())
            System.out.println("Activate native: "+jar.getLocation());

        File localFile = tracker.getCacheFile(jar.getLocation());
        if (localFile == null)
            return;

        String[] librarySuffixes = { ".so", ".dylib", ".jnilib", ".framework", ".dll" };

        try {
            JarFile jarFile = new JarFile(localFile, false);
            Enumeration<JarEntry> entries = jarFile.entries();

            while (entries.hasMoreElements()) {
                JarEntry e = entries.nextElement();

                if (e.isDirectory()) {
                    continue;
                }

                String name = new File(e.getName()).getName();
                boolean isLibrary = false;

                for (String suffix: librarySuffixes) {
                    if (name.endsWith(suffix)) {
                       isLibrary = true;
                       break;
                    }
                }
                if (!isLibrary) {
                    continue;
                }

                if (nativeDir == null)
                    nativeDir = getNativeDir();

                File outFile = new File(nativeDir, name);

                CacheUtil.streamCopy(jarFile.getInputStream(e),
                                     new FileOutputStream(outFile));

            }
        }
        catch (IOException ex) {
            if (JNLPRuntime.isDebug())
                ex.printStackTrace();
        }
    }


Generated by  Doxygen 1.6.0   Back to index