Package org.mvel2.util

Examples of org.mvel2.util.StringAppender


     * @param e - the exception received
     */
    public static void sendClientError(MessageBus bus, Message message, String errorMessage, Throwable e) {

        if (e != null) {
            StringAppender a = new StringAppender("<br/>").append(e.getClass().getName() + ": " + e.getMessage()).append("<br/>");

            // Let's build-up the stacktrace.
            boolean first = true;
            for (StackTraceElement sel : e.getStackTrace()) {
                a.append(first ? "" : "&nbsp;&nbsp;").append(sel.toString()).append("<br/>");
                first = false;
            }

            // And add the entire causal chain.
            while ((e = e.getCause()) != null) {
                first = true;
                a.append("Caused by:<br/>");
                for (StackTraceElement sel : e.getStackTrace()) {
                    a.append(first ? "" : "&nbsp;&nbsp;").append(sel.toString()).append("<br/>");
                    first = false;
                }
            }
            sendClientError(bus, message, errorMessage, a.toString());

        }
        else {
            sendClientError(bus, message, errorMessage, "No additional details.");
        }
View Full Code Here


     */
    @Override
    protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
            throws ServletException, IOException {
        BufferedReader reader = httpServletRequest.getReader();
        StringAppender sb = new StringAppender(httpServletRequest.getContentLength());
        CharBuffer buffer = CharBuffer.allocate(10);

        int read;
        while ((read = reader.read(buffer)) > 0) {
            buffer.rewind();
            for (; read > 0; read--) {
                sb.append(buffer.get());
            }
            buffer.rewind();
        }

        for (Message msg : createCommandMessage(sessionProvider.getSession(httpServletRequest.getSession()), sb.toString())) {
            service.store(msg);
        }

        pollQueue(service.getBus().getQueue(httpServletRequest.getSession().getId()), httpServletRequest, httpServletResponse);
    }
View Full Code Here

        try {
            ServletInputStream inputStream = httpServletRequest.getInputStream();
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(inputStream, "UTF-8")
            );
            StringAppender sb = new StringAppender(httpServletRequest.getContentLength());
            CharBuffer buffer = CharBuffer.allocate(10);

            int read;
            while ((read = reader.read(buffer)) > 0) {
                buffer.rewind();
                for (; read > 0; read--) {
                    sb.append(buffer.get());
                }
                buffer.rewind();
            }

            for (Message msg : createCommandMessage(sessionProvider.getSession(httpServletRequest.getSession()), sb.toString())) {
                service.store(msg);
            }
        }
        catch (Throwable e) {
            // handle gracefully
View Full Code Here

    private int readInRequest(HttpServletRequest request) {
        try {

            BufferedReader reader = request.getReader();
            if (!reader.ready()) return 0;
            StringAppender sb = new StringAppender(request.getContentLength());
            CharBuffer buffer = CharBuffer.allocate(10);
            int read;
            while ((read = reader.read(buffer)) > 0) {
                buffer.rewind();
                for (; read > 0; read--) {
                    sb.append(buffer.get());
                }
                buffer.rewind();
            }


            int messagesSent = 0;
            for (Message msg : createCommandMessage(sessionProvider.getSession(request.getSession()), sb.toString())) {
                service.store(msg);
                messagesSent++;
            }

            return messagesSent;
View Full Code Here

    }

    private int readInRequest(HttpServletRequest request) throws IOException {
        BufferedReader reader = request.getReader();
        if (!reader.ready()) return 0;
        StringAppender sb = new StringAppender(request.getContentLength());
        CharBuffer buffer = CharBuffer.allocate(10);
        int read;
        while ((read = reader.read(buffer)) > 0) {
            buffer.rewind();
            for (; read > 0; read--) {
                sb.append(buffer.get());
            }
            buffer.rewind();
        }

        int messagesSent = 0;
        for (Message msg : createCommandMessage(sessionProvider.getSession(request.getSession()), sb.toString())) {
            service.store(msg);
            messagesSent++;
        }

        return messagesSent;
View Full Code Here

    return parmValues;
  }

  public static String commaDelimitedList(Context context, Statement[] parts) {
    StringAppender appender = new StringAppender();
    for (int i = 0; i < parts.length; i++) {
      appender.append(parts[i].generate(context));
      if ((i + 1) < parts.length) appender.append(", ");
    }
    return appender.toString();
  }
View Full Code Here

  }

  private int readInRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
    BufferedReader reader = request.getReader();
    if (!reader.ready()) return 0;
    StringAppender sb = new StringAppender(request.getContentLength());
    CharBuffer buffer = CharBuffer.allocate(10);
    int read;
    while ((read = reader.read(buffer)) > 0) {
      buffer.rewind();
      for (; read > 0; read--) {
        sb.append(buffer.get());
      }
      buffer.rewind();
    }

    Message msg = createCommandMessage(sessionProvider.getSession(request.getSession(),
        request.getHeader(REMOTE_QUEUE_ID_HEADER)), sb.toString());
    if (msg != null) {
      try {
        service.store(msg);
      }
      catch (Exception e) {
View Full Code Here

    final QueueSession session = sessionProvider.getSession(request.getSession(),
        request.getHeader(ClientMessageBus.REMOTE_QUEUE_ID_HEADER));

    BufferedReader reader = request.getReader();
    StringAppender sb = new StringAppender(request.getContentLength());
    CharBuffer buffer = CharBuffer.allocate(10);

    int read;
    while ((read = reader.read(buffer)) > 0) {
      buffer.rewind();
      for (; read > 0; read--) {
        sb.append(buffer.get());
      }
      buffer.rewind();
    }

    Message msg = createCommandMessage(session, sb.toString());
    if (msg != null) {
      try {
        service.store(msg);
      }
      catch (Exception e) {
View Full Code Here

    final QueueSession session = sessionProvider.getSession(httpServletRequest.getSession(),
        httpServletRequest.getHeader(ClientMessageBus.REMOTE_QUEUE_ID_HEADER));

    BufferedReader reader = httpServletRequest.getReader();
    StringAppender sb = new StringAppender(httpServletRequest.getContentLength());
    CharBuffer buffer = CharBuffer.allocate(10);

    int read;
    while ((read = reader.read(buffer)) > 0) {
      buffer.rewind();
      for (; read > 0; read--) {
        sb.append(buffer.get());
      }
      buffer.rewind();
    }

    Message m = createCommandMessage(session, sb.toString());
    if (m != null) {
      try {
        service.store(m);
      }
      catch (Exception e) {
View Full Code Here

  private int readInRequest(QueueSession session, HttpServletRequest request, HttpServletResponse response) {
    try {

      BufferedReader reader = request.getReader();
      if (!reader.ready()) return 0;
      StringAppender sb = new StringAppender(request.getContentLength());
      CharBuffer buffer = CharBuffer.allocate(10);
      int read;
      while ((read = reader.read(buffer)) > 0) {
        buffer.rewind();
        for (; read > 0; read--) {
          sb.append(buffer.get());
        }
        buffer.rewind();
      }


      Message msg = createCommandMessage(sessionProvider.getSession(request.getSession(),
          request.getHeader(ClientMessageBus.REMOTE_QUEUE_ID_HEADER)), sb.toString());
      if (msg != null) {
        try {
          service.store(msg);
        }
        catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.mvel2.util.StringAppender

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.