jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jalka...@apache.org
Subject svn commit: r667878 - in /incubator/jspwiki/trunk: ChangeLog src/com/ecyrd/jspwiki/auth/UserManager.java
Date Sat, 14 Jun 2008 20:55:53 GMT
Author: jalkanen
Date: Sat Jun 14 13:55:53 2008
New Revision: 667878

URL: http://svn.apache.org/viewvc?rev=667878&view=rev
Log:
JSPWIKI-57: Made JSONUserModule properly serializable by separating it from the UserManager.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=667878&r1=667877&r2=667878&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sat Jun 14 13:55:53 2008
@@ -21,6 +21,9 @@
         you normally want to enable in jspwiki.properties, but most people don't
         really want to touch.
         
+        * JSPWIKI-57: Should resolve NotSerializableExceptions when container
+        goes up or down.
+        
 2007-06-14 Dirk Frederickx <dirk.frederickx@gmail.com>
 
         * 2.7.0-svn-41  Many template fixes, added ajaxed edit preview, improved IE6/IE7
compat.

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java?rev=667878&r1=667877&r2=667878&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java Sat Jun 14 13:55:53
2008
@@ -20,6 +20,7 @@
  */
 package com.ecyrd.jspwiki.auth;
 
+import java.io.Serializable;
 import java.security.Permission;
 import java.security.Principal;
 import java.text.MessageFormat;
@@ -114,7 +115,7 @@
         // TODO: it would be better if we did this in PageManager directly
         addWikiEventListener( engine.getPageManager() );
 
-        JSONRPCManager.registerGlobalObject( "users", new JSONUserModule(), new AllPermission(null)
);
+        JSONRPCManager.registerGlobalObject( "users", new JSONUserModule(this), new AllPermission(null)
);
     }
 
     /**
@@ -811,9 +812,25 @@
 
     /**
      *  Implements the JSON API for usermanager.
+     *  <p>
+     *  Even though this gets serialized whenever container shuts down/restarts,
+     *  this gets reinstalled to the session when JSPWiki starts.  This means
+     *  that it's not actually necessary to save anything.
      */
-    public final class JSONUserModule implements RPCCallable
+    public static final class JSONUserModule implements RPCCallable, Serializable
     {
+        private static final long serialVersionUID = 1L;
+        private volatile UserManager m_manager;
+        
+        /**
+         *  Create a new JSONUserModule.
+         *  @param mgr Manager
+         */
+        public JSONUserModule( UserManager mgr )
+        {
+            m_manager = mgr;
+        }
+        
         /**
          *  Directly returns the UserProfile object attached to an uid.
          *
@@ -824,12 +841,14 @@
         public UserProfile getUserInfo( String uid )
             throws NoSuchPrincipalException
         {
-            log.info("request "+uid);
-            UserProfile prof = getUserDatabase().find( uid );
-
-            log.info("answer "+prof);
+            if( m_manager != null )
+            {
+                UserProfile prof = m_manager.getUserDatabase().find( uid );
 
-            return prof;
+                return prof;
+            }
+            
+            throw new IllegalStateException("The manager is offline.");
         }
     }
 }



Mime
View raw message