Package center.task

Examples of center.task.TaskException


      SAMsg in = new SAMsg();
      SAMsg result = new SAMsg();
        int enq = is.read();
        System.out.print("<-- " + toHexString(enq));
        if (enq != SAMsg.ENQ)
          throw new TaskException(State.DONE_ERR, "Incorrect the first signal from host");
        q.sendTo(s.getOutputStream());
        System.out.print("\n-->");
        q.printTo(System.out);

        System.out.println();
        String v;
        for (String n : prmi.getFieldNames()) {
          v = prmi.getField(n);
          System.out.println(n + " = " + v);
        }

        int ch;
        PrmInterface inpi = in.getPrmInterface();
        CloseableOutputStream osc = in.getOutputStream();
        System.out.print("\n<--");
        boolean end = false;
        while (!end && (ch = is.read()) != -1) {
          System.out.print(" ");
          System.out.print(toHexString(ch));
          osc.write(ch);
          if (osc.isClosed()) {
            switch(Integer.parseInt(inpi.getField("type"))) {
            case  SAMsg.STX:
              System.out.println();
              PrmInterface rpi = result.getPrmInterface();
              for (String n : inpi.getFieldNames()) {
                v = inpi.getField(n);
                rpi.setField(n, v);
                System.out.println(n + " = " + v);
              }
              end = true;
              break;
            case  SAMsg.ACK:
              System.out.print("\n<--");
              break;
            case  SAMsg.ENQ:
              System.out.print("\n<--");
              break;
            default:
              System.out.print("\n<--");
              throw new TaskException(State.DONE_ERR, "Incorrect response from host");
            }
            in.reset();
            osc = in.getOutputStream();
          }
        }
       
        os.write(SAMsg.ACK);
        System.out.print("\n--> " + toHexString(SAMsg.ACK));
        os.write(SAMsg.EOT);
        System.out.println("\n--> " + toHexString(SAMsg.EOT));

      PrmInterface rpi = result.getPrmInterface();
      StringList flds = rpi.getFieldNames();
      for (String fld : flds) {
        cntx.setPrmByFullName(msg_grp_out + "/" + fld, rpi.getField(fld), false);
      }
    } catch (UnknownHostException e) {
      throw new TaskException(State.DONE_ERR, e);
    } catch (IOException e) {
      throw new TaskException(State.DONE_ERR, e);
    } finally {
      ru.vassaev.core.util.Sockets.close(s);
    }
    return State.DONE_OK;
  }
View Full Code Here


                .println("javax.net.ssl.keyStore is not defined");
          else
            System.out.println("javax.net.ssl.keyStore = "
                + keyStore1);
        } catch (NoSuchProviderException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (NoSuchAlgorithmException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (KeyManagementException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (CertificateException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (UnrecoverableKeyException e) {
          throw new TaskException(State.DONE_ERR, e);
        } catch (KeyStoreException e) {
          throw new TaskException(State.DONE_ERR, e);
        }
      else
        server = HttpServer.create(new InetSocketAddress(port), 0);
      server.createContext(path, new XMLHttpHandler(cntx));
      server.setExecutor(executor);
      server.start();

      Process prc = Process.currentProcess();
      while (true) {
        try {
          if (prc.isWillBreak())
            return State.BROKEN;
          State st = cntx.ta.getState(cntx.id_task);
          if (st.getType().equals(TypeOfState.LAST))
            return st;
          if (st.equals(State.BREAKING))
            return State.BROKEN;
        } catch (SysException ex) {
          ex.printStackTrace();
        }
        Thread.sleep(2000);// !!!
      }
    } catch (IOException e) {
      throw new TaskException(State.DONE_ERR, e);
    } catch (InterruptedException e) {
      throw new TaskException(State.DONE_ERR, e);
    } finally {
      if (server != null)
        server.stop(0);
    }
  }
View Full Code Here

TOP

Related Classes of center.task.TaskException

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.