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


Java Marshaller类代码示例

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


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


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