本文整理汇总了Java中com.dyuproject.protostuff.ProtostuffIOUtil.mergeFrom方法的典型用法代码示例。如果您正苦于以下问题:Java ProtostuffIOUtil.mergeFrom方法的具体用法?Java ProtostuffIOUtil.mergeFrom怎么用?Java ProtostuffIOUtil.mergeFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.dyuproject.protostuff.ProtostuffIOUtil
的用法示例。
在下文中一共展示了ProtostuffIOUtil.mergeFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSeckill
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
public Seckill getSeckill(long seckillId) {
try {
Jedis jedis = jedisPool.getResource();
try {
String key = "seckill:" + seckillId;
//从字节数组到对象
byte[] bytes = jedis.get(key.getBytes());
if (bytes != null) {
Seckill seckill = schema.newMessage();
//反序列,赋值
ProtostuffIOUtil.mergeFrom(bytes, seckill, schema);
return seckill;
}
} finally {
jedis.close();
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
return null;
}
示例2: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
@Override
public Object deserialize(InputStream input) {
try {
HeartBeat message = objenesis.newInstance(HeartBeat.class);
Schema<HeartBeat> schema = getSchema(HeartBeat.class);
ProtostuffIOUtil.mergeFrom(input, message, schema);
return message;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例3: deSerialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
/**
* 反序列化对象
*
* @param param 需要反序列化的byte []
* @param clazz
* @return 对象
* @throws TransactionException
*/
@Override
public <T> T deSerialize(byte[] param, Class<T> clazz) throws TransactionException {
T object;
try( ByteArrayInputStream inputStream = new ByteArrayInputStream(param)) {
Class cls = clazz;
object = OBJENESIS_STD.newInstance((Class<T>) cls);
Schema schema = getSchema(cls);
ProtostuffIOUtil.mergeFrom(inputStream, object, schema);
return object;
} catch (Exception e) {
throw new TransactionException(e.getMessage(), e);
}
}
示例4: deSerialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
@Override
public <T> T deSerialize(byte[] param, Class<T> clazz) throws SerializerException {
T object;
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(param);
Class cls = clazz;
object = objenesis.newInstance((Class<T>) cls);
Schema schema = getSchema(cls);
ProtostuffIOUtil.mergeFrom(inputStream, object, schema);
return object;
} catch (Exception e) {
throw new SerializerException(e.getMessage(), e);
}
}
示例5: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
public <T> T deserialize(byte[] bytes) {
if(bytes == null || bytes.length == 0){
return null;
}
try {
ObjectWrapper objectWrapper = new ObjectWrapper();
//ProtobufIOUtil.mergeFrom(bytes, objectWrapper, schema);
ProtostuffIOUtil.mergeFrom(bytes, objectWrapper, schema);
return (T) objectWrapper.getObject();
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
示例6: deSerialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
/**
* 反序列化对象
*
* @param param 需要反序列化的byte []
* @param clazz
* @return 对象
* @throws TccException
*/
@Override
public <T> T deSerialize(byte[] param, Class<T> clazz) throws TccException {
T object;
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(param);
Class cls = clazz;
object = OBJENESIS_STD.newInstance((Class<T>) cls);
Schema schema = getSchema(cls);
ProtostuffIOUtil.mergeFrom(inputStream, object, schema);
return object;
} catch (Exception e) {
throw new TccException(e.getMessage(), e);
}
}
示例7: deSerialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
/**
* 反序列化对象
*
* @param param 需要反序列化的byte []
* @param clazz clazz
* @return 对象
* @throws MythException 异常
*/
@Override
public <T> T deSerialize(byte[] param, Class<T> clazz) throws MythException {
T object;
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(param);
Class cls = clazz;
object = OBJENESIS_STD.newInstance((Class<T>) cls);
Schema schema = getSchema(cls);
ProtostuffIOUtil.mergeFrom(inputStream, object, schema);
return object;
} catch (Exception e) {
throw new MythException(e.getMessage(), e);
}
}
示例8: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
public <T> T deserialize(byte[] data, Class<T> cls) {
try {
T message = (T) cls.getConstructors()[0].newInstance();
Schema<T> schema = getSchema(cls);
ProtostuffIOUtil.mergeFrom(data, message, schema);
return message;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例9: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
@Override
public <T> T deserialize(byte[] buf, Class<T> type) throws IOException {
Schema<T> schema = getSchema(type);
T msg = schema.newMessage();
ProtostuffIOUtil.mergeFrom(buf, msg, schema);
return (T) msg;
}
示例10: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
public Object deserialize(InputStream input) {
try {
Class cls = isRpcDirect() ? MessageRequest.class : MessageResponse.class;
Object message = (Object) objenesis.newInstance(cls);
Schema<Object> schema = getSchema(cls);
ProtostuffIOUtil.mergeFrom(input, message, schema);
return message;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例11: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
@Override
public <T> T deserialize(byte[] bytes, Class<T> clz) throws IOException, ClassNotFoundException {
try {
T message = (T) objenesis.newInstance(clz);
Schema<T> schema = getSchema(clz);
ProtostuffIOUtil.mergeFrom(bytes, message, schema);
return message;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例12: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
/**
* 反序列化对象
*
* @param paramArrayOfByte
* @param targetClass
* @return
*/
public static <T> T deserialize(byte[] paramArrayOfByte, Class<T> targetClass) {
if (paramArrayOfByte == null || paramArrayOfByte.length == 0) {
throw new RuntimeException("反序列化对象发生异常,byte序列为空!");
}
T instance = null;
try {
instance = targetClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException("反序列化过程中依据类型创建对象失败!", e);
}
Schema<T> schema = RuntimeSchema.getSchema(targetClass);
ProtostuffIOUtil.mergeFrom(paramArrayOfByte, instance, schema);
return instance;
}
示例13: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
@Override
public <T> T deserialize(byte[] bytes, Class<T> clazz) throws SerializationException {
try {
T message = clazz.newInstance();
Schema schema = getSchema(clazz);
ProtostuffIOUtil.mergeFrom(bytes, message, schema);
return message;
} catch (Throwable e) {
throw new SerializationException(e.getMessage(), e);
}
}
示例14: deserialize
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
@Override
public <T> Object deserialize(byte[] bytes, Class<T> clazz) {
try {
T message = (T) objenesis.newInstance(clazz);
Schema<T> schema = getSchema(clazz);
ProtostuffIOUtil.mergeFrom(bytes, message, schema);
return message;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例15: fromBinaryJava
import com.dyuproject.protostuff.ProtostuffIOUtil; //导入方法依赖的package包/类
@Override
public Object fromBinaryJava(byte[] content, Class<?> claz)
{
try {
Schema schema = RuntimeSchema.getSchema(claz);
Object product = claz.newInstance();
ProtostuffIOUtil.mergeFrom(content, product, schema);
return product;
} catch (Exception e) {
LOG.error("无法反序列化" + claz);
}
return null;
}