commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r769725 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: Group.java User.java
Date Wed, 29 Apr 2009 09:11:55 GMT
Author: mturk
Date: Wed Apr 29 09:11:54 2009
New Revision: 769725

URL: http://svn.apache.org/viewvc?rev=769725&view=rev
Log:
Make singleton access to user and group databases.

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java?rev=769725&r1=769724&r2=769725&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java Wed
Apr 29 09:11:54 2009
@@ -27,6 +27,13 @@
 public final class Group
 {
 
+    // Singleton access to users database
+    private static Object singleton;
+    static {
+
+        singleton = new Object();
+    }
+
     private Group()
     {
         // No instance.
@@ -77,7 +84,11 @@
     public static GroupIterator getLocalGroups()
         throws IOException, SecurityException
     {
-        return new GroupIteratorImpl(enum0());
+        GroupIterator iter;
+        synchronized(singleton) {
+            iter = new GroupIteratorImpl(enum0());
+        }
+        return iter;
     }
 
     /**

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java?rev=769725&r1=769724&r2=769725&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java Wed Apr
29 09:11:54 2009
@@ -28,6 +28,13 @@
 public final class User
 {
 
+    // Singleton access to users database
+    private static Object singleton;
+    static {
+
+        singleton = new Object();
+    }
+
     private User()
     {
         // No instance.
@@ -74,7 +81,11 @@
     public static UserIterator getUsers()
         throws IOException, SecurityException
     {
-        return new UserIteratorImpl(enum0());
+        UserIterator iter;
+        synchronized(singleton) {
+            iter = new UserIteratorImpl(enum0());
+        }
+        return iter;
     }
 
     /**



Mime
View raw message