@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if(obj == null) { out.writeNull(); return; } T handle = null; try { Constructor<T> constructor = handleType.getConstructor(Object.class); handle = constructor.newInstance(obj); } catch (Exception e) { throw new RuntimeException("the class :" + handleType.getName() + " construct failed:" + e.getMessage(), e); } out.writeObject(handle); } }
out.writeObject(repl); out.writeObject(value); out.writeObject(value);
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) out.writeNull(); else { Calendar cal = (Calendar) obj; out.writeObject(new CalendarHandle(cal.getClass(), cal.getTimeInMillis())); } } }
out.writeObject(repl);
void serialize(AbstractHessianOutput out, Object obj, Field field) throws IOException { Object value = null; try { value = field.get(obj); } catch (IllegalAccessException e) { log.log(Level.FINE, e.toString(), e); } try { out.writeObject(value); } catch (RuntimeException e) { throw new RuntimeException(e.getMessage() + "\n Java field: " + field, e); } catch (IOException e) { throw new IOExceptionWrapper(e.getMessage() + "\n Java field: " + field, e); } } }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { Iterator iter = (Iterator) obj; boolean hasEnd = out.writeListBegin(-1, null); while (iter.hasNext()) { Object value = iter.next(); out.writeObject(value); } if (hasEnd) out.writeListEnd(); } }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { Enumeration iter = (Enumeration) obj; boolean hasEnd = out.writeListBegin(-1, null); while (iter.hasMoreElements()) { Object value = iter.nextElement(); out.writeObject(value); } if (hasEnd) out.writeListEnd(); } }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) out.writeNull(); else { Locale locale = (Locale) obj; out.writeObject(new LocaleHandle(locale.toString())); } } }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { out.writeObject(new ZoneIdHandle(obj)); } }
public void writeReply(Object o) throws IOException { startReply(); writeObject(o); completeReply(); }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; Map map = (Map) obj; Class cl = obj.getClass(); if (cl.equals(HashMap.class) || !_isSendJavaType || !(obj instanceof java.io.Serializable)) out.writeMapBegin(null); else out.writeMapBegin(obj.getClass().getName()); Iterator iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); out.writeObject(entry.getKey()); out.writeObject(entry.getValue()); } out.writeMapEnd(); } }
/** * Writes a complete method call. */ public void call(String method, Object[] args) throws IOException { int length = args != null ? args.length : 0; startCall(method, length); for (int i = 0; i < length; i++) writeObject(args[i]); completeCall(); }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) { out.writeNull(); } else { try { Field field = EnumSet.class.getDeclaredField("elementType"); field.setAccessible(true); Class type = (Class) field.get(obj); EnumSet enumSet = (EnumSet) obj; Object[] objects = enumSet.toArray(); out.writeObject(new EnumSetHandler(type, objects)); } catch (Throwable t) { throw new IOException(t); } } } }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; Collection list = (Collection) obj; Class cl = obj.getClass(); boolean hasEnd; if (cl.equals(ArrayList.class) || !_sendJavaType || !Serializable.class.isAssignableFrom(cl)) hasEnd = out.writeListBegin(list.size(), null); else hasEnd = out.writeListBegin(list.size(), obj.getClass().getName()); Iterator iter = list.iterator(); while (iter.hasNext()) { Object value = iter.next(); out.writeObject(value); } if (hasEnd) out.writeListEnd(); } }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (out.addRef(obj)) return; Object[] array = (Object[]) obj; boolean hasEnd = out.writeListBegin(array.length, getArrayType(obj.getClass())); for (int i = 0; i < array.length; i++) out.writeObject(array[i]); if (hasEnd) out.writeListEnd(); }
out.writeObject(data[i]);
public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { Optional optional = (Optional) obj; if (optional == null || !optional.isPresent()) out.writeNull(); else { out.writeObject(optional.get()); } } }
@Override public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { if (obj == null) out.writeNull(); else { Locale locale = (Locale) obj; out.writeObject(new LocaleHandle(locale.toString())); } } }
public void writeReply(Object o) throws IOException { startReply(); writeObject(o); completeReply(); }
/** * Writes a complete method call. */ public void call(String method, Object[] args) throws IOException { int length = args != null ? args.length : 0; startCall(method, length); for (int i = 0; i < length; i++) writeObject(args[i]); completeCall(); }