当前位置: 首页>>代码示例>>Java>>正文


Java Hessian2Input类代码示例

本文整理汇总了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);
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:19,代码来源:X509Encryption.java

示例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);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:SerializationCompareTest.java

示例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();
    }
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:20,代码来源:X509Encryption.java

示例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);
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:20,代码来源:SerializationCompareTest.java

示例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);
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:16,代码来源:X509Signature.java

示例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
    }
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:39,代码来源:X509Signature.java

示例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);
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:16,代码来源:Java8TimeSerializerTest.java

示例8: Hessian2ObjectInput

import com.alibaba.com.caucho.hessian.io.Hessian2Input; //导入依赖的package包/类
public Hessian2ObjectInput(InputStream is)
{
	mH2i = new Hessian2Input(is);
	mH2i.setSerializerFactory(Hessian2SerializerFactory.SERIALIZER_FACTORY);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:6,代码来源:Hessian2ObjectInput.java

示例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;
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:17,代码来源:X509Encryption.java


注:本文中的com.alibaba.com.caucho.hessian.io.Hessian2Input类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。