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


Java ProtostuffIOUtil.mergeFrom方法代码示例

本文整理汇总了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;
}
 
开发者ID:jessezwd,项目名称:HCS,代码行数:24,代码来源:RedisDao.java

示例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);
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:12,代码来源:ProtostuffSerialize.java

示例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);
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:22,代码来源:ProtostuffSerializer.java

示例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);
    }
}
 
开发者ID:1991wangliang,项目名称:tx-lcn,代码行数:15,代码来源:ProtostuffSerializer.java

示例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);
	}
}
 
开发者ID:penggle,项目名称:xproject,代码行数:14,代码来源:ProtostuffSerializer.java

示例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);
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-tcc,代码行数:23,代码来源:ProtostuffSerializer.java

示例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);
    }
}
 
开发者ID:yu199195,项目名称:myth,代码行数:23,代码来源:ProtostuffSerializer.java

示例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);
    }
}
 
开发者ID:linuer,项目名称:nan,代码行数:11,代码来源:ProtoStuffSerializer.java

示例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;
}
 
开发者ID:TFdream,项目名称:mango,代码行数:8,代码来源:ProtostuffSerializer.java

示例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);
    }
}
 
开发者ID:craware,项目名称:webapp-tyust,代码行数:12,代码来源:ProtostuffSerialize.java

示例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);
       }
}
 
开发者ID:chenxh,项目名称:rpc,代码行数:12,代码来源:ProtostuffSerialization.java

示例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;
}
 
开发者ID:melonlee,项目名称:PowerApi,代码行数:22,代码来源:ProtoStuffSerializerUtil.java

示例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);
    }
}
 
开发者ID:justimkiss,项目名称:bee,代码行数:12,代码来源:ProtostuffSerializer.java

示例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);
       }
}
 
开发者ID:xuxueli,项目名称:xxl-incubator,代码行数:12,代码来源:ProtostuffSerializer.java

示例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;
}
 
开发者ID:beykery,项目名称:bakka,代码行数:14,代码来源:BakkaSerializer.java


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