javacommons/utils/javasrc/com/nokia/mj/impl/rt/support/ApplicationUtils.java
changeset 80 d6dafc5d983f
parent 78 71ad690e91f5
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 package com.nokia.mj.impl.rt.support;
    18 package com.nokia.mj.impl.rt.support;
    19 
    19 
       
    20 import java.security.AccessControlException;
       
    21 import java.security.Permission;
       
    22 import java.util.Enumeration;
       
    23 import java.util.Vector;
       
    24 
    20 import com.nokia.mj.impl.utils.Uid;
    25 import com.nokia.mj.impl.utils.Uid;
    21 import java.util.Vector;
    26 import com.nokia.mj.impl.utils.Logger;
    22 import java.util.Enumeration;
       
    23 import java.security.Permission;
       
    24 import java.security.AccessControlException;
       
    25 
    27 
    26 /**
    28 /**
    27  * ApplicationUtils is an abstract base class for API implementations,
    29  * ApplicationUtils is an abstract base class for API implementations,
    28  * which allows them to use miscellanous utilities related to the running
    30  * which allows them to use miscellanous utilities related to the running
    29  * application.
    31  * application.
   133         try
   135         try
   134         {
   136         {
   135             Class clazz = Class.forName(className);
   137             Class clazz = Class.forName(className);
   136             sInstance = (ApplicationUtils)clazz.newInstance();
   138             sInstance = (ApplicationUtils)clazz.newInstance();
   137         }
   139         }
   138         catch (Exception e)
   140         catch (Throwable t)
   139         {
   141         {
   140             e.printStackTrace();
   142             String err = "Not able to instantiate class " +
   141             throw new RuntimeException("Not able to instantiate class " +
   143                          className + ". Reason is: ";
   142                                        className+". Reason is: " + e);
   144             Logger.LOG(Logger.EUtils, Logger.EInfo, err, t);
       
   145             throw new RuntimeException(err + t);
   143         }
   146         }
   144     }
   147     }
   145 
   148 
   146     /**
   149     /**
   147      * Returns an instace of ApplicationUtils class which provides access to
   150      * Returns an instace of ApplicationUtils class which provides access to
   187      * runtime dependent.
   190      * runtime dependent.
   188      * <p>
   191      * <p>
   189      * This method is meant ONLY for the UI and no other API are allowed
   192      * This method is meant ONLY for the UI and no other API are allowed
   190      * to use it.
   193      * to use it.
   191      * <p>
   194      * <p>
   192      * It is possible that the method is called several times from different 
   195      * It is possible that the method is called several times from different
   193      * phases of the UI exit sequence. 
   196      * phases of the UI exit sequence.
   194      */
   197      */
   195     public void uiDisposed()
   198     public void uiDisposed()
   196     {
   199     {
   197         notifyExitCmd();
   200         notifyExitCmd();
   198     }
   201     }
   218      *         permitted, based on the current security policy.
   221      *         permitted, based on the current security policy.
   219      * @throws NullPointerException if the specified permission is null.
   222      * @throws NullPointerException if the specified permission is null.
   220      */
   223      */
   221     public abstract void checkPermission(Permission p)
   224     public abstract void checkPermission(Permission p)
   222     throws AccessControlException,
   225     throws AccessControlException,
   223                 NullPointerException;
   226         NullPointerException;
   224 
   227 
   225     public abstract void checkPermission(Uid appUid,Permission p)
   228     public abstract void checkPermission(Uid appUid,Permission p)
   226     throws AccessControlException,
   229     throws AccessControlException,
   227                 NullPointerException;
   230         NullPointerException;
   228 
   231 
   229     /**
   232     /**
   230      * Adds a shutdown notifications listener to receive notifications when
   233      * Adds a shutdown notifications listener to receive notifications when
   231      * the application is about to close.
   234      * the application is about to close.
   232      * <p>
   235      * <p>
   256 
   259 
   257     /**
   260     /**
   258      * Removes the registered shutdown listener.
   261      * Removes the registered shutdown listener.
   259      *
   262      *
   260      * @param listener the listener to be removed. If the listener is not
   263      * @param listener the listener to be removed. If the listener is not
   261      *                 found nothing happens. If the key is null, a 
   264      *                 found nothing happens. If the key is null, a
   262      * @throws NullPointerException if the listener is null.
   265      * @throws NullPointerException if the listener is null.
   263      */
   266      */
   264     public void removeShutdownListener(ShutdownListener listener)
   267     public void removeShutdownListener(ShutdownListener listener)
   265     {
   268     {
   266         if (listener == null)
   269         if (listener == null)
   267         {
   270         {
   268             throw new 
   271             throw new
   269               NullPointerException("Listener was null when trying to remove");
   272             NullPointerException("Listener was null when trying to remove");
   270         }
   273         }
   271         if (mListeners != null)
   274         if (mListeners != null)
   272         {
   275         {
   273             mListeners.removeElement(listener);
   276             mListeners.removeElement(listener);
   274         }
   277         }
   351                 ShutdownListener listener =
   354                 ShutdownListener listener =
   352                     (ShutdownListener)enumer.nextElement();
   355                     (ShutdownListener)enumer.nextElement();
   353                 listener.shuttingDown();
   356                 listener.shuttingDown();
   354             }
   357             }
   355         }
   358         }
       
   359         mListeners = null;
   356     }
   360     }
   357 }
   361 }