@Override public void writeObject(Object obj, com.alibaba.com.caucho.hessian.io.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); } }
@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); } }
@SuppressWarnings("rawtypes") public Serializer getSerializer(Class cl) throws HessianProtocolException { if (PersistentMap.class.isAssignableFrom(cl)) { return mapSerializer; } else if (AbstractPersistentCollection.class.isAssignableFrom(cl)) { return listSerializer; } else if (cl.getSimpleName().contains("_$$_javassist_")) { return hibernateBeanSerializer; } return super.getSerializer(cl); }
@SuppressWarnings("rawtypes") @Override public Serializer getSerializer(Class cl) throws HessianProtocolException{ if (PersistentMap.class.isAssignableFrom(cl) || PersistentBag.class.isAssignableFrom(cl)) { return serializer ; } return super.getSerializer(cl); }
@SuppressWarnings("unchecked") public Iterator<T> getElementsIterator(Object collection) { try { return ((ConcurrentHashMap<V, T>) collection).values().iterator(); } catch (ClassCastException cce) { return ((PersistentMap) collection).values().iterator(); } }
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) { return new PersistentMap(session); }
public PersistentCollection wrap(SessionImplementor session, Object collection) { return new PersistentMap( session, (java.util.Map) collection ); }
public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) { return new PersistentMap(session); }
@SuppressWarnings("unchecked") public PersistentCollection wrap(SessionImplementor session, Object collection) { return new PersistentMap(session, (ConcurrentHashMap<V, T>) collection); }