home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / netscape / applet / MozillaAppletContext.class (.txt) < prev   
Encoding:
Java Class File  |  1996-10-20  |  16.4 KB  |  703 lines

  1. package netscape.applet;
  2.  
  3. import java.applet.Applet;
  4. import java.applet.AppletContext;
  5. import java.applet.AudioClip;
  6. import java.awt.Image;
  7. import java.awt.Toolkit;
  8. import java.awt.Window;
  9. import java.io.PrintStream;
  10. import java.net.MalformedURLException;
  11. import java.net.URL;
  12. import java.util.Enumeration;
  13. import java.util.Hashtable;
  14. import java.util.Vector;
  15. import netscape.net.URLStreamHandlerFactory;
  16. import sun.awt.image.URLImageSource;
  17.  
  18. class MozillaAppletContext implements AppletContext {
  19.    int frameMWContext;
  20.    Mapping appletFrames;
  21.    Hashtable imageCache;
  22.    Hashtable audioClipCache;
  23.    URL documentURL;
  24.    Integer contextID;
  25.    static Console console;
  26.    static int totalApplets;
  27.    static int trimThreshold;
  28.    static boolean noisyTrimming;
  29.    static Mapping appletContexts = new Mapping();
  30.    static int debug;
  31.  
  32.    MozillaAppletContext(Integer contextID) {
  33.       this.contextID = contextID;
  34.       this.appletFrames = new Mapping();
  35.       this.imageCache = new Hashtable();
  36.       this.audioClipCache = new Hashtable();
  37.    }
  38.  
  39.    static void indent(PrintStream out, int i) {
  40.       while(true) {
  41.          --i;
  42.          if (i < 0) {
  43.             return;
  44.          }
  45.  
  46.          out.print(" ");
  47.       }
  48.    }
  49.  
  50.    void dumpState(PrintStream out, int i) {
  51.       indent(out, i);
  52.       out.println("MozillaAppletContext #frames=" + this.appletFrames.size() + " #images=" + this.imageCache.size() + " #audioClips=" + this.audioClipCache.size() + " url=" + this.documentURL);
  53.       int size = this.appletFrames.size();
  54.  
  55.       for(int j = 0; j < size; ++j) {
  56.          EmbeddedAppletFrame eaf = (EmbeddedAppletFrame)this.appletFrames.elementAt(j);
  57.          eaf.dumpState(out, i + 1);
  58.       }
  59.  
  60.       if (this.imageCache.size() > 0) {
  61.          indent(out, i + 1);
  62.          out.println("image cache:");
  63.          Enumeration e = this.imageCache.keys();
  64.  
  65.          while(e.hasMoreElements()) {
  66.             URL u = (URL)e.nextElement();
  67.             indent(out, i + 2);
  68.             out.println(u.toString());
  69.          }
  70.       }
  71.  
  72.       if (this.audioClipCache.size() > 0) {
  73.          indent(out, i + 1);
  74.          out.println("audio clip cache:");
  75.          Enumeration e = this.audioClipCache.keys();
  76.  
  77.          while(e.hasMoreElements()) {
  78.             URL u = (URL)e.nextElement();
  79.             indent(out, i + 2);
  80.             out.println(u.toString());
  81.          }
  82.       }
  83.  
  84.    }
  85.  
  86.    void destroy() {
  87.       if (debug > 0) {
  88.          System.err.println("#   destroy acx=" + this + " frameMWContext=" + this.frameMWContext);
  89.       }
  90.  
  91.       this.destroyApplets();
  92.       this.frameMWContext = 0;
  93.       this.appletFrames = null;
  94.       this.imageCache = null;
  95.       this.audioClipCache = null;
  96.       appletContexts.remove(this.contextID);
  97.    }
  98.  
  99.    public AudioClip getAudioClip(URL url) {
  100.       AudioClip clip = lookupAudioClip(this, url);
  101.       return clip;
  102.    }
  103.  
  104.    public Image getImage(URL url) {
  105.       Image img = lookupImage(this, url);
  106.       return img;
  107.    }
  108.  
  109.    public Applet getApplet(String name) {
  110.       int size = this.appletFrames.size();
  111.  
  112.       for(int i = 0; i < size; ++i) {
  113.          EmbeddedAppletFrame frame = (EmbeddedAppletFrame)this.appletFrames.elementAt(i);
  114.          if (name.equals(frame.applet.getParameter("name"))) {
  115.             return frame.applet;
  116.          }
  117.       }
  118.  
  119.       return null;
  120.    }
  121.  
  122.    public Enumeration getApplets() {
  123.       int size = this.appletFrames.size();
  124.       Vector v = new Vector(size);
  125.  
  126.       for(int i = 0; i < size; ++i) {
  127.          EmbeddedAppletFrame frame = (EmbeddedAppletFrame)this.appletFrames.elementAt(i);
  128.          v.addElement(frame.applet);
  129.       }
  130.  
  131.       return v.elements();
  132.    }
  133.  
  134.    public void showDocument(URL url) {
  135.       this.showDocument(url, "_top");
  136.    }
  137.  
  138.    public void showDocument(URL url, String target) {
  139.       this.pShowDocument(url.toExternalForm(), (String)null, target);
  140.    }
  141.  
  142.    public void showStatus(String status) {
  143.       this.pShowStatus(status);
  144.    }
  145.  
  146.    public void mochaOnLoad(int result) {
  147.       this.pMochaOnLoad(result);
  148.    }
  149.  
  150.    private native void pShowDocument(String var1, String var2, String var3);
  151.  
  152.    private native void pShowStatus(String var1);
  153.  
  154.    private native void pMochaOnLoad(int var1);
  155.  
  156.    static synchronized AudioClip lookupAudioClip(MozillaAppletContext incx, URL url) {
  157.       int size = appletContexts.size();
  158.  
  159.       for(int i = 0; i < size; ++i) {
  160.          MozillaAppletContext acx = (MozillaAppletContext)appletContexts.elementAt(i);
  161.          Object clip = acx.audioClipCache.get(url);
  162.          if (clip != null) {
  163.             return (AudioClip)clip;
  164.          }
  165.       }
  166.  
  167.       AudioClip clip = new AppletAudioClip(url);
  168.       incx.audioClipCache.put(url, clip);
  169.       if (debug > 0) {
  170.          System.err.println("# New audio clip: " + url);
  171.       }
  172.  
  173.       return clip;
  174.    }
  175.  
  176.    static synchronized Image lookupImage(MozillaAppletContext incx, URL url) {
  177.       int size = appletContexts.size();
  178.  
  179.       for(int i = 0; i < size; ++i) {
  180.          MozillaAppletContext acx = (MozillaAppletContext)appletContexts.elementAt(i);
  181.          Object image = acx.imageCache.get(url);
  182.          if (image != null) {
  183.             return (Image)image;
  184.          }
  185.       }
  186.  
  187.       Image image;
  188.       try {
  189.          URLImageSource source = new URLImageSource(url);
  190.          image = Toolkit.getDefaultToolkit().createImage(source);
  191.          incx.imageCache.put(url, image);
  192.          if (debug > 0) {
  193.             System.err.println("# New image: " + url);
  194.          }
  195.       } catch (Exception var6) {
  196.          image = null;
  197.       }
  198.  
  199.       return image;
  200.    }
  201.  
  202.    synchronized void initApplet(int appletID, String docURL, Hashtable params) {
  203.       if (debug > 0) {
  204.          System.err.println("#   initApplet: appletID=" + appletID);
  205.       }
  206.  
  207.       try {
  208.          this.documentURL = new URL(docURL);
  209.       } catch (MalformedURLException var17) {
  210.          if (debug > 0) {
  211.             System.err.println("#     Malformed documentURL: " + docURL);
  212.          }
  213.  
  214.          this.mochaOnLoad(-1);
  215.          return;
  216.       }
  217.  
  218.       String codebase = (String)params.get("codebase");
  219.       if (codebase == null) {
  220.          int tail = docURL.lastIndexOf(47) + 1;
  221.          codebase = docURL.substring(0, tail);
  222.       } else {
  223.          if (!codebase.endsWith("/")) {
  224.             codebase = codebase + "/";
  225.          }
  226.  
  227.          try {
  228.             URL u = new URL(this.documentURL, codebase);
  229.             codebase = u.toString();
  230.             int tail = codebase.lastIndexOf(47) + 1;
  231.             if (tail != codebase.length() - 1) {
  232.                codebase = codebase.substring(0, tail);
  233.             }
  234.          } catch (MalformedURLException var16) {
  235.          }
  236.  
  237.          if (!docURL.startsWith("file:") && codebase.startsWith("file:")) {
  238.             throw new AppletSecurityException("AppletContext: Can't use file:// URL in CODEBASE spec", codebase);
  239.          }
  240.       }
  241.  
  242.       params.put("codebase", codebase);
  243.       URL codebaseURL = this.documentURL;
  244.  
  245.       try {
  246.          codebaseURL = new URL(codebase);
  247.       } catch (MalformedURLException var15) {
  248.       }
  249.  
  250.       String archive = (String)params.get("archive");
  251.       if (archive == null) {
  252.          int tail = docURL.lastIndexOf(47) + 1;
  253.          archive = docURL.substring(0, tail);
  254.       } else {
  255.          try {
  256.             int commaIndex = archive.indexOf(44);
  257.             if (commaIndex != -1) {
  258.                archive = archive.substring(0, commaIndex);
  259.             }
  260.  
  261.             URL u = new URL(codebaseURL, archive);
  262.             archive = u.toString();
  263.          } catch (MalformedURLException var14) {
  264.          }
  265.       }
  266.  
  267.       params.put("archive", archive);
  268.       URL archiveURL = codebaseURL;
  269.  
  270.       try {
  271.          archiveURL = new URL(archive);
  272.       } catch (MalformedURLException var13) {
  273.       }
  274.  
  275.       Integer frameKey = new Integer(appletID);
  276.       EmbeddedAppletFrame frame = new EmbeddedAppletFrame(this.documentURL, codebaseURL, archiveURL, params, this, frameKey);
  277.       this.appletFrames.put(frameKey, frame);
  278.       ++totalApplets;
  279.       if (debug > 0) {
  280.          System.err.println("#     total applets=" + totalApplets);
  281.       }
  282.  
  283.       if (debug > 0) {
  284.          String p = "";
  285.  
  286.          Object key;
  287.          for(Enumeration e = params.keys(); e.hasMoreElements(); p = p + (String)key + "=" + (String)params.get(key) + " ") {
  288.             key = e.nextElement();
  289.          }
  290.  
  291.          System.err.println("#     New applet: " + appletID + " at " + codebaseURL + " " + p);
  292.       }
  293.  
  294.       frame.start();
  295.       ((Window)frame).pack();
  296.       ((Window)frame).show();
  297.       frame.sendEvent(1);
  298.       frame.sendEvent(2);
  299.    }
  300.  
  301.    EmbeddedAppletFrame getAppletFrame(Integer appletID) {
  302.       EmbeddedAppletFrame frame = (EmbeddedAppletFrame)this.appletFrames.get(appletID);
  303.       if (frame == null && debug > 0) {
  304.          System.err.println("#   Warning: AppletFrame not found for appletID " + appletID);
  305.       }
  306.  
  307.       return frame;
  308.    }
  309.  
  310.    synchronized void startApplet(int appletID) {
  311.       if (debug > 0) {
  312.          System.err.println("#   startApplet: appletID=" + appletID);
  313.       }
  314.  
  315.       EmbeddedAppletFrame frame = this.getAppletFrame(new Integer(appletID));
  316.       if (frame == null) {
  317.          System.err.println("---> applet must have been pruned: " + appletID + " on " + this.documentURL);
  318.       } else {
  319.          frame.inHistory = false;
  320.          frame.sendEvent(3);
  321.       }
  322.    }
  323.  
  324.    synchronized void stopApplet(int appletID) {
  325.       if (debug > 0) {
  326.          System.err.println("#   stopApplet: appletID=" + appletID);
  327.       }
  328.  
  329.       EmbeddedAppletFrame frame = this.getAppletFrame(new Integer(appletID));
  330.       if (frame != null) {
  331.          frame.inHistory = true;
  332.          frame.sendEvent(4);
  333.          trimApplets();
  334.       }
  335.    }
  336.  
  337.    synchronized void destroyApplet(Integer appletID) {
  338.       if (noisyTrimming && debug > 0) {
  339.          System.err.println("#   destroyApplet: appletID=" + appletID);
  340.       }
  341.  
  342.       EmbeddedAppletFrame frame = this.getAppletFrame(appletID);
  343.       if (frame != null) {
  344.          --totalApplets;
  345.          if (noisyTrimming && debug > 0) {
  346.             System.err.println("#     total applets=" + totalApplets);
  347.          }
  348.  
  349.          if (!noisyTrimming) {
  350.             frame.noisy = false;
  351.          }
  352.  
  353.          this.appletFrames.remove(appletID);
  354.          ThreadGroup group = frame.handler.getThreadGroup();
  355.          synchronized(group){}
  356.  
  357.          try {
  358.             frame.sendEvent(4);
  359.             frame.sendEvent(5);
  360.             frame.sendEvent(0);
  361.  
  362.             try {
  363.                group.wait(1000L);
  364.             } catch (InterruptedException var11) {
  365.             }
  366.  
  367.             if (group.activeCount() > 0) {
  368.                SecurityManager.setScopePermission();
  369.                group.stop();
  370.                SecurityManager.resetScopePermission();
  371.  
  372.                try {
  373.                   group.wait(10000L);
  374.                } catch (InterruptedException var10) {
  375.                }
  376.             }
  377.  
  378.             try {
  379.                SecurityManager.setScopePermission();
  380.                group.destroy();
  381.                SecurityManager.resetScopePermission();
  382.             } catch (Exception var9) {
  383.             }
  384.          } catch (Throwable var12) {
  385.             throw var12;
  386.          }
  387.  
  388.       }
  389.    }
  390.  
  391.    synchronized void iconifyApplets() {
  392.       if (debug > 0) {
  393.          System.err.println("#   iconifyApplets");
  394.       }
  395.  
  396.       int size = this.appletFrames.size();
  397.  
  398.       for(int i = 0; i < size; ++i) {
  399.          EmbeddedAppletFrame frame = (EmbeddedAppletFrame)this.appletFrames.elementAt(i);
  400.          if (debug > 0) {
  401.             System.err.println("#     iconifyApplets: stopping appletID " + frame.pData);
  402.          }
  403.  
  404.          frame.sendEvent(4);
  405.       }
  406.  
  407.    }
  408.  
  409.    synchronized void uniconifyApplets() {
  410.       if (debug > 0) {
  411.          System.err.println("#   uniconifyApplets");
  412.       }
  413.  
  414.       int size = this.appletFrames.size();
  415.  
  416.       for(int i = 0; i < size; ++i) {
  417.          EmbeddedAppletFrame frame = (EmbeddedAppletFrame)this.appletFrames.elementAt(i);
  418.          if (debug > 0) {
  419.             System.err.println("#     uniconifyApplets: starting appletID " + frame.pData);
  420.          }
  421.  
  422.          frame.sendEvent(3);
  423.       }
  424.  
  425.    }
  426.  
  427.    synchronized Object reflectApplet(int appletID) {
  428.       if (debug > 0) {
  429.          System.err.println("#   reflectApplet: appletID=" + appletID);
  430.       }
  431.  
  432.       EmbeddedAppletFrame frame = this.getAppletFrame(new Integer(appletID));
  433.       return frame == null ? null : frame.applet;
  434.    }
  435.  
  436.    synchronized void destroyApplets() {
  437.       if (debug > 0) {
  438.          System.err.println("#   destroyApplets");
  439.       }
  440.  
  441.       int size = this.appletFrames.size();
  442.  
  443.       for(int i = size - 1; i >= 0; --i) {
  444.          Integer frame = (Integer)this.appletFrames.keyAt(i);
  445.          this.destroyApplet(frame);
  446.       }
  447.  
  448.    }
  449.  
  450.    static void init() {
  451.       console = new Console();
  452.       System.setProperties(new AppletProperties());
  453.       URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory());
  454.       System.setSecurityManager(new AppletSecurity());
  455.    }
  456.  
  457.    static void setConsoleState(int newstate) {
  458.       setConsoleState0(newstate);
  459.    }
  460.  
  461.    static native void setConsoleState0(int var0);
  462.  
  463.    static void showConsole() {
  464.       console.show();
  465.    }
  466.  
  467.    static void hideConsole() {
  468.       console.hide();
  469.    }
  470.  
  471.    static int trimApplets(int numberToTrim, boolean trimOnlyStoppedApplets) {
  472.       int numberTrimmed = trimApplets1(numberToTrim, true);
  473.       if (numberTrimmed < numberToTrim && !trimOnlyStoppedApplets) {
  474.          numberTrimmed += trimApplets1(numberToTrim - numberTrimmed, false);
  475.       }
  476.  
  477.       return numberTrimmed;
  478.    }
  479.  
  480.    static int trimApplets1(int numberToTrim, boolean trimOnlyStoppedApplets) {
  481.       int numberTrimmed;
  482.       for(numberTrimmed = 0; numberToTrim-- > 0; ++numberTrimmed) {
  483.          long oldestTime = -1L;
  484.          EmbeddedAppletFrame oldestFrame = null;
  485.          MozillaAppletContext contextOfOldest = null;
  486.          int size = appletContexts.size();
  487.  
  488.          for(int i = 0; i < size; ++i) {
  489.             MozillaAppletContext acx = (MozillaAppletContext)appletContexts.elementAt(i);
  490.             int size2 = acx.appletFrames.size();
  491.  
  492.             for(int j = 0; j < size2; ++j) {
  493.                EmbeddedAppletFrame frame = (EmbeddedAppletFrame)acx.appletFrames.elementAt(j);
  494.                if ((!trimOnlyStoppedApplets || frame.inHistory) && (oldestTime == -1L || frame.timestamp < oldestTime)) {
  495.                   oldestTime = frame.timestamp;
  496.                   oldestFrame = frame;
  497.                   contextOfOldest = acx;
  498.                }
  499.             }
  500.          }
  501.  
  502.          if (oldestFrame == null) {
  503.             if (noisyTrimming && debug > 0) {
  504.                System.err.println("# No stopped applets to prune.");
  505.             }
  506.  
  507.             return numberTrimmed;
  508.          }
  509.  
  510.          try {
  511.             if (noisyTrimming) {
  512.                Applet applet = oldestFrame.applet;
  513.                String name = null;
  514.                if (applet != null) {
  515.                   name = applet.getParameter("name");
  516.                }
  517.  
  518.                if (name == null) {
  519.                   name = applet.getClass().getName().toString();
  520.                }
  521.  
  522.                System.err.println("# Pruning applet " + name + " from " + contextOfOldest.documentURL + " to save memory.");
  523.                if (debug > 0) {
  524.                   System.err.println("#   Pruning appletID=" + oldestFrame.pData + " contextID=" + contextOfOldest.contextID + " applet=" + oldestFrame.applet);
  525.                }
  526.             }
  527.          } catch (Throwable var14) {
  528.          }
  529.  
  530.          try {
  531.             contextOfOldest.destroyApplet(oldestFrame.appletID);
  532.          } catch (Throwable var13) {
  533.          }
  534.       }
  535.  
  536.       return numberTrimmed;
  537.    }
  538.  
  539.    static void trimApplets() {
  540.       trimApplets(totalApplets - trimThreshold, true);
  541.    }
  542.  
  543.    static MozillaAppletContext getAppletContext(int contextID) {
  544.       Integer key = new Integer(contextID);
  545.       MozillaAppletContext context = (MozillaAppletContext)appletContexts.get(key);
  546.       if (context == null && debug > 0) {
  547.          System.err.println("# Warning: applet context not found for contextID " + contextID);
  548.       }
  549.  
  550.       return context;
  551.    }
  552.  
  553.    static MozillaAppletContext ensureAppletContext(int contextID) {
  554.       Integer key = new Integer(contextID);
  555.       MozillaAppletContext context = (MozillaAppletContext)appletContexts.get(key);
  556.       if (context == null) {
  557.          context = new MozillaAppletContext(key);
  558.          appletContexts.put(key, context);
  559.       }
  560.  
  561.       return context;
  562.    }
  563.  
  564.    static void initApplet(int parentContext, int frameContext, int contextID, int appletID, String[] argv) {
  565.       Hashtable params = new Hashtable();
  566.  
  567.       for(int i = 1; i < argv.length; ++i) {
  568.          String str = argv[i];
  569.          int j = str.indexOf(61);
  570.          if (j >= 0) {
  571.             params.put(str.substring(0, j).toLowerCase(), str.substring(j + 1));
  572.          }
  573.       }
  574.  
  575.       String dbg = (String)params.get("debug");
  576.       if (dbg != null) {
  577.          try {
  578.             debug = Integer.parseInt(dbg);
  579.          } catch (Exception var9) {
  580.          }
  581.       }
  582.  
  583.       if (debug > 0) {
  584.          System.err.println("# initApplet: contextID=" + contextID + " appletID=" + appletID + " parentContext=" + parentContext + " frameContext=" + frameContext);
  585.       }
  586.  
  587.       trimApplets();
  588.       MozillaAppletContext acx = ensureAppletContext(contextID);
  589.       acx.frameMWContext = frameContext;
  590.       acx.initApplet(appletID, argv[0], params);
  591.    }
  592.  
  593.    static void startApplet(int contextID, int appletID, int newFrameMWContext) {
  594.       if (debug > 0) {
  595.          System.err.println("# startApplet: contextID=" + contextID + " appletID=" + appletID + " newFrameMWContext=" + newFrameMWContext);
  596.       }
  597.  
  598.       MozillaAppletContext acx = getAppletContext(contextID);
  599.       if (acx != null) {
  600.          acx.frameMWContext = newFrameMWContext;
  601.          acx.startApplet(appletID);
  602.       }
  603.    }
  604.  
  605.    static void stopApplet(int contextID, int appletID) {
  606.       if (debug > 0) {
  607.          System.err.println("# stopApplet: contextID=" + contextID + " appletID=" + appletID);
  608.       }
  609.  
  610.       MozillaAppletContext acx = getAppletContext(contextID);
  611.       if (acx != null) {
  612.          acx.frameMWContext = 0;
  613.          acx.stopApplet(appletID);
  614.          trimApplets();
  615.       }
  616.    }
  617.  
  618.    static void destroyApplet(int contextID, int appletID) {
  619.       if (debug > 0) {
  620.          System.err.println("# destroyApplet: contextID=" + contextID + " appletID=" + appletID);
  621.       }
  622.  
  623.       MozillaAppletContext acx = getAppletContext(contextID);
  624.       if (acx != null) {
  625.          acx.destroyApplet(new Integer(appletID));
  626.          if (acx.appletFrames.isEmpty()) {
  627.             if (debug > 0) {
  628.                System.err.println("#   destroyApplet: destroying context for contextID " + contextID);
  629.             }
  630.  
  631.             acx.destroy();
  632.          }
  633.  
  634.       }
  635.    }
  636.  
  637.    static Object reflectApplet(int contextID, int appletID) {
  638.       if (debug > 0) {
  639.          System.err.println("# reflectApplet: contextID=" + contextID + " appletID=" + appletID);
  640.       }
  641.  
  642.       MozillaAppletContext acx = getAppletContext(contextID);
  643.       return acx == null ? null : acx.reflectApplet(appletID);
  644.    }
  645.  
  646.    static void iconifyApplets(int contextID) {
  647.       if (debug > 0) {
  648.          System.err.println("# iconifyApplets: contextID=" + contextID);
  649.       }
  650.  
  651.       MozillaAppletContext acx = getAppletContext(contextID);
  652.       if (acx != null) {
  653.          acx.iconifyApplets();
  654.       }
  655.    }
  656.  
  657.    static void uniconifyApplets(int contextID) {
  658.       if (debug > 0) {
  659.          System.err.println("# uniconifyApplets: contextID=" + contextID);
  660.       }
  661.  
  662.       MozillaAppletContext acx = getAppletContext(contextID);
  663.       if (acx != null) {
  664.          acx.uniconifyApplets();
  665.       }
  666.    }
  667.  
  668.    static void destroyApplets(int contextID) {
  669.       if (debug > 0) {
  670.          System.err.println("# destroyApplets: contextID=" + contextID);
  671.       }
  672.  
  673.       MozillaAppletContext acx = getAppletContext(contextID);
  674.       if (acx != null) {
  675.          acx.destroy();
  676.       }
  677.    }
  678.  
  679.    static void destroyAll() {
  680.       if (debug > 0) {
  681.          System.err.println("# destroyAll");
  682.       }
  683.  
  684.       int size = appletContexts.size();
  685.  
  686.       for(int i = size - 1; i >= 0; --i) {
  687.          MozillaAppletContext acx = (MozillaAppletContext)appletContexts.elementAt(i);
  688.          acx.destroy();
  689.       }
  690.  
  691.    }
  692.  
  693.    static void dumpState(PrintStream out) {
  694.       int size = appletContexts.size();
  695.  
  696.       for(int i = 0; i < size; ++i) {
  697.          MozillaAppletContext acx = (MozillaAppletContext)appletContexts.elementAt(i);
  698.          acx.dumpState(out, 0);
  699.       }
  700.  
  701.    }
  702. }
  703.