本文整理汇总了Java中com.alibaba.com.caucho.hessian.io.Hessian2Input类的典型用法代码示例。如果您正苦于以下问题:Java Hessian2Input类的具体用法?Java Hessian2Input怎么用?Java Hessian2Input使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Hessian2Input类属于com.alibaba.com.caucho.hessian.io包,在下文中一共展示了Hessian2Input类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unwrap
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
public Hessian2Input unwrap(Hessian2Input in)
throws IOException {
if (_privateKey == null)
throw new IOException("X509Encryption.unwrap requires a private key");
if (_cert == null)
throw new IOException("X509Encryption.unwrap requires a certificate");
int version = in.readEnvelope();
String method = in.readMethod();
if (!method.equals(getClass().getName()))
throw new IOException("expected hessian Envelope method '" +
getClass().getName() + "' at '" + method + "'");
return unwrapHeaders(in);
}
示例2: testH2oPerm
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
@Test
public void testH2oPerm() throws Exception
{
Bean bean = new Bean();
int len = 0;
long now = System.currentTimeMillis();
for(int i=0;i<500;i++)
{
ByteArrayOutputStream os = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(os);
out.writeObject(bean);
out.flushBuffer();
os.close();
if( i == 0 )
len = os.toByteArray().length;
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
Hessian2Input in = new Hessian2Input(is);
assertEquals(in.readObject().getClass(), Bean.class);
}
System.out.println("Hessian2 write and parse 500 times in " + (System.currentTimeMillis()-now)+"ms, size " + len);
}
示例3: close
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
public void close()
throws IOException {
Hessian2Input in = _in;
_in = null;
if (in != null) {
_cipherIn.close();
_bodyIn.close();
int len = in.readInt();
if (len != 0)
throw new IOException("Unexpected footer");
in.completeEnvelope();
in.close();
}
}
示例4: testH2oPerm
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
@Test
public void testH2oPerm() throws Exception {
Bean bean = new Bean();
int len = 0;
long now = System.currentTimeMillis();
for (int i = 0; i < 500; i++) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
Hessian2Output out = new Hessian2Output(os);
out.writeObject(bean);
out.flushBuffer();
os.close();
if (i == 0)
len = os.toByteArray().length;
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
Hessian2Input in = new Hessian2Input(is);
assertEquals(in.readObject().getClass(), Bean.class);
}
System.out.println("Hessian2 write and parse 500 times in " + (System.currentTimeMillis() - now) + "ms, size " + len);
}
示例5: unwrap
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
public Hessian2Input unwrap(Hessian2Input in)
throws IOException {
if (_cert == null)
throw new IOException("X509Signature.unwrap requires a certificate");
int version = in.readEnvelope();
String method = in.readMethod();
if (!method.equals(getClass().getName()))
throw new IOException("expected hessian Envelope method '" +
getClass().getName() + "' at '" + method + "'");
return unwrapHeaders(in);
}
示例6: close
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
public void close()
throws IOException {
Hessian2Input in = _in;
_in = null;
if (in != null) {
_bodyIn.close();
int len = in.readInt();
byte[] signature = null;
for (int i = 0; i < len; i++) {
String header = in.readString();
if ("signature".equals(header))
signature = in.readBytes();
}
in.completeEnvelope();
in.close();
if (signature == null)
throw new IOException("Expected signature");
byte[] sig = _mac.doFinal();
if (sig.length != signature.length)
throw new IOException("mismatched signature");
for (int i = 0; i < sig.length; i++) {
if (signature[i] != sig[i])
throw new IOException("mismatched signature");
}
// XXX: save principal
}
}
示例7: testJava8Time
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
private void testJava8Time(Object expected) throws IOException {
os.reset();
Hessian2Output output = new Hessian2Output(os);
output.setSerializerFactory(factory);
output.writeObject(expected);
output.flush();
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
Hessian2Input input = new Hessian2Input(is);
input.setSerializerFactory(factory);
Object actual = input.readObject();
TestCase.assertEquals(expected, actual);
}
示例8: Hessian2ObjectInput
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
public Hessian2ObjectInput(InputStream is)
{
mH2i = new Hessian2Input(is);
mH2i.setSerializerFactory(Hessian2SerializerFactory.SERIALIZER_FACTORY);
}
示例9: unwrapHeaders
import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
public Hessian2Input unwrapHeaders(Hessian2Input in)
throws IOException {
if (_privateKey == null)
throw new IOException("X509Encryption.unwrap requires a private key");
if (_cert == null)
throw new IOException("X509Encryption.unwrap requires a certificate");
InputStream is = new EncryptInputStream(in);
Hessian2Input filter = new Hessian2Input(is);
filter.setCloseStreamOnClose(true);
return filter;
}