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

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