1 21 22 package com.coi.tools.os.izpack; 23 24 import com.izforge.izpack.util.Librarian; 25 import com.izforge.izpack.util.NativeLibraryClient; 26 27 35 public class COIOSHelper 36 { 37 38 private static COIOSHelper self = null; 39 40 private static int used = 0; 41 42 private static boolean destroyed = false; 43 44 51 private native void FreeLibrary(String name); 52 53 56 private COIOSHelper() 57 { 58 super(); 59 } 60 61 66 public static synchronized COIOSHelper getInstance() 67 { 68 if (self == null) self = new COIOSHelper(); 69 return (self); 70 71 } 72 73 74 89 90 93 public void freeLibrary(String name) 94 { 95 used--; 96 if (!destroyed) 97 { 98 FreeLibrary(name); 99 destroyed = true; 100 } 101 } 102 103 110 public void addDependant(NativeLibraryClient dependant) throws Exception 111 { 112 used++; 113 try 114 { 115 Librarian.getInstance().loadLibrary("COIOSHelper", dependant); 116 } 117 catch (UnsatisfiedLinkError exception) 118 { 119 throw (new Exception ("could not locate native library")); 120 } 121 122 } 123 124 } 125 | Popular Tags |