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

Java MarshallerFactory类代码示例

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

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



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

示例1: readWithJBossMarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
private void readWithJBossMarshalling(byte[] bytes, long[] result) throws IOException, ClassNotFoundException {
   MarshallingConfiguration configuration = new MarshallingConfiguration();
   configuration.setVersion(3);
   MarshallerFactory marshallerFactory = Marshalling.getProvidedMarshallerFactory("river");

   ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
   long tStart = System.nanoTime();
   for (int i = 0; i < NUM_INNER_LOOPS; i++) {
      Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
      unmarshaller.start(Marshalling.createByteInput(bais));
      unmarshaller.readObject();
      unmarshaller.finish();
      bais.close();
      bais.reset();
   }
   result[0] = System.nanoTime() - tStart;
   log.infof("JBoss marshalling read duration     = %d ns", result[0]);
}
 
开发者ID:infinispan,项目名称:protostream,代码行数:19,代码来源:PerformanceTest.java


示例2: testSimpleUnmarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的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


示例3: testTooBigObject

import org.jboss.marshalling.MarshallerFactory; //导入依赖的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


示例4: testSimpleUnmarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的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


示例5: writeWithJBossMarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的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: buildMarshallingDecoder

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
/**
   * 创建Jboss Marshalling解码器MarshallingDecoder
   * @return MarshallingDecoder
   */
  public static MarshallingDecoder buildMarshallingDecoder() {
  	//首先通过Marshalling工具类的精通方法获取Marshalling实例对象 参数serial标识创建的是java序列化工厂对象。
final MarshallerFactory marshallerFactory = Marshalling.getProvidedMarshallerFactory("serial");
//创建了MarshallingConfiguration对象,配置了版本号为5 
final MarshallingConfiguration configuration = new MarshallingConfiguration();
configuration.setVersion(5);
//根据marshallerFactory和configuration创建provider
UnmarshallerProvider provider = new DefaultUnmarshallerProvider(marshallerFactory, configuration);
//构建Netty的MarshallingDecoder对象,俩个参数分别为provider和单个消息序列化后的最大长度
MarshallingDecoder decoder = new MarshallingDecoder(provider, 1024);
return decoder;
  }
 
开发者ID:craware,项目名称:webapp-tyust,代码行数:17,代码来源:MarshallingCodeCFactory.java


示例7: buildMarshallingEncoder

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
/**
   * 创建Jboss Marshalling编码器MarshallingEncoder
   * @return MarshallingEncoder
   */
  public static MarshallingEncoder buildMarshallingEncoder() {
final MarshallerFactory marshallerFactory = Marshalling.getProvidedMarshallerFactory("serial");
final MarshallingConfiguration configuration = new MarshallingConfiguration();
configuration.setVersion(5);
MarshallerProvider provider = new DefaultMarshallerProvider(marshallerFactory, configuration);
//构建Netty的MarshallingEncoder对象,MarshallingEncoder用于实现序列化接口的POJO对象序列化为二进制数组
MarshallingEncoder encoder = new MarshallingEncoder(provider);
return encoder;
  }
 
开发者ID:craware,项目名称:webapp-tyust,代码行数:14,代码来源:MarshallingCodeCFactory.java


示例8: buildMarshallingDecoder

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
/**
 * 创建Jboss Marshalling解码器
 * @return
 */
public static MarshallingDecoder buildMarshallingDecoder() {
	MarshallerFactory factory = Marshalling.getProvidedMarshallerFactory("serial");
	MarshallingConfiguration configuration = new MarshallingConfiguration();
	configuration.setVersion(5);
	UnmarshallerProvider provider = new DefaultUnmarshallerProvider(factory, configuration);
	MarshallingDecoder decoder = new MarshallingDecoder(provider, 1024);
	return decoder;
	
}
 
开发者ID:hdcuican,项目名称:java_learn,代码行数:14,代码来源:MarshallingCodeCFactory.java


示例9: buildMarshallingEncoder

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
/**
 * 创建Jboss Marshalling编码器
 * @return
 */
public static MarshallingEncoder buildMarshallingEncoder() {
	MarshallerFactory factory = Marshalling.getProvidedMarshallerFactory("serial");
	MarshallingConfiguration configuration = new MarshallingConfiguration();
	configuration.setVersion(5);
	MarshallerProvider provider = new DefaultMarshallerProvider(factory, configuration);
	MarshallingEncoder encoder = new MarshallingEncoder(provider);
	return encoder;
	
}
 
开发者ID:hdcuican,项目名称:java_learn,代码行数:14,代码来源:MarshallingCodeCFactory.java


示例10: buildMarshallingDecoder

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
/**
    * 创建Jboss Marshalling解码器MarshallingDecoder
    * 
    * @return
    */
   public static MarshallingDecoder buildMarshallingDecoder() {
final MarshallerFactory marshallerFactory = Marshalling
	.getProvidedMarshallerFactory("serial");
final MarshallingConfiguration configuration = new MarshallingConfiguration();
configuration.setVersion(5);
UnmarshallerProvider provider = new DefaultUnmarshallerProvider(
	marshallerFactory, configuration);
MarshallingDecoder decoder = new MarshallingDecoder(provider, 1024*1024*10);
return decoder;
   }
 
开发者ID:huisongyang,项目名称:fileserver,代码行数:16,代码来源:MarshallingCodeCFactory.java


示例11: buildMarshallingEncoder

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
/**
    * 创建Jboss Marshalling编码器MarshallingEncoder
    * 
    * @return
    */
   public static MarshallingEncoder buildMarshallingEncoder() {
final MarshallerFactory marshallerFactory = Marshalling
	.getProvidedMarshallerFactory("serial");
final MarshallingConfiguration configuration = new MarshallingConfiguration();
configuration.setVersion(5);
MarshallerProvider provider = new DefaultMarshallerProvider(
	marshallerFactory, configuration);
MarshallingEncoder encoder = new MarshallingEncoder(provider);
return encoder;
   }
 
开发者ID:huisongyang,项目名称:fileserver,代码行数:16,代码来源:MarshallingCodeCFactory.java


示例12: buildMarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的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


示例13: buildUnMarshalling

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


示例14: buildMarshallingDecoder

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
/**
    * 创建Jboss Marshalling解码器MarshallingDecoder
    * 
    * @return
    */
   public static MarshallingDecoder buildMarshallingDecoder() {
final MarshallerFactory marshallerFactory = Marshalling
	.getProvidedMarshallerFactory("serial");
final MarshallingConfiguration configuration = new MarshallingConfiguration();
configuration.setVersion(5);
UnmarshallerProvider provider = new DefaultUnmarshallerProvider(
	marshallerFactory, configuration);
MarshallingDecoder decoder = new MarshallingDecoder(provider, 1024);
return decoder;
   }
 
开发者ID:changyuefeng,项目名称:netty-book,代码行数:16,代码来源:MarshallingCodeCFactory.java


示例15: createMarshallerFactory

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
@Override
protected MarshallerFactory createMarshallerFactory() {
    return Marshalling.getProvidedMarshallerFactory("serial");
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:5,代码来源:SerialCompatibleMarshallingEncoderTest.java


示例16: testFragmentedUnmarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的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


示例17: testMarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
@Test
public void testMarshalling() throws IOException, ClassNotFoundException {
    @SuppressWarnings("RedundantStringConstructorCall")
    String testObject = new String("test");

    final MarshallerFactory marshallerFactory = createMarshallerFactory();
    final MarshallingConfiguration configuration = createMarshallingConfig();

    EmbeddedChannel ch = new EmbeddedChannel(createEncoder());

    ch.writeOutbound(testObject);
    assertTrue(ch.finish());

    ByteBuf buffer = (ByteBuf) ch.readOutbound();

    Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
    unmarshaller.start(Marshalling.createByteInput(truncate(buffer).nioBuffer()));
    String read = (String) unmarshaller.readObject();
    assertEquals(testObject, read);

    assertEquals(-1, unmarshaller.read());

    assertNull(ch.readOutbound());

    unmarshaller.finish();
    unmarshaller.close();
    buffer.release();
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:29,代码来源:AbstractCompatibleMarshallingEncoderTest.java


示例18: createMarshallerFactory

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
@Override
protected MarshallerFactory createMarshallerFactory() {
    return Marshalling.getProvidedMarshallerFactory("river");
}
 
开发者ID:kyle-liu,项目名称:netty4study,代码行数:5,代码来源:RiverCompatibleMarshallingDecoderTest.java


示例19: testFragmentedUnmarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的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


示例20: testMarshalling

import org.jboss.marshalling.MarshallerFactory; //导入依赖的package包/类
@Test
public void testMarshalling() throws Exception {
    @SuppressWarnings("RedundantStringConstructorCall")
    String testObject = new String("test");

    final MarshallerFactory marshallerFactory = createMarshallerFactory();
    final MarshallingConfiguration configuration = createMarshallingConfig();

    EmbeddedChannel ch = new EmbeddedChannel(createEncoder());

    ch.writeOutbound(testObject);
    assertTrue(ch.finish());

    ByteBuf buffer = ch.readOutbound();

    Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
    unmarshaller.start(Marshalling.createByteInput(truncate(buffer).nioBuffer()));
    String read = (String) unmarshaller.readObject();
    assertEquals(testObject, read);

    assertEquals(-1, unmarshaller.read());

    assertNull(ch.readOutbound());

    unmarshaller.finish();
    unmarshaller.close();
    buffer.release();
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:29,代码来源:AbstractCompatibleMarshallingEncoderTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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