Package ru.vassaev.core.exception

Examples of ru.vassaev.core.exception.SysException


  public JavaFunc(center.task.prm.Type tp, String owner, Element e) throws SysException {
    super(tp, owner);
    //Класс
    clsn = Strings.getXMLValue(e, "class_name");
    if (clsn == null)
      throw new SysException("There is no Element class_name");
    try {
      cls = Class.forName(clsn);
    } catch (ClassNotFoundException e1) {
      throw new SysException(e1);
    }
    //Method
    mtdn = Strings.getXMLValue(e, "func_name");
    if (mtdn == null)
      throw new SysException("There is no Element func_name");

    NodeList le = Xml.getElementsByTagName(e, "param");
    params = new ArrayList<Object>();
    int l = le.getLength();
    cls_ = new Class[l];
    for (int i = 0; i < l; i++) {
      Element el = (Element) le.item(i);
      String type = el.getAttribute("type");
      if (type != null)
        try {
          cls_[i] = Class.forName(type);
        } catch (ClassNotFoundException e1) {
          throw new SysException(e1);
        }
      else
          cls_[i] = String.class;
      Object p = Prm.getPrm(el);
      params.add(p);
    }
    try {
      mtd = cls.getMethod(mtdn, cls_);
    } catch (NoSuchMethodException e1) {
      throw new SysException(e1);
    }
  }
View Full Code Here


   */
  public void paramsValidateAndPrepare(Context cntx) throws SysException {
    // Имя пула потоков, которое используется для разбора очереди
    poolProcessName = cntx.getPrmString("process_pool");
    if (Null.equ(poolProcessName))
      throw new SysException("Parameter process_pool isn't set");
    ru.vassaev.core.thread.Process prc =
      ru.vassaev.core.thread.Process.currentProcess();
    AppInfo ai = ApplicationManager.getCurrentAppInfo();
    Pool<?> poolprc = ai.getContainer().getRM().getPool(poolProcessName);
    if (Null.equ(poolprc))
      throw new SysException("There is no pool by name " + poolProcessName);
    try {
      prcs = (Pool<ru.vassaev.core.thread.Process>) poolprc;
    } catch(Throwable e) {
      throw new SysException("The pool by name " + poolProcessName + " dosn't contain process' object");
    }
   
    dateFormat = cntx.getPrmString("date_format");
    if (dateFormat == null)
      dateFormat = "dd.MM.yyyy HH:mm:ss.SSS";
View Full Code Here

   */
  public void paramsValidateAndPrepare(Context cntx) throws SysException {
    // Имя пула потоков исполнения
    poolProcessName = cntx.getPrmString("process_pool");
    if (Null.equ(poolProcessName))
      throw new SysException("Parameter process_pool isn't set");
    ru.vassaev.core.thread.Process prc = ru.vassaev.core.thread.Process
        .currentProcess();
    prcs = (PoolThread) ApplicationManager.getPoolByName(poolProcessName, Process.class);
    // Определение пула контейнеров сообщений
    String poolMessageName = cntx.getPrmString("message_pool");
    if (Null.equ(poolMessageName))
      throw new SysException("Parameter message_pool isn't set");
    poolmsg = (Pool<ByteMsg>) ApplicationManager.getPoolByName(poolMessageName, ByteMsg.class);

    localport = Strings.parseInteger(cntx.getPrmByFullName("localport"));

    maxlink = Strings.parseIntegerNvl(cntx.getPrmByFullName("maxlink"), 50);
View Full Code Here

   * @throws SysException
   */
  public void paramsValidateAndPrepare(Context cntx) throws SysException {
    poolProcessName = cntx.getPrmString("process_pool");
    if (Null.equ(poolProcessName))
      throw new SysException("Parameter process_pool isn't set");
    ru.vassaev.core.thread.Process prc =
      ru.vassaev.core.thread.Process.currentProcess();
    AppInfo ai = ApplicationManager.getCurrentAppInfo();
    Pool<?> poolprc = ai.getContainer().getRM().getPool(poolProcessName);
    if (Null.equ(poolprc))
      throw new SysException("There is no pool by name " + poolProcessName);
    try {
      prcs = (Pool<ru.vassaev.core.thread.Process>) poolprc;
    } catch(Throwable e) {
      throw new SysException("The pool by name " + poolProcessName + " dosn't contain process' object");
    }
    dateFormat = cntx.getPrmString("date_format");
    if (dateFormat == null)
      dateFormat = "dd.MM.yyyy HH:mm:ss.SSS";
  }
View Full Code Here

                for (int i = 0; i < address.length; i++) {
                    address[i] = new InternetAddress(to[i]);
                }
                msg.setRecipients(Message.RecipientType.TO, address);
            } catch (Exception ex) {
                throw new SysException(ex);
            }

            InternetAddress[] address = new InternetAddress[bcc.length + to.length];
            try {
                for (int i = 0; i < address.length; i++) {
                    if (i < bcc.length)
                        address[i] = new InternetAddress(bcc[i]);
                    else
                        address[i] = new InternetAddress(to[i - bcc.length]);
                }
                msg.setRecipients(Message.RecipientType.BCC, address);
            } catch (Exception ex) {
                throw new SysException(ex);
            }
//*/
            msg.setSubject(l.subject, l.charset);
            msg.setSentDate(new java.util.Date());
            // create and fill the first message part
            Multipart mp = new MimeMultipart();

            MimeBodyPart mbp1 = new MimeBodyPart();
            mbp1.setText(l.body, l.charset);
            mp.addBodyPart(mbp1);
            for (int i = 0; i < l.files.length; i++) {
                MimeBodyPart mbp12 = new MimeBodyPart();
                mbp12.setDataHandler(new DataHandler(
                         new FileDataSource(l.files[i])));
                if((l.descriptions != null) && (l.descriptions.length > i))
                    mbp12.setDescription(l.descriptions[i]);
                if((l.filenames != null) && (l.filenames.length > i))
                    mbp12.setFileName(l.filenames[i]);
                else
                    mbp12.setFileName(l.files[i].getName());
                mp.addBodyPart(mbp12);
            }
            // add the Multipart to the message
            msg.setContent(mp);
            synchronized (Transport.class) {
                Transport t;
                t = session.getTransport("smtp");
                t.connect(host, Integer.parseInt(port), user, pwd);
                t.send(msg, address);
                t.close();
            }
            return true;
        } catch (MessagingException ex) {
            ex.printStackTrace();
            throw new SysException(ex);
        }
    }
View Full Code Here

   * @throws SysException - ошибка создания запроса
   */
  public void makeQuery(Q msg, String key) throws SysException {
    synchronized (qt) {
      if (qt.get(key) != null)
        throw new SysException("The key is not unique");
      qt.put(key, msg);
    }
  }
View Full Code Here

  public void giveResponse(R msg, String key) throws SysException {
    Q q;
    synchronized (qt) {
      q = qt.get(key);
      if (q == null)
        throw new SysException("There is no query for this response");
    }
    synchronized (rt) {
      if (rt.get(key) != null)
        throw new SysException("The key is not unique");
      rt.put(key, msg);
    }
    synchronized (q) {
      q.notify();
    }
View Full Code Here

  public R takeResponse(String key) throws SysException {
    Q q;
    synchronized (qt) {
      q = qt.get(key);
      if (q == null)
        throw new SysException("There is no query for this response");
    }
    R r = null;
    try {
      synchronized (rt) {
        r = rt.remove(key);
View Full Code Here

  public R takeResponseWithWait(String key) throws SysException {
    Q q = null;
    synchronized (qt) {
      q = qt.get(key);
      if (q == null)
        throw new SysException("There is no query for this response");
    }
    R r = null;
    try {
      synchronized (q) {
        do {
          synchronized (rt) {
            r = rt.remove(key);
          }
          if (r != null)
            return r;
          try {
            q.wait();
          } catch (InterruptedException ex) {
            throw new SysException(ex);
          }
          if (qt.get(key) == null) {
            return null;
          }
        } while (true);
View Full Code Here

  public R takeResponseWithWait(String key, long timeout) throws SysException {
    Q q;
    synchronized (qt) {
      q = qt.get(key);
      if (q == null)
        throw new SysException("There is no query for this response");
    }
    R r = null;
    try {
      long to = timeout / 10;
      long from = System.currentTimeMillis();
      long to_time = from + timeout;
      //long from = System.currentTimeMillis();
      synchronized (q) {
        synchronized (rt) {
          r = rt.remove(key);
          if (r != null)
            return r;
        }
        //to_time > System.currentTimeMillis()
        while (to_time > System.currentTimeMillis()) {
          try {
            q.wait(to);
          } catch (InterruptedException ex) {
            throw new SysException(ex);
          }
          if (qt.get(key) == null)
            return null;
          synchronized (rt) {
            r = rt.remove(key);
View Full Code Here

TOP

Related Classes of ru.vassaev.core.exception.SysException

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.