From 57ff8b84e6bd7f02f70999b4a77853bdc5279e8a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 11 Apr 2018 17:04:07 -0700 Subject: [PATCH] GUACAMOLE-542: Deprecate SimpleConnectionDirectory, etc., relying instead on SimpleDirectory. --- .../simple/SimpleConnectionDirectory.java | 3 +++ .../SimpleConnectionGroupDirectory.java | 3 +++ .../net/auth/simple/SimpleDirectory.java | 21 ++++++++++++++++--- .../net/auth/simple/SimpleUserDirectory.java | 3 +++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java index 3f9c4c8a7..77eaf983a 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionDirectory.java @@ -28,7 +28,10 @@ import org.apache.guacamole.net.auth.Connection; * An extremely simple read-only implementation of a Directory of * GuacamoleConfigurations which provides access to a pre-defined Map of * GuacamoleConfigurations. + * + * @deprecated Use {@link SimpleDirectory} instead. */ +@Deprecated public class SimpleConnectionDirectory extends SimpleDirectory { /** diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java index a2597d4b2..e0870548b 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleConnectionGroupDirectory.java @@ -28,7 +28,10 @@ import org.apache.guacamole.net.auth.ConnectionGroup; * An extremely simple read-only implementation of a Directory of * ConnectionGroup which provides which provides access to a pre-defined * Collection of ConnectionGroups. + * + * @deprecated Use {@link SimpleDirectory} instead. */ +@Deprecated public class SimpleConnectionGroupDirectory extends SimpleDirectory { diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java index 1e184c4ed..4f64ec8c0 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleDirectory.java @@ -23,9 +23,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleSecurityException; import org.apache.guacamole.net.auth.Directory; @@ -57,7 +57,7 @@ public class SimpleDirectory /** * Creates a new SimpleDirectory which provides access to the objects * contained within the given Map. The given Map will be used to back all - * operations on the SimpleDirectory, and must be threadsafe. + * operations on the SimpleDirectory. * * @param objects * The Map of objects to provide access to. @@ -66,10 +66,25 @@ public class SimpleDirectory this.objects = objects; } + /** + * Creates a new SimpleDirectory which provides access to the given object. + * + * @param object + * The object to provide access to. + */ public SimpleDirectory(ObjectType object) { this(Collections.singletonMap(object.getIdentifier(), object)); } + /** + * Creates a new SimpleDirectory which provides access to the given + * objects. Note that a new Map will be created to store the given objects. + * If the objects are already available in Map form, it is more efficient + * to use the {@link #SimpleDirectory(java.util.Map)} constructor. + * + * @param objects + * The objects that should be present in this directory. + */ public SimpleDirectory(ObjectType... objects) { this(Arrays.asList(objects)); } @@ -85,7 +100,7 @@ public class SimpleDirectory * A Collection of all objects that should be present in this directory. */ public SimpleDirectory(Collection objects) { - this.objects = new ConcurrentHashMap(objects.size()); + this.objects = new HashMap(objects.size()); for (ObjectType object : objects) this.objects.put(object.getIdentifier(), object); } diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java index f9068d4e3..bb5e37a23 100644 --- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java +++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/simple/SimpleUserDirectory.java @@ -25,7 +25,10 @@ import org.apache.guacamole.net.auth.User; /** * An extremely simple read-only implementation of a Directory of Users which * provides access to a single pre-defined User. + * + * @deprecated Use {@link SimpleDirectory} instead. */ +@Deprecated public class SimpleUserDirectory extends SimpleDirectory { /**