本文整理汇总了Java中org.jboss.marshalling.Marshaller.start方法的典型用法代码示例。如果您正苦于以下问题:Java Marshaller.start方法的具体用法?Java Marshaller.start怎么用?Java Marshaller.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.marshalling.Marshaller
的用法示例。
在下文中一共展示了Marshaller.start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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));
}
示例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();
}
示例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);
}
示例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();
}
示例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());
}
示例8: 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