Package com.caucho.hessian.io

Examples of com.caucho.hessian.io.AbstractHessianOutput


    }

    HessianInputFactory.HeaderType header = _inputFactory.readHeader(is);

    AbstractHessianInput in;
    AbstractHessianOutput out;

    switch (header) {
    case CALL_1_REPLY_1:
      in = _hessianFactory.createHessianInput(is);
      out = _hessianFactory.createHessianOutput(os);
      break;

    case CALL_1_REPLY_2:
      in = _hessianFactory.createHessianInput(is);
      out = _hessianFactory.createHessian2Output(os);
      break;

    case HESSIAN_2:
      in = _hessianFactory.createHessian2Input(is);
      in.readCall();
      out = _hessianFactory.createHessian2Output(os);
      break;

    default:
      throw new IllegalStateException(header + " is an unknown Hessian call");
    }

    if (serializerFactory != null) {
      in.setSerializerFactory(serializerFactory);
      out.setSerializerFactory(serializerFactory);
    }

    try {
      invoke(_service, in, out);
    } finally {
      in.close();
      out.close();

      if (isDebug)
        os.close();
    }
  }
View Full Code Here


  }

  protected void invoke(RequestWrapper rw, InputStream is, OutputStream os,
      SerializerFactory serializerFactory) {
    AbstractHessianInput in = null;
    AbstractHessianOutput out = null;
    String username = rw.getUser();
    String password = rw.getPassword();
    try {

      HessianInputFactory.HeaderType header = _inputFactory
          .readHeader(is);

      switch (header) {
      case CALL_1_REPLY_1:
        in = _hessianFactory.createHessianInput(is);
        out = _hessianFactory.createHessianOutput(os);
        break;

      case CALL_1_REPLY_2:
        in = _hessianFactory.createHessianInput(is);
        out = _hessianFactory.createHessian2Output(os);
        break;

      case HESSIAN_2:
        in = _hessianFactory.createHessian2Input(is);
        in.readCall();
        out = _hessianFactory.createHessian2Output(os);
        break;

      default:
        throw new IllegalStateException(header
            + " is an unknown Hessian call");
      }

      if (serializerFactory != null) {
        in.setSerializerFactory(serializerFactory);
        out.setSerializerFactory(serializerFactory);
      }

      if (username == null || password == null) {
        Exception exception = new RuntimeException(
            "the client can't offer the user or password infor,please check.");
        out.writeFault("ServiceException", exception.getMessage(),
            exception);
        log.error("the client can't offer the user or password infor,now we have refused.");
        throw exception;
      }
      invoke(rw, in, out);
    } catch (Exception e) {
      e.printStackTrace();
      try {
        out.writeFault("ServiceException", e.getMessage(), e);
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    } finally {
      try {
        in.close();
        out.close();
      } catch (IOException e) {
        e.printStackTrace();
      }

    }
View Full Code Here

      int code = isToUse.read();
      int major;
      int minor;

      AbstractHessianInput in;
      AbstractHessianOutput out;

      if (code == 'H') {
        // Hessian 2.0 stream
        major = isToUse.read();
        minor = isToUse.read();
        if (major != 0x02) {
          throw new IOException("Version " + major + "." + minor + " is not understood");
        }
        in = new Hessian2Input(isToUse);
        out = new Hessian2Output(osToUse);
        in.readCall();
      }
      else if (code == 'C') {
        // Hessian 2.0 call... for some reason not handled in HessianServlet!
        isToUse.reset();
        in = new Hessian2Input(isToUse);
        out = new Hessian2Output(osToUse);
        in.readCall();
      }
      else if (code == 'c') {
        // Hessian 1.0 call
        major = isToUse.read();
        minor = isToUse.read();
        in = new HessianInput(isToUse);
        if (major >= 2) {
          out = new Hessian2Output(osToUse);
        }
        else {
          out = new HessianOutput(osToUse);
        }
      }
      else {
        throw new IOException("Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at " + code);
      }

      if (this.serializerFactory != null) {
        in.setSerializerFactory(this.serializerFactory);
        out.setSerializerFactory(this.serializerFactory);
      }
      if (this.remoteResolver != null) {
        in.setRemoteResolver(this.remoteResolver);
      }

      try {
        skeleton.invoke(in, out);
      }
      finally {
        try {
          in.close();
          isToUse.close();
        }
        catch (IOException ex) {
          // ignore
        }
        try {
          out.close();
          osToUse.close();
        }
        catch (IOException ex) {
          // ignore
        }
View Full Code Here

      int code = isToUse.read();
      int major;
      int minor;

      AbstractHessianInput in;
      AbstractHessianOutput out;

      if (code == 'H') {
        // Hessian 2.0 stream
        major = isToUse.read();
        minor = isToUse.read();
        if (major != 0x02) {
          throw new IOException("Version " + major + "." + minor + " is not understood");
        }
        in = new Hessian2Input(isToUse);
        out = new Hessian2Output(osToUse);
        in.readCall();
      }
      else if (code == 'C') {
        // Hessian 2.0 call... for some reason not handled in HessianServlet!
        isToUse.reset();
        in = new Hessian2Input(isToUse);
        out = new Hessian2Output(osToUse);
        in.readCall();
      }
      else if (code == 'c') {
        // Hessian 1.0 call
        major = isToUse.read();
        minor = isToUse.read();
        in = new HessianInput(isToUse);
        if (major >= 2) {
          out = new Hessian2Output(osToUse);
        }
        else {
          out = new HessianOutput(osToUse);
        }
      }
      else {
        throw new IOException("Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at " + code);
      }

      if (this.serializerFactory != null) {
        in.setSerializerFactory(this.serializerFactory);
        out.setSerializerFactory(this.serializerFactory);
      }

      try {
        skeleton.invoke(in, out);
      }
      finally {
        try {
          in.close();
          isToUse.close();
        }
        catch (IOException ex) {
          // ignore
        }
        try {
          out.close();
          osToUse.close();
        }
        catch (IOException ex) {
          // ignore
        }
View Full Code Here

    int code = in.read();
    if (code != 'c') {
      throw new IOException("expected 'c' in hessian input at " + code);
    }

    AbstractHessianOutput out = null;
    int major = in.read();
    int minor = in.read();
    if (major >= 2) {
      out = new Hessian2Output(osToUse);
    }
    else {
      out = new HessianOutput(osToUse);
    }
    if (this.serializerFactory != null) {
      out.setSerializerFactory(this.serializerFactory);
    }

    this.skeleton.invoke(in, out);
  }
View Full Code Here

    return in;
  }

  public AbstractHessianOutput getHessianOutput(OutputStream os)
  {
    AbstractHessianOutput out;

    if (_isHessian2Request)
      out = new Hessian2Output(os);
    else {
      HessianOutput out1 = new HessianOutput(os);
      out = out1;

      if (_isHessian2Reply)
        out1.setVersion(2);
    }

    out.setSerializerFactory(getSerializerFactory());

    return out;
  }
View Full Code Here

    }

    HessianInputFactory.HeaderType header = _inputFactory.readHeader(is);

    AbstractHessianInput in;
    AbstractHessianOutput out;

    switch (header) {
    case CALL_1_REPLY_1:
      in = _hessianFactory.createHessianInput(is);
      out = _hessianFactory.createHessianOutput(os);
      break;

    case CALL_1_REPLY_2:
      in = _hessianFactory.createHessianInput(is);
      out = _hessianFactory.createHessian2Output(os);
      break;

    case HESSIAN_2:
      in = _hessianFactory.createHessian2Input(is);
      in.readCall();
      out = _hessianFactory.createHessian2Output(os);
      break;

    default:
      throw new IllegalStateException(header + " is an unknown Hessian call");
    }

    if (serializerFactory != null) {
      in.setSerializerFactory(serializerFactory);
      out.setSerializerFactory(serializerFactory);
    }

    try {
      invoke(_service, in, out);
    } finally {
      in.close();
      out.close();

      if (isDebug)
        os.close();
    }
  }
View Full Code Here

  {
    BytesMessage message = _jmsSession.createBytesMessage();

    BytesMessageOutputStream os = new BytesMessageOutputStream(message);

    AbstractHessianOutput out = _factory.getHessianOutput(os);

    out.call(methodName, args);
    out.flush();

    _producer.send(message);
  }
View Full Code Here

  public void invoke(InputStream is, OutputStream os)
  {
    try {
      Hessian2Input in = new Hessian2Input(is);
      AbstractHessianOutput out;

      SerializerFactory serializerFactory = getSerializerFactory();

      in.setSerializerFactory(serializerFactory);

      int code = in.read();

      if (code != 'c') {
        // XXX: deflate
        throw new IOException(L.l("expected 'c' in hessian input at {0}",
                                  code));
      }

      int major = in.read();
      int minor = in.read();

      if (major >= 2)
        out = new Hessian2Output(os);
      else
        out = new HessianOutput(os);

      out.setSerializerFactory(serializerFactory);

      if (_skeleton == null)
        throw new Exception("skeleton is null!");

      _skeleton.invoke(in, out);

      out.close();
    } catch (IOException e) {
      log.log(Level.INFO, L.l("Unable to process request: "), e);
    } catch (Throwable e) {
      log.log(Level.INFO, L.l("Unable to process request: "), e);
    }
View Full Code Here

TOP

Related Classes of com.caucho.hessian.io.AbstractHessianOutput

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.