[Red5commits] [1648] added class "ObjectMap?" for objects without classnames that should be serialize
jbauch
luke at codegent.com
Wed Jan 24 11:14:20 EST 2007
added class "ObjectMap?" for objects without classnames that should be serialized as objects instead of maps after usage
Timestamp: 01/23/07 16:36:47 EST (19 hours ago)
Change: 1648
Author: jbauch
Files (see diff or trac for details):
java/server/branches/joachim_amf3_integration/src/org/red5/io/amf/Input.java
java/server/branches/joachim_amf3_integration/src/org/red5/io/amf3/Input.java
java/server/branches/joachim_amf3_integration/src/org/red5/io/amf3/Output.java
java/server/branches/joachim_amf3_integration/src/org/red5/io/object/Serializer.java
java/server/branches/joachim_amf3_integration/src/org/red5/io/utils/ObjectMap.java
Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1648
Index: /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf3/Input.java
===================================================================
--- /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf3/Input.java (revision 1641)
+++ /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf3/Input.java (revision 1648)
@@ -28,14 +28,12 @@
import org.red5.io.object.RecordSet;
import org.red5.io.object.RecordSetPage;
+import org.red5.io.utils.ObjectMap;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
-import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.TimeZone;
/**
@@ -287,5 +285,5 @@
if ("".equals(className)) {
// "anonymous" object, load as Map
- Map<String, Object> resultMap = new HashMap<String, Object>();
+ Map<String, Object> resultMap = new ObjectMap<String, Object>();
storeReference(resultMap);
switch (type & 0x03) {
Index: /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf3/Output.java
===================================================================
--- /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf3/Output.java (revision 1641)
+++ /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf3/Output.java (revision 1648)
@@ -23,9 +23,7 @@
import java.util.Collection;
import java.util.Date;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.apache.commons.logging.Log;
Index: /java/server/branches/joachim_amf3_integration/src/org/red5/io/utils/ObjectMap.java
===================================================================
--- /java/server/branches/joachim_amf3_integration/src/org/red5/io/utils/ObjectMap.java (revision 1648)
+++ /java/server/branches/joachim_amf3_integration/src/org/red5/io/utils/ObjectMap.java (revision 1648)
@@ -0,0 +1,37 @@
+package org.red5.io.utils;
+
+/*
+ * RED5 Open Source Flash Server - http://www.osflash.org/red5
+ *
+ * Copyright (c) 2006 by respective authors (see below). All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation; either version 2.1 of the License, or (at your option) any later
+ * version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along
+ * with this library; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+import java.util.HashMap;
+
+/**
+ * Map that should be transmitted as object through RTMP.
+ *
+ * @author The Red5 Project (red5 at osflash.org)
+ * @author Joachim Bauch (jojo at struktur.de)
+ */
+public class ObjectMap<K, V> extends HashMap<K, V> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5146266119400305646L;
+
+}
Index: /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf/Input.java
===================================================================
--- /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf/Input.java (revision 1639)
+++ /java/server/branches/joachim_amf3_integration/src/org/red5/io/amf/Input.java (revision 1648)
@@ -29,4 +29,5 @@
import org.red5.io.object.RecordSet;
import org.red5.io.object.RecordSetPage;
+import org.red5.io.utils.ObjectMap;
import org.red5.io.utils.XMLUtils;
import org.w3c.dom.Document;
@@ -293,4 +294,12 @@
public Map<String, Object> readKeyValues(Deserializer deserializer) {
Map<String, Object> result = new HashMap<String, Object>();
+ readKeyValues(result, deserializer);
+ return result;
+ }
+
+ /**
+ * Read key - value pairs into Map object
+ */
+ protected void readKeyValues(Map<String, Object> result, Deserializer deserializer) {
while (hasMoreProperties()) {
String name = readPropertyName();
@@ -308,5 +317,4 @@
}
skipEndObject();
- return result;
}
@@ -435,5 +443,6 @@
log.debug("read map");
}
- Map<String, Object> result = readKeyValues(deserializer);
+ Map<String, Object> result = new ObjectMap<String, Object>();
+ readKeyValues(result, deserializer);
storeReference(result);
return result;
Index: /java/server/branches/joachim_amf3_integration/src/org/red5/io/object/Serializer.java
===================================================================
--- /java/server/branches/joachim_amf3_integration/src/org/red5/io/object/Serializer.java (revision 1639)
+++ /java/server/branches/joachim_amf3_integration/src/org/red5/io/object/Serializer.java (revision 1648)
@@ -20,6 +20,8 @@
*/
+import org.apache.commons.collections.BeanMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.red5.io.utils.ObjectMap;
import org.red5.io.utils.XMLUtils;
import org.w3c.dom.Document;
@@ -248,6 +250,8 @@
*/
protected boolean writeObjectType(Output out, Object obj) {
- if (obj instanceof Map) {
+ if (obj instanceof ObjectMap || obj instanceof BeanMap) {
out.writeObject((Map) obj, this);
+ } else if (obj instanceof Map) {
+ out.writeMap((Map) obj, this);
} else if (obj instanceof RecordSet) {
out.writeRecordSet((RecordSet) obj, this);
Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.
More information about the Red5commits
mailing list