本文整理汇总了Java中com.caucho.hessian.io.Hessian2Output.close方法的典型用法代码示例。如果您正苦于以下问题:Java Hessian2Output.close方法的具体用法?Java Hessian2Output.close怎么用?Java Hessian2Output.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.caucho.hessian.io.Hessian2Output
的用法示例。
在下文中一共展示了Hessian2Output.close方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encode
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;
}
示例2: marshal
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
}
}
}
示例3: serialize
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();
}
}
示例4: encode
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;
}
示例5: serialize
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();
}
示例6: saveToCompressedFile
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;
}
示例7: serialize
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();
}
示例8: enSerialize
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;
}
示例9: writeCompactEnumFile
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<String,Integer> 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<String> 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;
}
示例10: encodeDubboRequest
import com.caucho.hessian.io.Hessian2Output; //导入方法依赖的package包/类
@Override
public void encodeDubboRequest(Request<DubboHessianRequest> 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<String, String> 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));
}
示例11: encodeDubboResponse
import com.caucho.hessian.io.Hessian2Output; //导入方法依赖的package包/类
@Override
public void encodeDubboResponse(Response<DubboHessianResponse> 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);
}