Exemplo n.º 1
0
 /**
  * Notify registered listeners about mount/unmount event.
  *
  * @param event root added or removed event
  * @param root pathname of the root file system
  */
 private static void notifyListeners(int event, String root) {
   for (int i = 0; i < fileSystemListeners.size(); i++) {
     try {
       ((FileSystemListener) fileSystemListeners.elementAt(i)).rootChanged(event, root);
     } catch (Throwable t) {
       t.printStackTrace();
     }
   }
 }
  /**
   * Handles exceptions happened during MIDlet suite execution.
   *
   * @param t exception instance
   */
  public void handleException(Throwable t) {
    t.printStackTrace();
    int errorCode = getErrorCode(t);

    if (Logging.TRACE_ENABLED) {
      Logging.trace(t, "Exception caught in CdcMIDletSuiteLoader");
    }

    reportError(errorCode, t.getMessage());
  }
  /**
   * Called at the initial start of the VM. Initializes internal security and any other AMS classes
   * related classes before starting the MIDlet.
   *
   * @param args arg[0] the suite ID (-1=rommized MIDlet), arg[1] the class name of the MIDlet,
   *     arg[2-n] optional MIDlet args, the first labled arg-0, then second arg-1, etc
   */
  public static void main(String args[]) {
    try {
      CDCInit.init();

      CdcMIDletSuiteLoader loader = new CdcMIDletSuiteLoader();

      if (args.length < 1) {
        System.err.println("The suite ID for the " + "MIDlet suite was not given");
        throw new IllegalArgumentException("Suite ID absent");
      }

      try {
        loader.suiteId = Integer.parseInt(args[0]);
      } catch (Throwable t) {
        throw new IllegalArgumentException("Suite ID: " + t.getMessage());
      }

      if (args.length < 2) {
        System.err.println("The class name for the " + "MIDlet was not given");
        throw new IllegalArgumentException("MIDlet class name absent.");
      }

      loader.midletClassName = args[1];

      int numberOfSuiteArgs = args.length - 2;

      if (numberOfSuiteArgs > 0) {
        loader.args = new String[numberOfSuiteArgs];
        for (int i = 0; i < numberOfSuiteArgs; i++) {
          loader.args[i] = args[i + 2];
        }
      }

      loader.runMIDletSuite();
    } catch (Throwable t) {
      t.printStackTrace();
    }
  }