本文整理汇总了Java中com.caucho.hessian.io.AbstractHessianOutput.writeObject方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractHessianOutput.writeObject方法的具体用法?Java AbstractHessianOutput.writeObject怎么用?Java AbstractHessianOutput.writeObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.caucho.hessian.io.AbstractHessianOutput
的用法示例。
在下文中一共展示了AbstractHessianOutput.writeObject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的package包/类
@Override
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {
if(out.addRef(obj)) {
return;
}
@SuppressWarnings("unchecked")
SoftReference<Object> data=(SoftReference<Object>)obj;
int refV=out.writeObjectBegin(SoftReference.class.getName());
if(refV == -1) {
out.writeInt(1);
out.writeString("ref");
out.writeObjectBegin(SoftReference.class.getName());
}
if(data != null) {
Object ref=data.get();
if(null != ref) {
out.writeObject(ref);
} else {
out.writeNull();
}
} else {
out.writeNull();
}
}
示例2: serialize
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的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;
}
示例3: serialize
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的package包/类
public static <O> byte[] serialize(O o) throws IOException {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
final AbstractHessianOutput output = getAndCreateOutput(os);
try {
output.writeObject(o);
output.flush();
return os.toByteArray();
}
finally {
try {
os.close();
}
catch (IOException ignore) {
}
}
}
示例4: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的package包/类
@Override
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {
if(out.addRef(obj)) {
return;
}
@SuppressWarnings("unchecked")
WeakReference<Object> data=(WeakReference<Object>)obj;
int refV=out.writeObjectBegin(WeakReference.class.getName());
if(refV == -1) {
out.writeInt(1);
out.writeString("ref");
out.writeObjectBegin(WeakReference.class.getName());
}
if(data != null) {
Object ref=data.get();
if(null != ref) {
out.writeObject(ref);
} else {
out.writeNull();
}
} else {
out.writeNull();
}
}
示例5: serialize
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的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;
}
示例6: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的package包/类
@Override
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {
boolean init = Hibernate.isInitialized(obj);
if (init) {
out.writeObject(obj);
out.flush();
return;
}
if (PersistentMap.class.isAssignableFrom(obj.getClass())) {
//将没有初始化的Map序列化空的HashMap
mapSerializer.writeObject(new HashMap<Object,Object>(), out);
} else {
//将没有初始化的List,Set等序列化为空的ArrayList
collectionSeiralizer.writeObject(new ArrayList<Object>(), out);
}
}
示例7: marshal
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @see marshalsec.MarshallerBase#marshal(java.lang.Object)
*/
@Override
public byte[] marshal ( Object o ) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
AbstractHessianOutput out = createOutput(bos);
NoWriteReplaceSerializerFactory sf = new NoWriteReplaceSerializerFactory();
sf.setAllowNonSerializable(true);
out.setSerializerFactory(sf);
out.writeObject(o);
out.close();
return bos.toByteArray();
}
示例8: write
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的package包/类
void write(AbstractHessianOutput out, Pageable dest) throws IOException {
out.writeInt(dest.getPageNumber());
out.writeInt(dest.getPageSize());
out.writeObject(dest.getSort());
}
示例9: write
import com.caucho.hessian.io.AbstractHessianOutput; //导入方法依赖的package包/类
void write(AbstractHessianOutput out, Sort dest) throws IOException {
Iterator<Order> iterator = dest.iterator();
while (iterator.hasNext()) {
out.writeObject(iterator.next());
}
}