• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Marshaller类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Marshaller类属于org.jboss.marshalling包,在下文中一共展示了Marshaller类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: CustomClassTable

import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
public CustomClassTable() {
    classLookup = new HashMap<>();
    idLookup    = new HashMap<>();

    register(new BNodeExternalizer());
    register(new BooleanLiteralExternalizer());
    register(new DateLiteralExternalizer());
    register(new DoubleLiteralExternalizer());
    register(new IntLiteralExternalizer());
    register(new StringLiteralExternalizer());
    register(new TripleExternalizer());
    register(new UriExternalizer());

    classLookup.put(11, BaseExternalizer.class);
    idLookup.put(BaseExternalizer.class,11);

    writer = new Writer() {
        @Override
        public void writeClass(Marshaller marshaller, Class<?> clazz) throws IOException {
            marshaller.writeByte((byte) ((int)idLookup.get(clazz)));
        }
    };

}
 
开发者ID:apache,项目名称:marmotta,代码行数:25,代码来源:CustomClassTable.java


示例5: 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


示例6: buildMarshalling

import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
/**
    * 创建Jboss Marshaller
    * 
    * @return
    * @throws IOException
    */
   protected static Marshaller buildMarshalling() throws IOException {
final MarshallerFactory marshallerFactory = Marshalling
	.getProvidedMarshallerFactory("serial");
final MarshallingConfiguration configuration = new MarshallingConfiguration();
configuration.setVersion(5);
Marshaller marshaller = marshallerFactory
	.createMarshaller(configuration);
return marshaller;
   }
 
开发者ID:changyuefeng,项目名称:netty-book,代码行数:16,代码来源:MarshallingCodecFactory.java


示例7: 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


示例8: 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


示例9: getMarshaller

import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
@Override
public Marshaller getMarshaller(ChannelHandlerContext ctx) throws Exception {
    Marshaller marshaller = marshallers.get();
    if (marshaller == null) {
        marshaller = factory.createMarshaller(config);
        marshallers.set(marshaller);
    }
    return marshaller;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:10,代码来源:ThreadLocalMarshallerProvider.java


示例10: 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


示例11: 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


示例12: 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


示例13: getMarshaller

import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
@Override
public Marshaller getMarshaller(ChannelHandlerContext ctx) throws Exception {
    return factory.createMarshaller(config);
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:5,代码来源:DefaultMarshallerProvider.java


示例14: getMarshaller

import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
public static Marshaller getMarshaller(final MarshallingConfiguration config) throws IOException {
    return MARSHALLER_FACTORY.createMarshaller(config);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:4,代码来源:ProtocolUtils.java


示例15: getMarshaller

import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
/**
 * Get a {@link Marshaller} for the given {@link ChannelHandlerContext}
 */
Marshaller getMarshaller(ChannelHandlerContext ctx) throws Exception;
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:5,代码来源:MarshallerProvider.java


示例16: failedToFinishMarshaller

import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
/**
 * Logs an error message indicating a failure to finish the marshaller.
 *
 * @param cause      the cause of the error.
 * @param marshaller the marshaller in error.
 */
@LogMessage(level = ERROR)
@Message(id = 37, value = "Failed to finish the marshaller %s")
void failedToFinishMarshaller(@Cause Throwable cause, Marshaller marshaller);
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:ProcessLogger.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FuzzyMode类代码示例发布时间:2022-05-23
下一篇:
Java ProviderLookup类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap