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


Java Marshaller.finish方法代码示例

本文整理汇总了Java中org.jboss.marshalling.Marshaller.finish方法的典型用法代码示例。如果您正苦于以下问题:Java Marshaller.finish方法的具体用法?Java Marshaller.finish怎么用?Java Marshaller.finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.marshalling.Marshaller的用法示例。


在下文中一共展示了Marshaller.finish方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSimpleUnmarshalling

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
@Test
public void testSimpleUnmarshalling() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();

    EmbeddedChannel ch = new EmbeddedChannel(createDecoder(Integer.MAX_VALUE));

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();

    byte[] testBytes = bout.toByteArray();

    ch.writeInbound(input(testBytes));
    assertTrue(ch.finish());

    String unmarshalled = (String) ch.readInbound();

    assertEquals(testObject, unmarshalled);

    assertNull(ch.readInbound());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:26,代码来源:AbstractCompatibleMarshallingDecoderTest.java

示例2: testTooBigObject

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
@Test
public void testTooBigObject() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();

    ChannelHandler mDecoder = createDecoder(4);
    EmbeddedChannel ch = new EmbeddedChannel(mDecoder);

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();

    byte[] testBytes = bout.toByteArray();
    onTooBigFrame(ch, input(testBytes));
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:19,代码来源:AbstractCompatibleMarshallingDecoderTest.java

示例3: testSimpleUnmarshalling

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
@Test
public void testSimpleUnmarshalling() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();

    EmbeddedChannel ch = new EmbeddedChannel(createDecoder(Integer.MAX_VALUE));

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();

    byte[] testBytes = bout.toByteArray();

    ch.writeInbound(input(testBytes));
    assertTrue(ch.finish());

    String unmarshalled = ch.readInbound();

    assertEquals(testObject, unmarshalled);

    assertNull(ch.readInbound());
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:26,代码来源:AbstractCompatibleMarshallingDecoderTest.java

示例4: writeWithJBossMarshalling

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
private byte[] writeWithJBossMarshalling(User user, long[] result) throws IOException {
   MarshallingConfiguration configuration = new MarshallingConfiguration();
   configuration.setVersion(3);
   MarshallerFactory marshallerFactory = Marshalling.getProvidedMarshallerFactory("river");

   ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
   long tStart = System.nanoTime();
   for (int i = 0; i < NUM_INNER_LOOPS; i++) {
      Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
      marshaller.start(Marshalling.createByteOutput(out));
      marshaller.writeObject(user);
      marshaller.finish();
      out.close();
      if (i != NUM_INNER_LOOPS - 1) {
         out.reset();
      }
   }
   result[0] = System.nanoTime() - tStart;
   log.infof("JBoss Marshalling write duration    = %d ns", result[0]);
   return out.toByteArray();
}
 
开发者ID:infinispan,项目名称:protostream,代码行数:22,代码来源:PerformanceTest.java

示例5: encode

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
    Marshaller marshaller = provider.getMarshaller(ctx);
    int lengthPos = out.writerIndex();
    out.writeBytes(LENGTH_PLACEHOLDER);
    ChannelBufferByteOutput output = new ChannelBufferByteOutput(out);
    marshaller.start(output);
    marshaller.writeObject(msg);
    marshaller.finish();
    marshaller.close();

    out.setInt(lengthPos, out.writerIndex() - lengthPos - 4);
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:14,代码来源:MarshallingEncoder.java

示例6: encode

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
    Marshaller marshaller = provider.getMarshaller(ctx);
    marshaller.start(new ChannelBufferByteOutput(out));
    marshaller.writeObject(msg);
    marshaller.finish();
    marshaller.close();
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:9,代码来源:CompatibleMarshallingEncoder.java

示例7: testFragmentedUnmarshalling

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
@Test
public void testFragmentedUnmarshalling() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();

    EmbeddedChannel ch = new EmbeddedChannel(createDecoder(Integer.MAX_VALUE));

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();

    byte[] testBytes = bout.toByteArray();

    ByteBuf buffer = input(testBytes);
    ByteBuf slice = buffer.readSlice(2);

    ch.writeInbound(slice.retain());
    ch.writeInbound(buffer);
    assertTrue(ch.finish());

    String unmarshalled = (String) ch.readInbound();

    assertEquals(testObject, unmarshalled);

    assertNull(ch.readInbound());
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:30,代码来源:AbstractCompatibleMarshallingDecoderTest.java

示例8: safeFinish

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
public static void safeFinish(final Marshaller marshaller) {
    if (marshaller != null) try {
        marshaller.finish();
    } catch (IOException e) {
        ProcessLogger.PROTOCOL_LOGGER.failedToFinishMarshaller(e, marshaller);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:8,代码来源:StreamUtils.java

示例9: testFragmentedUnmarshalling

import org.jboss.marshalling.Marshaller; //导入方法依赖的package包/类
@Test
public void testFragmentedUnmarshalling() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();

    EmbeddedChannel ch = new EmbeddedChannel(createDecoder(Integer.MAX_VALUE));

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();

    byte[] testBytes = bout.toByteArray();

    ByteBuf buffer = input(testBytes);
    ByteBuf slice = buffer.readSlice(2);

    ch.writeInbound(slice.retain());
    ch.writeInbound(buffer);
    assertTrue(ch.finish());

    String unmarshalled = ch.readInbound();

    assertEquals(testObject, unmarshalled);

    assertNull(ch.readInbound());
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:30,代码来源:AbstractCompatibleMarshallingDecoderTest.java


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