Package org.contikios.cooja.MoteType

Examples of org.contikios.cooja.MoteType.MoteTypeCreationException


          templateFileReader.close();
        }
      } catch (Exception e2) {
      }

      throw (MoteTypeCreationException) new MoteTypeCreationException(
          "Could not generate corecomm source file: " + className + ".java")
          .initCause(e);
    }

    File genFile = new File("org/contikios/cooja/corecomm/" + destFilename);
    if (genFile.exists()) {
      return;
    }

    throw new MoteTypeCreationException(
        "Could not generate corecomm source file: " + className + ".java");
  }
View Full Code Here


      if (classFile.exists()) {
        return;
      }

    } catch (IOException e) {
      MoteTypeCreationException exception = (MoteTypeCreationException) new MoteTypeCreationException(
          "Could not compile corecomm source file: " + className + ".java")
          .initCause(e);
      exception.setCompilationOutput(compilationOutput);
      throw exception;
    } catch (InterruptedException e) {
      MoteTypeCreationException exception = (MoteTypeCreationException) new MoteTypeCreationException(
          "Could not compile corecomm source file: " + className + ".java")
          .initCause(e);
      exception.setCompilationOutput(compilationOutput);
      throw exception;
    }

    MoteTypeCreationException exception = new MoteTypeCreationException(
        "Could not compile corecomm source file: " + className + ".java");
    exception.setCompilationOutput(compilationOutput);
    throw exception;
  }
View Full Code Here

          CoreComm.class.getClassLoader());
      loadedClass = urlClassLoader.loadClass("org.contikios.cooja.corecomm."
          + className);

    } catch (MalformedURLException e) {
      throw (MoteTypeCreationException) new MoteTypeCreationException(
          "Could not load corecomm class file: " + className + ".class")
          .initCause(e);
    } catch (ClassNotFoundException e) {
      throw (MoteTypeCreationException) new MoteTypeCreationException(
          "Could not load corecomm class file: " + className + ".class")
          .initCause(e);
    }
    if (loadedClass == null) {
      throw new MoteTypeCreationException(
          "Could not load corecomm class file: " + className + ".class");
    }

    return loadedClass;
  }
View Full Code Here

      coreCommFiles.add(libFile);
      fileCounter++;

      return newCoreComm;
    } catch (Exception e) {
      throw (MoteTypeCreationException) new MoteTypeCreationException(
          "Error when creating corecomm instance: " + className).initCause(e);
    }
  }
View Full Code Here

        if (outputFile.exists()) {
          messageDialog.addMessage("Error when deleting old " + outputFile.getName(), MessageList.ERROR);
          if (onFailure != null) {
            onFailure.actionPerformed(null);
          }
          throw new MoteTypeCreationException("Error when deleting old " + outputFile.getName());
        }
      }

      Thread readInput = new Thread(new Runnable() {
        public void run() {
          try {
            String readLine;
            while ((readLine = processNormal.readLine()) != null) {
              if (messageDialog != null) {
                messageDialog.addMessage(readLine, MessageList.NORMAL);
              }
            }
          } catch (IOException e) {
            logger.warn("Error while reading from process");
          }
        }
      }, "read input stream thread");

      Thread readError = new Thread(new Runnable() {
        public void run() {
          try {
            String readLine;
            while ((readLine = processError.readLine()) != null) {
              if (messageDialog != null) {
                messageDialog.addMessage(readLine, MessageList.ERROR);
              }
            }
          } catch (IOException e) {
            logger.warn("Error while reading from process");
          }
        }
      }, "read error stream thread");

      final MoteTypeCreationException syncException = new MoteTypeCreationException("");
      Thread handleCompilationResultThread = new Thread(new Runnable() {
        public void run() {

          /* Wait for compilation to end */
          try {
            compileProcess.waitFor();
          } catch (Exception e) {
            messageDialog.addMessage(e.getMessage(), MessageList.ERROR);
            syncException.setCompilationOutput(new MessageList());
            syncException.fillInStackTrace();
            return;
          }

          /* Check return value */
          if (compileProcess.exitValue() != 0) {
            messageDialog.addMessage("Process returned error code " + compileProcess.exitValue(), MessageList.ERROR);
            if (onFailure != null) {
              onFailure.actionPerformed(null);
            }
            syncException.setCompilationOutput(new MessageList());
            syncException.fillInStackTrace();
            return;
          }

          if (outputFile == null) {
            /* No firmware to generate: OK */
            if (onSuccess != null) {
              onSuccess.actionPerformed(null);
            }
            return;
          }

          if (!outputFile.exists()) {
            messageDialog.addMessage("No firmware file: " + outputFile, MessageList.ERROR);
            if (onFailure != null) {
              onFailure.actionPerformed(null);
            }
            syncException.setCompilationOutput(new MessageList());
            syncException.fillInStackTrace();
            return;
          }

          messageDialog.addMessage("", MessageList.NORMAL);
          messageDialog.addMessage("Compilation succeded", MessageList.NORMAL);
          if (onSuccess != null) {
            onSuccess.actionPerformed(null);
          }
        }
      }, "handle compilation results");

      readInput.start();
      readError.start();
      handleCompilationResultThread.start();

      if (synchronous) {
        try {
          handleCompilationResultThread.join();
        } catch (Exception e) {
          /* Make sure process has exited */
          compileProcess.destroy();

          String msg = e.getMessage();
          if (e instanceof InterruptedException) {
            msg = "Aborted by user";
          }
          throw (MoteTypeCreationException) new MoteTypeCreationException(
              "Compilation error: " + msg).initCause(e);
        }

        /* Detect error manually */
        if (syncException.hasCompilationOutput()) {
          throw (MoteTypeCreationException) new MoteTypeCreationException(
          "Bad return value").initCause(syncException);
        }
      }
    } catch (IOException ex) {
      if (onFailure != null) {
        onFailure.actionPerformed(null);
      }
      throw (MoteTypeCreationException) new MoteTypeCreationException(
          "Compilation error: " + ex.getMessage()).initCause(ex);
    }

    return compileProcess;
  }
View Full Code Here

TOP

Related Classes of org.contikios.cooja.MoteType.MoteTypeCreationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.