本文整理汇总了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());
}
示例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: 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)));
}
};
}
示例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();
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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());
}
示例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);
}
}
示例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);
}
示例14: getMarshaller
import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
public static Marshaller getMarshaller(final MarshallingConfiguration config) throws IOException {
return MARSHALLER_FACTORY.createMarshaller(config);
}
示例15: getMarshaller
import org.jboss.marshalling.Marshaller; //导入依赖的package包/类
/**
* Get a {@link Marshaller} for the given {@link ChannelHandlerContext}
*/
Marshaller getMarshaller(ChannelHandlerContext ctx) throws Exception;