/*
* Copyright (c) 2001-2008 Caucho Technology, Inc. All rights reserved.
*
* The Apache Software License, Version 1.1
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Caucho Technology (http://www.caucho.com/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "Hessian", "Resin", and "Caucho" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* info@caucho.com.
*
* 5. Products derived from this software may not be called "Resin"
* nor may "Resin" appear in their names without prior written
* permission of Caucho Technology.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @author Scott Ferguson
*/
package com.caucho.hessian.io;
import java.io.*;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.logging.*;
/**
* Input stream for Hessian requests.
*
* <p>HessianInput is unbuffered, so any client needs to provide
* its own buffering.
*
* <pre>
* InputStream is = ...; // from http connection
* HessianInput in = new HessianInput(is);
* String value;
*
* in.startReply(); // read reply header
* value = in.readString(); // read string value
* in.completeReply(); // read reply footer
* </pre>
*/
public class Hessian2Input
extends AbstractHessianInput
implements Hessian2Constants
{
private static final Logger log
= Logger.getLogger(Hessian2Input.class.getName());
private static final double D_256 = 1.0 / 256.0;
private static final int END_OF_DATA = -2;
private static Field _detailMessageField;
private static final int SIZE = 256;
private static final int GAP = 16;
// factory for deserializing objects in the input stream
protected SerializerFactory _serializerFactory;
private static boolean _isCloseStreamOnClose;
protected ArrayList _refs;
protected ArrayList _classDefs;
protected ArrayList _types;
// the underlying input stream
private InputStream _is;
private final byte []_buffer = new byte[SIZE];
// a peek character
private int _offset;
private int _length;
// true for streaming data
private boolean _isStreaming;
// the method for a call
private String _method;
private Reader _chunkReader;
private InputStream _chunkInputStream;
private Throwable _replyFault;
private StringBuffer _sbuf = new StringBuffer();
// true if this is the last chunk
private boolean _isLastChunk;
// the chunk length
private int _chunkLength;
/**
* Creates a new Hessian input stream, initialized with an
* underlying input stream.
*
* @param is the underlying input stream.
*/
public Hessian2Input(InputStream is)
{
_is = is;
}
/**
* Sets the serializer factory.
*/
public void setSerializerFactory(SerializerFactory factory)
{
_serializerFactory = factory;
}
/**
* Gets the serializer factory.
*/
public SerializerFactory getSerializerFactory()
{
return _serializerFactory;
}
/**
* Gets the serializer factory, creating a default if necessary.
*/
public final SerializerFactory findSerializerFactory()
{
SerializerFactory factory = _serializerFactory;
if (factory == null)
_serializerFactory = factory = new SerializerFactory();
return factory;
}
public void setCloseStreamOnClose(boolean isClose)
{
_isCloseStreamOnClose = isClose;
}
public boolean isCloseStreamOnClose()
{
return _isCloseStreamOnClose;
}
/**
* Returns the calls method
*/
public String getMethod()
{
return _method;
}
/**
* Returns any reply fault.
*/
public Throwable getReplyFault()
{
return _replyFault;
}
/**
* Starts reading the call
*
* <pre>
* c major minor
* </pre>
*/
public int readCall()
throws IOException
{
int tag = read();
if (tag != 'c')
throw error("expected hessian call ('c') at " + codeName(tag));
int major = read();
int minor = read();
return (major << 16) + minor;
}
/**
* Starts reading the envelope
*
* <pre>
* E major minor
* </pre>
*/
public int readEnvelope()
throws IOException
{
int tag = read();
if (tag != 'E')
throw error("expected hessian Envelope ('E') at " + codeName(tag));
int major = read();
int minor = read();
return (major << 16) + minor;
}
/**
* Completes reading the envelope
*
* <p>A successful completion will have a single value:
*
* <pre>
* z
* </pre>
*/
public void completeEnvelope()
throws IOException
{
int tag = read();
if (tag != 'z')
error("expected end of envelope at " + codeName(tag));
}
/**
* Starts reading the call
*
* <p>A successful completion will have a single value:
*
* <pre>
* m b16 b8 method
* </pre>
*/
public String readMethod()
throws IOException
{
int tag = read();
if (tag != 'm')
throw error("expected hessian method ('m') at " + codeName(tag));
int d1 = read();
int d2 = read();
_isLastChunk = true;
_chunkLength = d1 * 256 + d2;
_sbuf.setLength(0);
int ch;
while ((ch = parseChar()) >= 0)
_sbuf.append((char) ch);
_method = _sbuf.toString();
return _method;
}
/**
* Starts reading the call, including the headers.
*
* <p>The call expects the following protocol data
*
* <pre>
* c major minor
* m b16 b8 method
* </pre>
*/
public void startCall()
throws IOException
{
readCall();
while (readHeader() != null) {
readObject();
}
readMethod();
}
/**
* Completes reading the call
*
* <p>A successful completion will have a single value:
*
* <pre>
* z
* </pre>
*/
public void completeCall()
throws IOException
{
int tag = read();
if (tag == 'z') {
}
else if (tag < 0)
throw error("expected end of call ('z') at end of stream.");
else
throw error("expected end of call ('z') at " + codeName(tag) + ". Check method arguments and ensure method overloading is enabled if necessary");
}
/**
* Reads a reply as an object.
* If the reply has a fault, throws the exception.
*/
@Override
public Object readReply(Class expectedClass)
throws Throwable
{
int tag = read();
if (tag != 'r') {
StringB
没有合适的资源?快使用搜索试试~ 我知道了~
hessian 源代码与jar包
共136个文件
java:130个
html:2个
jar:2个
5星 · 超过95%的资源 需积分: 9 155 下载量 148 浏览量
2009-07-24
09:21:53
上传
评论 2
收藏 796KB RAR 举报
温馨提示
Hessian是一个轻量级的remoting onhttp工具,使用简单的方法提供了RMI的功能. 相比WebService,Hessian更简单、快捷。采用的是二进制RPC协议,因为采用的是二进制协议,所以它很适合于发送二进制数据
资源推荐
资源详情
资源评论
收起资源包目录
hessian 源代码与jar包 (136个子文件)
package.html 2KB
package.html 2KB
hessian-3_2-snap-src.jar 290KB
hessian-3_2-snap.jar 277KB
Hessian2Input.java 60KB
BurlapInput.java 36KB
Hessian2Output.java 35KB
HessianDebugState.java 33KB
HessianInput.java 32KB
MicroBurlapInput.java 23KB
BurlapOutput.java 21KB
HessianOutput.java 20KB
SerializerFactory.java 19KB
JavaDeserializer.java 17KB
MicroBurlapOutput.java 16KB
BasicDeserializer.java 14KB
HessianProxyFactory.java 14KB
MicroHessianOutput.java 13KB
AbstractHessianOutput.java 12KB
HessianProxy.java 12KB
JavaSerializer.java 11KB
HessianServlet.java 11KB
BurlapProxyFactory.java 11KB
MicroHessianInput.java 10KB
X509Signature.java 10KB
X509Encryption.java 10KB
AbstractHessianInput.java 9KB
MuxServer.java 8KB
BeanSerializer.java 8KB
BeanDeserializer.java 8KB
BasicSerializer.java 7KB
BurlapProxy.java 7KB
AbstractSkeleton.java 6KB
MuxInputStream.java 6KB
BurlapServlet.java 6KB
IdentityIntMap.java 6KB
HessianSkeleton.java 6KB
IntMap.java 6KB
ServiceContext.java 6KB
BurlapSkeleton.java 6KB
MuxOutputStream.java 6KB
HessianSerializerInput.java 5KB
Deflation.java 5KB
ClassDeserializer.java 5KB
HessianSerializerOutput.java 5KB
ArrayDeserializer.java 4KB
MapDeserializer.java 4KB
Hessian2StreamingInput.java 4KB
HessianDebugInputStream.java 4KB
JMXSerializerFactory.java 4KB
HessianDebugOutputStream.java 4KB
GenericService.java 4KB
EnumDeserializer.java 4KB
Hessian2Constants.java 4KB
AbstractDeserializer.java 4KB
SqlDateDeserializer.java 4KB
MBeanInfoDeserializer.java 4KB
NameServerRemote.java 4KB
CollectionDeserializer.java 4KB
StringValueDeserializer.java 4KB
NameServer.java 4KB
ExtSerializerFactory.java 4KB
MBeanAttributeInfoDeserializer.java 4KB
LocaleHandle.java 4KB
MBeanOperationInfoDeserializer.java 4KB
CollectionSerializer.java 3KB
BurlapRemote.java 3KB
EnumSerializer.java 3KB
HessianRemote.java 3KB
BurlapRemote.java 3KB
MapSerializer.java 3KB
MBeanConstructorInfoDeserializer.java 3KB
MessageSender.java 3KB
MBeanParameterInfoDeserializer.java 3KB
MBeanNotificationInfoDeserializer.java 3KB
ServiceProxyFactory.java 3KB
ObjectDeserializer.java 3KB
Hessian2StreamingOutput.java 3KB
HessianProtocolException.java 3KB
HessianInputFactory.java 3KB
MessageServiceException.java 3KB
ObjectInstanceDeserializer.java 3KB
BeanSerializerFactory.java 3KB
ArraySerializer.java 3KB
HessianRuntimeException.java 3KB
BurlapRuntimeException.java 3KB
BurlapProtocolException.java 3KB
NameServiceException.java 3KB
ValueDeserializer.java 3KB
CalendarHandle.java 3KB
HessianEnvelope.java 3KB
HessianProxyResolver.java 3KB
BurlapProxyResolver.java 3KB
BurlapProtocolException.java 3KB
SqlDateSerializer.java 3KB
EnumerationSerializer.java 3KB
ClassSerializer.java 3KB
StringValueSerializer.java 3KB
HessianServiceException.java 3KB
IteratorSerializer.java 3KB
共 136 条
- 1
- 2
bleakoasis
- 粉丝: 6
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页