本文整理汇总了Java中com.caucho.hessian.io.AbstractHessianOutput类的典型用法代码示例。如果您正苦于以下问题:Java AbstractHessianOutput类的具体用法?Java AbstractHessianOutput怎么用?Java AbstractHessianOutput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractHessianOutput类属于com.caucho.hessian.io包,在下文中一共展示了AbstractHessianOutput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: write
import com.caucho.hessian.io.AbstractHessianOutput; //导入依赖的package包/类
void write(AbstractHessianOutput out, Sort.Order order) throws IOException {
if (order.getDirection() == null) {
out.writeNull();
}
else {
out.writeString(order.getDirection().name());
}
out.writeString(order.getProperty());
out.writeBoolean(order.isIgnoreCase());
if (order.getNullHandling() == null) {
out.writeNull();
}
else {
out.writeString(order.getNullHandling().name());
}
}
示例5: 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();
}
}
示例6: 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;
}
示例7: 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);
}
}
示例8: 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();
}
示例9: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入依赖的package包/类
@Override
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {
if (obj == null)
out.writeNull();
else {
Class<?> cl = obj.getClass();
if (out.addRef(obj)) return;
int ref = out.writeObjectBegin(cl.getName());
Pageable dest = (Pageable) obj;
if (ref < -1) {
out.writeString("value");
write(out, dest);
out.writeMapEnd();
}
else {
if (ref == -1) {
out.writeInt(1);
out.writeString("value");
out.writeObjectBegin(cl.getName());
}
write(out, dest);
}
}
}
示例10: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入依赖的package包/类
@Override
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {
if (obj == null)
out.writeNull();
else {
Class<?> cl = obj.getClass();
if (out.addRef(obj)) return;
int ref = out.writeObjectBegin(cl.getName());
Sort.Order order = (Sort.Order) obj;
if (ref < -1) {
out.writeString("value");
write(out, order);
out.writeMapEnd();
}
else {
if (ref == -1) {
out.writeInt(1);
out.writeString("value");
out.writeObjectBegin(cl.getName());
}
write(out, order);
}
}
}
示例11: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入依赖的package包/类
@Override
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {
if (obj == null)
out.writeNull();
else {
Class<?> cl = obj.getClass();
if (out.addRef(obj)) return;
int ref = out.writeObjectBegin(cl.getName());
Sort dest = (Sort) obj;
if (ref < -1) {
out.writeString("value");
write(out, dest);
out.writeMapEnd();
}
else {
if (ref == -1) {
out.writeInt(1);
out.writeString("value");
out.writeObjectBegin(cl.getName());
}
write(out, dest);
}
}
}
示例12: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入依赖的package包/类
@Override
public void writeObject(Object obj, final AbstractHessianOutput out) throws IOException {
try {
if (out.addRef(obj)) {
return;
}
Transcribable transcribable = (Transcribable) obj;
ServiceVersion serviceVersion = transcribable.getServiceVersion();
Class clazz = obj.getClass();
String classNameToWrite = clazz.getName();
// if we're talking to an older version we need to migrate vMajor to vMajor_Minor
if (!transcriptionParams.contains(TranscribableParams.MajorOnlyPackageNaming)) {
// look for vMajor
classNameToWrite = ClassnameCompatibilityMapper.toMajorMinorPackaging(clazz, serviceVersion);
}
int ref = out.writeObjectBegin(classNameToWrite);
// true if the object has already been defined
if (ref >= 0) {
transcribe(out,transcribable, client);
}
else {
Parameter[] parameters = transcribable.getParameters();
out.writeInt(parameters.length);
for (int i=0; i < parameters.length; i++) {
out.writeString(parameters[i].getName());
}
out.writeObjectBegin(classNameToWrite);
transcribe(out,transcribable, client);
}
}
catch (Exception e) {
throw new IOException(e);
}
}
示例13: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入依赖的package包/类
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {
if (out.addRef(obj)) {
return;
}
Class cl = obj.getClass();
String name = null;
try {
name = (String) _name.invoke(obj, (Object[]) null);
} catch (Exception e) {
throw new RuntimeException(e);
}
// if we're talking to an older version we need to migrate vMajor to vMajor_Minor
String className = cl.getName();
if (!transcriptionParams.contains(TranscribableParams.MajorOnlyPackageNaming)) {
className = ClassnameCompatibilityMapper.toMajorMinorPackaging(cl, _serviceVersion);
}
int ref = out.writeObjectBegin(className);
if (ref < -1) {
out.writeString("name");
out.writeString(name);
out.writeMapEnd();
}
else {
if (ref == -1) {
out.writeClassFieldLength(1);
out.writeString("name");
out.writeObjectBegin(className);
}
out.writeString(name);
}
}
示例14: writeObject
import com.caucho.hessian.io.AbstractHessianOutput; //导入依赖的package包/类
@Override
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException {
if (obj == null) {
out.writeNull();
} else {
if (out.addRef(obj)) {
return;
}
Class<?> cl = obj.getClass();
int ref = out.writeObjectBegin(cl.getName());
if (ref < -1) {
out.writeString("value");
out.writeString(jodaObjectToString(obj));
out.writeMapEnd();
} else {
if (ref == -1) {
out.writeInt(1);
out.writeString("value");
out.writeObjectBegin(cl.getName());
}
out.writeString(jodaObjectToString(obj));
}
}
}
示例15: getAndCreateOutput
import com.caucho.hessian.io.AbstractHessianOutput; //导入依赖的package包/类
static AbstractHessianOutput getAndCreateOutput(OutputStream os) {
final Hessian2Output output = new Hessian2Output(os);
output.setSerializerFactory(serializerFactory);
return output;
}