java hessian2_Java Hessian2Output類代碼示例

本文整理匯總了Java中com.caucho.hessian.io.Hessian2Output類的典型用法代碼示例。如果您正苦於以下問題:Java Hessian2Output類的具體用法?Java Hessian2Output怎麽用?Java Hessian2Output使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。

Hessian2Output類屬於com.caucho.hessian.io包,在下文中一共展示了Hessian2Output類的35個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: writeExternal

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

/**

* using Hessian-SM serialize protocol

* @param out - Hessian2Output

* @throws IOException

*/

@Override

public void writeExternal(Hessian2Output out) throws IOException {

out.writeInt(opType.value);

out.writeInt(remove);

out.writeInt(errorCode);

out.writeBytes( BlockUtil.toKeyBytes( key));

if ( value == null )

out.writeBoolean(true);

else {

out.writeBoolean(false);

out.writeBytes( Utils.valueToBytes( value));

}

}

開發者ID:viant,項目名稱:CacheStore,代碼行數:21,

示例2: serialize

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public byte[] serialize(Object obj) throws Exception {

if(obj == null) {

return null;

}

ByteArrayOutputStream outputStream=new ByteArrayOutputStream();

AbstractHessianOutput output=new Hessian2Output(outputStream);

output.setSerializerFactory(serializerFactory);

// 將對象寫到流裏

output.writeObject(obj);

output.flush();

byte[] val=outputStream.toByteArray();

output.close();

return val;

}

開發者ID:hailin0,項目名稱:pagecache-parent,代碼行數:17,

示例3: encode

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

protected Object encode(ChannelHandlerContext ctx, Channel channel,

Object msg) throws Exception {

ChannelBufferOutputStream bout = new ChannelBufferOutputStream(

dynamicBuffer(1024, ctx.getChannel().getConfig()

.getBufferFactory()));

bout.write(LENGTH_PLACEHOLDER);

Hessian2Output h2o = new Hessian2Output(bout);

try {

h2o.writeObject(msg);

h2o.flush();

} finally {

h2o.close();

}

ChannelBuffer encoded = bout.buffer();

encoded.setInt(0, encoded.writerIndex() - 4);

return encoded;

}

開發者ID:jbeetle,項目名稱:BJAF3.x,代碼行數:19,

示例4: marshal

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public void marshal(final Exchange exchange, final Object graph, final OutputStream outputStream) throws Exception {

final Hessian2Output out = new Hessian2Output(outputStream);

try {

out.startMessage();

out.writeObject(graph);

out.completeMessage();

} finally {

out.flush();

try {

out.close();

} catch (IOException e) {

// ignore

}

}

}

開發者ID:HydAu,項目名稱:Camel,代碼行數:17,

示例5: writeStringMultiMap

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static boolean writeStringMultiMap(Hessian2Output dos, HashMap> map) {

try {

dos.writeInt(map.size());

for (String s : map.keySet()) {

dos.writeString(s);

ArrayList values = map.get(s);

dos.writeInt(values.size());

for (String str : values) {

dos.writeString(str);

}

}

} catch (IOException e) {

return false;

}

return true;

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:17,

示例6: writeIntArray

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static boolean writeIntArray(Hessian2Output dos, int[] intArray) {

try {

if (intArray == null) {

dos.writeInt(0);

return true;

}

dos.writeInt(intArray.length);

for (int i : intArray) {

dos.writeInt(i);

}

} catch (IOException e) {

return false;

}

return true;

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:17,

示例7: writePrimitiveSite

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static boolean writePrimitiveSite(Hessian2Output dos, PrimitiveSite p, Device device, HashPool primitivePinPool) {

try {

// Write Name

dos.writeString(p.getName());

// Write Type

dos.writeInt(p.getType().ordinal());

// Write Tile (Unique Integer)

dos.writeInt(p.getTile().getUniqueAddress());

// Write PinMap

dos.writeInt(primitivePinPool.getEnumerationValue(new PrimitivePinMap(p.getPins())));

} catch (IOException e) {

return false;

}

return true;

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:20,

示例8: writeWireHashMap

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static boolean writeWireHashMap(Hessian2Output dos, WireHashMap wires,

HashPool wireArrayPool, HashPool wireConnectionPool) {

int[] wireConnections;

if (wires == null) {

wireConnections = new int[0];

} else {

wireConnections = new int[wires.size()];

int ndx = 0;

for (Integer key : wires.keySet()) {

WireArrayConnection tmp = new WireArrayConnection(key, wireArrayPool.getEnumerationValue(new WireArray(wires.get(key))));

wireConnections[ndx] = wireConnectionPool.getEnumerationValue(tmp);

ndx++;

}

}

writeIntArray(dos, wireConnections);

return true;

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:21,

示例9: serialize

​點讚 3

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public byte[] serialize(final Object obj) throws Exception {

if(obj == null) {

return null;

}

ByteArrayOutputStream outputStream=new ByteArrayOutputStream();

AbstractHessianOutput output=new Hessian2Output(outputStream);

output.setSerializerFactory(SERIALIZER_FACTORY);

// 將對象寫到流裏

output.writeObject(obj);

output.flush();

byte[] val=outputStream.toByteArray();

output.close();

return val;

}

開發者ID:qiujiayu,項目名稱:AutoLoadCache,代碼行數:17,

示例10: serialize

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public void serialize(OutputStream output, Object object) {

Hessian2Output ho = new Hessian2Output(output);

try {

ho.startMessage();

ho.writeObject(object);

ho.completeMessage();

ho.close();

output.close();

} catch (IOException e) {

e.printStackTrace();

}

}

開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:14,

示例11: encodeResponse

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public void encodeResponse(OutputStream outputStream, RpcResponse result)

throws IOException {

Hessian2Output out = new Hessian2Output(outputStream);

out.writeObject(result);

out.flush();

}

開發者ID:zhaoshiling1017,項目名稱:voyage,代碼行數:8,

示例12: encodeRequest

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public void encodeRequest(OutputStream outputStream, RpcRequest request)

throws IOException {

Hessian2Output out = new Hessian2Output(outputStream);

out.writeObject(request);

out.flush();

}

開發者ID:zhaoshiling1017,項目名稱:voyage,代碼行數:8,

示例13: serialize

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public byte[] serialize(Object data) throws IOException {

ByteArrayOutputStream bos = new ByteArrayOutputStream();

Hessian2Output out = new Hessian2Output(bos);

out.writeObject(data);

out.flush();

return bos.toByteArray();

}

開發者ID:chenxh,項目名稱:rpc,代碼行數:9,

示例14: toBytes

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public byte[] toBytes(Object object) {

ByteArrayOutputStream baos = new ByteArrayOutputStream();

try {

Hessian2Output oos = new Hessian2Output(baos);

oos.writeObject(object);

oos.flushBuffer();

}

catch (java.io.IOException ioe) {

throw new RuntimeException(ioe.getMessage(), ioe);

}

return baos.toByteArray();

}

開發者ID:viant,項目名稱:CacheStore,代碼行數:14,

示例15: writeExternal

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public void writeExternal(Hessian2Output out) throws IOException {

out.writeInt(opType.value);

if ( size() == 0)

out.writeBoolean(true);

else {

out.writeBoolean( false);

out.writeInt(size());

for (StoreParas each : list ) {

//out.writeBytes( each.toBytes());

out.writeObject( each);

}

}

}

開發者ID:viant,項目名稱:CacheStore,代碼行數:15,

示例16: encode

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public byte[] encode(Object object) throws Exception {

ByteArrayOutputStream byteArray = new ByteArrayOutputStream();

Hessian2Output output = new Hessian2Output(byteArray);

output.writeObject(object);

output.close();

byte[] bytes = byteArray.toByteArray();

return bytes;

}

開發者ID:leeyazhou,項目名稱:nfs-rpc,代碼行數:9,

示例17: toByteArray

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@SneakyThrows

@Override

public byte[] toByteArray(T t) throws MetaClientException {

checkNotNull(t);

try (ByteArrayOutputStream os = new ByteArrayOutputStream(defaultByteArrayBufferSize)) {

Hessian2Output ho = new Hessian2Output(os);

ho.writeObject(t);

ho.flush();

return os.toByteArray();

}

}

示例18: serialize

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public byte[] serialize(Object obj) throws Exception {

UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream();

Hessian2Output out = new Hessian2Output(bos);

out.startMessage();

out.writeObject(obj);

out.completeMessage();

out.close();

return bos.toByteArray();

}

開發者ID:WenZuHuai,項目名稱:light-task-scheduler,代碼行數:12,

示例19: serialize

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public byte[] serialize(Object obj) {

ByteArrayOutputStream os = new ByteArrayOutputStream();

Hessian2Output ho = new Hessian2Output(os);

try {

ho.writeObject(obj);

ho.flushBuffer();

} catch (IOException e) {

e.printStackTrace();

}

return os.toByteArray();

}

開發者ID:addisonli,項目名稱:addison-common-cached,代碼行數:14,

示例20: writeTo

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public void writeTo(InternalResponse> response, InternalRequest> request) {

try {

Hessian2Output out = new Hessian2Output(response.getOutputStream());

out.startMessage();

out.writeObject(response.getEntity().get());

out.completeMessage();

out.flushBuffer();

out.flush();

} catch (IOException e) {

throw new RuntimeException("An error occurred during marshalling to Hessian.", e);

}

}

開發者ID:petrbouda,項目名稱:joyrest,代碼行數:14,

示例21: debugWritingSize

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

private static void debugWritingSize(Hessian2Output hos, FileOutputStream fos,

String variableName, Long[] locations) {

try {

hos.flush();

locations[0] = fos.getChannel().position();

System.out.printf("%10d bytes : %s\n", (locations[0] - locations[1]), variableName);

locations[1] = locations[0];

} catch (IOException e) {

return;

}

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:13,

示例22: getOutputStream

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static Hessian2Output getOutputStream(String fileName) {

FileOutputStream fos;

try {

fos = new FileOutputStream(fileName);

BufferedOutputStream bos = new BufferedOutputStream(fos);

Hessian2Output hos = new Hessian2Output(bos);

Deflation dos = new Deflation();

return dos.wrap(hos);

} catch (Exception e) {

MessageGenerator.briefError("Problem opening stream for file: " + fileName);

}

return null;

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:14,

示例23: writeStringArray

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static boolean writeStringArray(Hessian2Output dos, String[] stringArray) {

int size = 0;

for (String s : stringArray) {

size += s.length() + 1;

}

try {

dos.writeInt(stringArray.length);

for (int i = 0; i < stringArray.length; i++) {

dos.writeString(stringArray[i]);

}

} catch (IOException e) {

return false;

}

return true;

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:16,

示例24: writeIntegerHashSet

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static boolean writeIntegerHashSet(Hessian2Output dos, HashSet ints) {

int[] nums = new int[ints.size()];

int idx = 0;

for (Integer i : ints) {

nums[idx] = i;

idx++;

}

return writeIntArray(dos, nums);

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:10,

示例25: saveToCompressedFile

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static boolean saveToCompressedFile(Object o, String fileName) {

Hessian2Output hos = getOutputStream(fileName);

try {

hos.writeObject(o);

hos.close();

} catch (IOException e) {

return false;

}

return true;

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:11,

示例26: write

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

private static byte[] write(Object obj) throws Exception {

ByteArrayOutputStream outputStream=new ByteArrayOutputStream();

Hessian2Output output=new Hessian2Output(outputStream);

output.setSerializerFactory(SERIALIZER_FACTORY);

output.writeObject(obj);

output.flush();

return outputStream.toByteArray();

}

開發者ID:qiujiayu,項目名稱:AutoLoadCache,代碼行數:9,

示例27: serialize

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public static byte[] serialize(Object obj) throws IOException {

ByteArrayOutputStream bos = new ByteArrayOutputStream();

Hessian2Output out = new Hessian2Output(bos);

out.writeObject(obj);

out.close();

return bos.toByteArray();

}

開發者ID:zxcpro,項目名稱:zing,代碼行數:8,

示例28: serialize

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public byte[] serialize(T data) throws Exception {

ByteArrayOutputStream bos = new ByteArrayOutputStream();

Hessian2Output out = new Hessian2Output(bos);

// out.startMessage();

out.writeObject(data);

// out.completeMessage();

out.flush();

return bos.toByteArray();

}

開發者ID:dinstone,項目名稱:com.dinstone.rpc,代碼行數:10,

示例29: enSerialize

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public byte[] enSerialize(Object message) throws IOException {

ByteArrayOutputStream byteArray = new ByteArrayOutputStream();

Hessian2Output output = new Hessian2Output(byteArray);

output.writeObject(message);

output.close();

byte[] bytes = byteArray.toByteArray();

return bytes;

}

開發者ID:ReliefZk,項目名稱:minor-rpc,代碼行數:10,

示例30: getAndCreateOutput

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

static AbstractHessianOutput getAndCreateOutput(OutputStream os) {

final Hessian2Output output = new Hessian2Output(os);

output.setSerializerFactory(serializerFactory);

return output;

}

開發者ID:5waynewang,項目名稱:commons-jkit,代碼行數:6,

示例31: Hessian2ObjectOutput

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

public Hessian2ObjectOutput(OutputStream os) {

mH2o = new Hessian2Output(os);

mH2o.setSerializerFactory(Hessian2SerializerFactory.SERIALIZER_FACTORY);

}

開發者ID:MOBX,項目名稱:Thor,代碼行數:5,

示例32: writeCompactEnumFile

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

/**

* Save class members to a file. Used to save this class to a file. Should be used with

* the corresponding method readCompactEnumFile().

*

* @param fileName Name of the file to be created.

* @return True if successful, false otherwise.

*/

public boolean writeCompactEnumFile(String fileName) {

try {

Hessian2Output hos = FileTools.getOutputStream(fileName);

//=======================================================//

/* public static final String wireEnumeratorVersion; */

//=======================================================//

hos.writeString(wireEnumeratorVersion);

//=======================================================//

/* private HashMap wireMap; */

//=======================================================//

// We'll rebuild this from wireArray

//=======================================================//

/* private String[] wireArray; */

//=======================================================//

if (!FileTools.writeStringArray(hos, wireArray)) {

System.out.println("Failed to write out wireArray.");

return false;

}

//=======================================================//

/* private WireType[] wireTypeArray; */

/* private WireDirection[] wireDirectionArray; */

//=======================================================//

int[] wireAttributes = new int[wireArray.length];

for (int i = 0; i < wireAttributes.length; i++) {

wireAttributes[i] = (getWireDirection(i).ordinal() << 16) + getWireType(i).ordinal();

}

if (!FileTools.writeIntArray(hos, wireAttributes)) {

System.out.println("Failed to write out wireAttributes.");

return false;

}

//=======================================================//

/* private HashSet pipWireNames; */

//=======================================================//

int[] pips = new int[pipWireNames.size()];

int j = 0;

for (String s : pipWireNames) {

pips[j] = getWireEnum(s);

j++;

}

if (!FileTools.writeIntArray(hos, pips)) {

System.out.println("Failed to write out pipWires.");

return false;

}

hos.close();

} catch (IOException e) {

MessageGenerator.briefErrorAndExit("Error writing to file: " + fileName);

}

return true;

}

開發者ID:ComputerArchitectureGroupPWr,項目名稱:JGenerilo,代碼行數:64,

示例33: encodeDubboRequest

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public void encodeDubboRequest(Request request, DubboData dd) throws Exception {

DubboHessianRequest dubboreq = request.pojo();

// set flag

DubboHeader dh = dubboreq.getDubboHeader();

dh.setFlag((byte) (FLAG_REQUEST | FLAG_TWOWAY | HESSIAN_SERIALIZATION_ID) );

// set body

ByteArrayOutputStream bos = new ByteArrayOutputStream();

Hessian2Output h2out = hessianFactory.createHessian2Output(bos);

String dubboVersion = dubboreq.getDubboVersion();

if( null == dubboVersion ) dubboVersion = DEFAULT_DUBBO_VERSION;

h2out.writeString(dubboVersion);

String service = dubboreq.getService();

h2out.writeString(service);

String version = dubboreq.getVersion();

if( null == version ) version = DEFAULT_METHOD_VERSION;

h2out.writeString(version);

String method = dubboreq.getMethod();

h2out.writeString(method);

Class>[] argtypes = CollectionUtil.objects2Classes( dubboreq.getArgs() );

String argsdesc = ReflectUtils.getDesc(argtypes);

h2out.writeString(argsdesc);

for( Object obj : dubboreq.getArgs() ){

h2out.writeObject(obj);

}

Map attachments = dubboreq.getAttachments();

h2out.writeObject(attachments);

h2out.close();

byte[] body = bos.toByteArray();

dd.setDubboHeader(dubboreq.getDubboHeader());

dd.setBody(body);

log.debug("encodeDubboRequest dubboVersion:{} service:{} version:{} method:{} args.size:{} attachments:{}",

dubboVersion, service, version, method, argtypes.length, YmlUtil.obj2Yml(attachments));

}

開發者ID:JD-wangyin,項目名稱:Ak47,代碼行數:48,

示例34: encodeDubboResponse

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

@Override

public void encodeDubboResponse(Response response, DubboData dd) throws Exception {

DubboHessianResponse dubbores = response.pojo();

// set flag

DubboHeader dh = dubbores.getDubboHeader();

dd.setDubboHeader(dubbores.getDubboHeader());

// set body

dh.setFlag((byte) (dh.getFlag() | HESSIAN_SERIALIZATION_ID) );

ByteArrayOutputStream bos = new ByteArrayOutputStream();

Hessian2Output h2out = hessianFactory.createHessian2Output(bos);

h2out.writeInt(RESPONSE_VALUE);

h2out.writeObject(dubbores.getResult());

h2out.close();

byte[] body = bos.toByteArray();

dd.setBody(body);

}

開發者ID:JD-wangyin,項目名稱:Ak47,代碼行數:26,

示例35: HessianObjectOutput

​點讚 2

import com.caucho.hessian.io.Hessian2Output; //導入依賴的package包/類

HessianObjectOutput(OutputStream wrapped, SerializerFactory factory) {

hessian2Output = new Hessian2Output(wrapped);

hessian2Output.setSerializerFactory(factory);

}

開發者ID:betfair,項目名稱:cougar,代碼行數:5,

注:本文中的com.caucho.hessian.io.Hessian2Output類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值