Package org.rzo.yajsw.controller

Examples of org.rzo.yajsw.controller.Message


  static final CharsetEncoder  encoder  = Charset.defaultCharset().newEncoder();

  @Override
  protected Object encode(ChannelHandlerContext ctx, Channel channel, Object message) throws Exception
  {
    Message m = (Message) message;
    ChannelBuffer buffer = buffer(m.getMessage().length() + 2);
    buffer.writeByte(m.getCode());
    buffer.writeBytes(encoder.encode(CharBuffer.wrap(m.getMessage())));
    buffer.writeByte((byte) 0);
    // System.out.println("encode " + buffer.toString("UTF-8"));
    return buffer;
  }
View Full Code Here


  }

  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception
  {
    Message message = (Message) e.getMessage();
    switch (message.getCode())
    {
    case WRAPPER_MSG_KEY:
      // check if JVM sent us correct key
      if (_controller._key.equals(message.getMessage()))
      {
        _controller.setState(JVMController.STATE_LOGGED_ON);
        _controller.startupOK();
        ctx.getChannel().write(new Message(Constants.WRAPPER_MSG_OKKEY, "" + _controller._wrappedProcess.getAppPid()));
        if (_controller.isDebug())
          _controller.getLog().info("Correct key");
      }
      // if not: announce it and close session
      else
      {
        if (_controller.isDebug())
          _controller.getLog().info("Wrong key -> closing session");
        ctx.getChannel().write(new Message(Constants.WRAPPER_MSG_BADKEY, null));
        ctx.getChannel().close();
      }
      break;
    case Constants.WRAPPER_MSG_STOP:
      if (_controller._wrappedProcess != null)
View Full Code Here

    byte code = b.readByte();
    // TODO remove the nul
    b.writerIndex(b.writerIndex());
    String msg = b.toString(Charset.defaultCharset().displayName());
    Message result = new Message(code, msg);
    return result;
  }
View Full Code Here

  }

  public void wrapperThreadDump()
  {
    Message m = new Message(Constants.WRAPPER_MSG_THREAD_DUMP, null);
    Action a = ActionFactory.getAction(m);
    try
    {
      ByteArrayOutputStream str = new ByteArrayOutputStream();
      PrintStream pr = new PrintStream(str);
View Full Code Here

      public boolean isOk(ChannelHandlerContext ctx, ChannelEvent e)
      {
        boolean result = false;
        if (e instanceof MessageEvent)
        {
          Message m = (Message) ((MessageEvent) e).getMessage();
          result = m.getCode() == Constants.WRAPPER_MSG_OKKEY;
        }
        return result;
      }
    }));
View Full Code Here

      while (_channel != null && _channel.isConnected() && i < 3)
      {
        i++;
        getLog().info("controller sending a stop command");
        if (_channel != null)
          _channel.write(new Message(Constants.WRAPPER_MSG_STOP, null));
        try
        {
          Thread.sleep(200);
        }
        catch (Exception ex)
View Full Code Here

   * Request thread dump.
   */
  public void requestThreadDump()
  {
    if (_channel != null)
      _channel.write(new Message(Constants.WRAPPER_MSG_THREAD_DUMP, null));
  }
View Full Code Here

          public void run()
          {
            if (_session != null && _session.isConnected() && !_stopping && !_appearHanging)
            {
              ChannelFuture future = _session.write(new Message(Constants.WRAPPER_MSG_PING, null));
              try
              {
                future.await(10000);
              }
              catch (InterruptedException e)
View Full Code Here

       * e1.printStackTrace(); } _lock.unlock();
       * System.out.println("started "+_started);
       */

      if (_started)
        future1.getChannel().write(new Message(Constants.WRAPPER_MSG_KEY, _key));
      else
        try
        {
          if (_debug)
            log.fine("connection failed -> sleep then retry");
View Full Code Here

  public void stop()
  {
    if (_session != null)
      while (_session != null && !_stopping)
      {
        _session.write(new Message(Constants.WRAPPER_MSG_STOP, null));
        try
        {
          Thread.sleep(500);
        }
        catch (InterruptedException e)
View Full Code Here

TOP

Related Classes of org.rzo.yajsw.controller.Message

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.