HibernateAdapter
/**
* Invoke the Object.method() called through FlashRemoting
*/
public Object invoke(Message message) {
Object results = null;
if (message instanceof RemotingMessage) {
RemotingMessage remotingMessage = (RemotingMessage) message;
results = super.invoke(remotingMessage);
// serialize the result out
try {
HibernateSerializer serializer = new HibernateSerializer();
results = serializer.translate(results);
} catch (Exception ex) {
ex.printStackTrace();
RuntimeException re = new RuntimeException(ex.getMessage());
re.setStackTrace(ex.getStackTrace());
throw re;
}
}
return results;
}
HibernateSerializer
public Object translate(Object obj) {
if (obj == null) {
return null;
}
Object result = null;
Object key = getCacheKey(obj);
if (cache.containsKey(key)) {
return cache.get(key);
}
Boolean isLazyProxy = obj instanceof HibernateProxy
&& (((HibernateProxy) obj).getHibernateLazyInitializer().isUninitialized());
if (isLazyProxy) {
result = writeHibernateProxy(obj, key);
} else if (obj instanceof PersistentMap) {
result = writePersistantMap(obj, result, key);
} else if (obj instanceof AbstractPersistentCollection) {
result = writeAbstractPersistentCollection(obj, key);
} else if (obj instanceof Collection) {
result = writeCollection(obj, key);
} else if (obj instanceof Map) {
result = writeMap(obj, key);
} else if (obj instanceof Object && (!isSimple(obj)) && !(obj instanceof ASObject)) {
result = writeBean(obj, result, key);
} else {
cache.put(key, obj);
result = obj;
}
return result;
}