javacommons/utils/javasrc/com/nokia/mj/impl/rt/support/ApplicationUtils.java
branchRCL_3
changeset 83 26b2b12093af
parent 60 6c158198356e
--- a/javacommons/utils/javasrc/com/nokia/mj/impl/rt/support/ApplicationUtils.java	Wed Sep 15 12:05:25 2010 +0300
+++ b/javacommons/utils/javasrc/com/nokia/mj/impl/rt/support/ApplicationUtils.java	Wed Oct 13 14:23:59 2010 +0300
@@ -45,11 +45,12 @@
  * package com.nokia.mj.impl.mypackage;
  *
  * import com.nokia.mj.impl.rt.support.ApplicationUtils;
- *      public void myClass()
+ * import com.nokia.mj.impl.rt.support.ShutdownListener;
+ *      public MyClass
  *      {
  *          public void myMethod()
  *          {
- *              // Get the insatnce of ApplicationUtils.
+ *              // Get the instance of ApplicationUtils.
  *              ApplicationUtils appUtils = ApplicationUtils.getInstance();
  *
  *              // Get the name of the application.
@@ -162,14 +163,11 @@
      * <p>
      * This method is meant ONLY for the UI and no other API are allowed
      * to use it. The UI must use this API ONLY when the user explicitly
-     * wants to close the application using some platform dependent feature
+     * wants to close the application using some platform depedent feataure
      * (e.g. red key in S60). If the user tries to close the application
      * using the mechanism provided by the application itself, this method
      * must not be called.
      * <p>
-     * Note that calling this method might cause the UI framework to call
-     * uiDisposed method, depending on which UI framework is used.
-     * <p>
      * This method is a problematic in such runtimes that may run more than one
      * application in same JVM instance (e.g. eRCP). If the application
      * doesn't close nicely the runtime may have to terminate
@@ -180,23 +178,6 @@
     public abstract void notifyExitCmd();
 
     /**
-     * Notifies the runtime that UI has been disposed. The runtime is
-     * responsible for killing the application if it doesn't close itself
-     * nicely after specified grace time. The specified grace time is
-     * runtime dependent.
-     * <p>
-     * This method is meant ONLY for the UI and no other API are allowed
-     * to use it.
-     * <p>
-     * It is possible that the method is called several times from different 
-     * phases of the UI exit sequence. 
-     */
-    public void uiDisposed()
-    {
-        notifyExitCmd();
-    }
-
-    /**
      * Determines whether the access request indicated by the specified
      * permission should be allowed or denied, based on the security policy
      * currently in effect. This method quietly returns if the access request
@@ -236,7 +217,11 @@
      * calls are made in a loop in one thread, so if some listener blocks the
      * call the rest of the listeners don't get the notification.
      * <p>
-     * There can be more than one listener.
+     * There can be more than one listener, but it is recommended that there
+     * is only one listener per component.
+     * <p>
+     * The implementation stores a strong reference to object which prevents
+     * garbage collection of the listener unless the listener is removed.
      *
      * @param listener the new listener.
      */
@@ -249,6 +234,25 @@
         mListeners.addElement(listener);
     }
 
+    /**
+     * Removes the registered shutdown listener.
+     *
+     * @param listener the listener to be removed. If the listener is not
+     *                 found nothing happens. If the key is null, a 
+     * @throws NullPointerException if the listener is null.
+     */
+    public void removeShutdownListener(ShutdownListener listener)
+    {
+        if (listener == null)
+        {
+            throw new 
+              NullPointerException("Listener was null when trying to remove");
+        }
+        if (mListeners != null)
+        {
+            mListeners.removeElement(listener);
+        }
+    }
 
     /**
      * Waits (if needed) until the application to be started is known.