[Red5commits] [1587] added method to get all attributes of an IAttributeStoreuse ConcurrentHashMap?
jbauch
luke at codegent.com
Wed Jan 24 11:00:21 EST 2007
added method to get all attributes of an IAttributeStore
use ConcurrentHashMap? to avoid problems while iterating
Timestamp: 12/13/06 12:28:46 EST (1 month ago)
Change: 1587
Author: jbauch
Files (see diff or trac for details):
java/server/trunk/src/org/red5/server/AttributeStore.java
java/server/trunk/src/org/red5/server/adapter/StatefulScopeWrappingAdapter.java
java/server/trunk/src/org/red5/server/api/IAttributeStore.java
java/server/trunk/src/org/red5/server/so/SharedObject.java
Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1587
Index: /java/server/trunk/src/org/red5/server/adapter/StatefulScopeWrappingAdapter.java
===================================================================
--- /java/server/trunk/src/org/red5/server/adapter/StatefulScopeWrappingAdapter.java (revision 1468)
+++ /java/server/trunk/src/org/red5/server/adapter/StatefulScopeWrappingAdapter.java (revision 1587)
@@ -62,4 +62,8 @@
public Set<String> getAttributeNames() {
return scope.getAttributeNames();
+ }
+
+ public Map<String, Object> getAttributes() {
+ return scope.getAttributes();
}
Index: /java/server/trunk/src/org/red5/server/so/SharedObject.java
===================================================================
--- /java/server/trunk/src/org/red5/server/so/SharedObject.java (revision 1574)
+++ /java/server/trunk/src/org/red5/server/so/SharedObject.java (revision 1587)
@@ -31,4 +31,5 @@
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
@@ -85,5 +86,5 @@
public SharedObject() {
// This is used by the persistence framework
- data = new HashMap<String, Object>();
+ data = new ConcurrentHashMap<String, Object>();
ownerMessage = new SharedObjectMessage(null, null, -1, false);
@@ -97,5 +98,6 @@
public SharedObject(Map<String, Object> data, String name, String path,
boolean persistent) {
- this.data = data;
+ this.data = new ConcurrentHashMap<String, Object>();
+ this.data.putAll(data);
this.name = name;
this.path = path;
@@ -107,5 +109,6 @@
public SharedObject(Map<String, Object> data, String name, String path,
boolean persistent, IPersistenceStore storage) {
- this.data = data;
+ this.data = new ConcurrentHashMap<String, Object>();
+ this.data.putAll(data);
this.name = name;
this.path = path;
@@ -245,4 +248,8 @@
public Set<String> getAttributeNames() {
return Collections.unmodifiableSet(data.keySet());
+ }
+
+ public Map<String, Object> getAttributes() {
+ return Collections.unmodifiableMap(data);
}
Index: /java/server/trunk/src/org/red5/server/AttributeStore.java
===================================================================
--- /java/server/trunk/src/org/red5/server/AttributeStore.java (revision 1519)
+++ /java/server/trunk/src/org/red5/server/AttributeStore.java (revision 1587)
@@ -20,4 +20,5 @@
*/
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@@ -25,4 +26,5 @@
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.red5.server.api.IAttributeStore;
@@ -31,5 +33,5 @@
public class AttributeStore implements ICastingAttributeStore {
- protected Map<String, Object> attributes = new HashMap<String, Object>();
+ protected Map<String, Object> attributes = new ConcurrentHashMap<String, Object>();
protected Map<String, Integer> hashes = new HashMap<String, Integer>();
@@ -40,7 +42,11 @@
public Set<String> getAttributeNames() {
- return attributes.keySet();
+ return Collections.unmodifiableSet(attributes.keySet());
}
+ public Map<String, Object> getAttributes() {
+ return Collections.unmodifiableMap(attributes);
+ }
+
public Object getAttribute(String name) {
return attributes.get(name);
Index: /java/server/trunk/src/org/red5/server/api/IAttributeStore.java
===================================================================
--- /java/server/trunk/src/org/red5/server/api/IAttributeStore.java (revision 1406)
+++ /java/server/trunk/src/org/red5/server/api/IAttributeStore.java (revision 1587)
@@ -32,5 +32,5 @@
/**
- * Get the attribute names.
+ * Get the attribute names. The resulting set will be read-only.
*
* @return set containing all attribute names
@@ -38,4 +38,11 @@
public Set<String> getAttributeNames();
+ /**
+ * Get the attributes. The resulting map will be read-only.
+ *
+ * @return map containing all attributes
+ */
+ public Map<String, Object> getAttributes();
+
/**
* Set an attribute on this object.
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