home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / Notes.jar / lotus / notes / NotesThread.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-15  |  4.0 KB  |  179 lines

  1. package lotus.notes;
  2.  
  3. public class NotesThread extends Thread {
  4.    boolean initialized;
  5.    Runnable target;
  6.  
  7.    private static synchronized native void NnotesInitThread();
  8.  
  9.    private static synchronized native void NnotesTermThread();
  10.  
  11.    private static synchronized native void NnotesLoad(boolean var0);
  12.  
  13.    public NotesThread() {
  14.    }
  15.  
  16.    public NotesThread(Runnable var1) {
  17.       super(var1);
  18.       this.target = var1;
  19.    }
  20.  
  21.    public NotesThread(String var1) {
  22.       super(var1);
  23.    }
  24.  
  25.    public NotesThread(Runnable var1, String var2) {
  26.       super(var1, var2);
  27.       this.target = var1;
  28.    }
  29.  
  30.    public NotesThread(ThreadGroup var1, String var2) {
  31.       super(var1, var2);
  32.    }
  33.  
  34.    public NotesThread(ThreadGroup var1, Runnable var2, String var3) {
  35.       super(var1, var2, var3);
  36.       this.target = var2;
  37.    }
  38.  
  39.    public NotesThread(ThreadGroup var1, Runnable var2) {
  40.       super(var1, var2);
  41.       this.target = var2;
  42.    }
  43.  
  44.    static AgentThreadGroup getAgentThreadGroup() {
  45.       ThreadGroup var0;
  46.       for(var0 = Thread.currentThread().getThreadGroup(); var0 != null && !(var0 instanceof AgentThreadGroup); var0 = var0.getParent()) {
  47.       }
  48.  
  49.       return (AgentThreadGroup)var0;
  50.    }
  51.  
  52.    private static void bumpActiveNotesThreadCount(int var0) {
  53.       AgentThreadGroup var1 = getAgentThreadGroup();
  54.       if (var1 != null) {
  55.          var1.bumpActiveNotesThreadCount(var0);
  56.       }
  57.  
  58.    }
  59.  
  60.    public void initThread() {
  61.       if (!this.initialized) {
  62.          bumpActiveNotesThreadCount(1);
  63.          NnotesInitThread();
  64.          this.initialized = true;
  65.       }
  66.  
  67.    }
  68.  
  69.    public void termThread() {
  70.       if (this.initialized) {
  71.          NnotesTermThread();
  72.          bumpActiveNotesThreadCount(-1);
  73.          this.initialized = false;
  74.       }
  75.  
  76.    }
  77.  
  78.    public static void sinitThread() {
  79.       bumpActiveNotesThreadCount(1);
  80.       NnotesInitThread();
  81.    }
  82.  
  83.    public static void stermThread() {
  84.       NnotesTermThread();
  85.       bumpActiveNotesThreadCount(-1);
  86.    }
  87.  
  88.    public final void run() {
  89.       if (!this.initialized) {
  90.          this.initThread();
  91.       }
  92.  
  93.       try {
  94.          if (this.target != null) {
  95.             this.target.run();
  96.          } else {
  97.             this.runNotes();
  98.          }
  99.       } catch (NotesException var6) {
  100.          ((Throwable)var6).printStackTrace();
  101.       } finally {
  102.          this.termThread();
  103.       }
  104.  
  105.    }
  106.  
  107.    public void runNotes() throws NotesException {
  108.    }
  109.  
  110.    public void finalize() {
  111.       if (this.initialized) {
  112.          System.out.println(JavaString.getFormattedString("thread_not_terminated", ((Thread)this).toString()));
  113.       }
  114.  
  115.    }
  116.  
  117.    public static void load(boolean var0) throws NotesException {
  118.       try {
  119.          String var1 = System.getProperty("os.name");
  120.          String var2 = System.getProperty("os.arch");
  121.          boolean var3 = Boolean.getBoolean("lotus.notes.internal.InfoPaneBuilder");
  122.          String var5 = null;
  123.          String var6 = "";
  124.          var1 = var1.toUpperCase();
  125.          var2 = var2.toUpperCase();
  126.          if (!var1.equals("WINDOWS NT") && !var1.equals("WINDOWS 95")) {
  127.             if (var1.equals("WINDOWS")) {
  128.                var5 = "_";
  129.             } else if (var1.equals("OS/2")) {
  130.                var5 = "i";
  131.             } else if (var1.equals("AIX")) {
  132.                var5 = "";
  133.                var6 = "_r";
  134.             } else if (var1.equals("SOLARIS")) {
  135.                var5 = "";
  136.             } else if (var1.equals("HPUX")) {
  137.                var5 = "";
  138.             } else if (var1.equals("OS/400")) {
  139.                var5 = "lib";
  140.                String var7 = System.getProperty("lotus.notes.nativecreated");
  141.                if (var7 != null) {
  142.                   var3 = true;
  143.                   if (var7.equalsIgnoreCase("TRUE")) {
  144.                      var3 = true;
  145.                   }
  146.                }
  147.             } else {
  148.                var5 = "";
  149.             }
  150.          } else if (var2.equals("X86")) {
  151.             var5 = "n";
  152.          } else if (var2.equals("ALPHA")) {
  153.             var5 = "a";
  154.          }
  155.  
  156.          if (var5 == null) {
  157.             throw new NotesException(JavaString.getFormattedString("system_dll", var1));
  158.          }
  159.  
  160.          String var4 = var5 + "lsxbe" + var6;
  161.          if (!var3) {
  162.             System.loadLibrary(var4);
  163.             NnotesLoad(var0);
  164.             return;
  165.          }
  166.       } catch (Exception var8) {
  167.          ((Throwable)var8).printStackTrace();
  168.       }
  169.  
  170.    }
  171.  
  172.    static {
  173.       try {
  174.          load(true);
  175.       } catch (Exception var0) {
  176.       }
  177.    }
  178. }
  179.