javacommons/utils/javasrc/com/nokia/mj/impl/rt/support/ApplicationUtils.java
changeset 78 71ad690e91f5
parent 49 35baca0e7a2e
child 80 d6dafc5d983f
--- a/javacommons/utils/javasrc/com/nokia/mj/impl/rt/support/ApplicationUtils.java	Fri Sep 17 16:44:34 2010 +0300
+++ b/javacommons/utils/javasrc/com/nokia/mj/impl/rt/support/ApplicationUtils.java	Mon Oct 04 11:29:25 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.
@@ -236,7 +237,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 +254,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.