You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/02/24 16:53:03 UTC

[jspwiki] 21/38: JSPWIKI-120: use Engine instead of WikiEngine on Attachment, SessionMonitor, WikiContext and WikiSession

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit d3710e0da3f111f23f9f912e3b600f12fddc1db9
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Feb 21 17:23:55 2020 +0100

    JSPWIKI-120: use Engine instead of WikiEngine on Attachment, SessionMonitor, WikiContext and WikiSession
---
 .../src/main/java/org/apache/wiki/WikiContext.java | 62 +++++++++---------
 .../src/main/java/org/apache/wiki/WikiSession.java | 31 ++++-----
 .../org/apache/wiki/attachment/Attachment.java     |  9 +--
 .../java/org/apache/wiki/auth/SessionMonitor.java  | 73 ++++++++++------------
 4 files changed, 85 insertions(+), 90 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
index 65f1821..cd76c5a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -19,11 +19,14 @@
 package org.apache.wiki;
 
 import org.apache.log4j.Logger;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.NoSuchPrincipalException;
 import org.apache.wiki.auth.UserManager;
 import org.apache.wiki.auth.WikiPrincipal;
 import org.apache.wiki.auth.permissions.AllPermission;
 import org.apache.wiki.auth.user.UserDatabase;
+import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.ui.Command;
 import org.apache.wiki.ui.CommandResolver;
 import org.apache.wiki.ui.GroupCommand;
@@ -56,13 +59,12 @@ import java.util.PropertyPermission;
 public class WikiContext implements Cloneable, Command {
 
     private    Command m_command;
-
     private    WikiPage   m_page;
     private    WikiPage   m_realPage;
-    private    WikiEngine m_engine;
+    private    Engine     m_engine;
     private    String     m_template = "default";
 
-    private    HashMap<String,Object> m_variableMap = new HashMap<>();
+    private HashMap< String, Object > m_variableMap = new HashMap<>();
 
     /** Stores the HttpServletRequest.  May be null, if the request did not come from a servlet. */
     protected HttpServletRequest m_request;
@@ -167,30 +169,30 @@ public class WikiContext implements Cloneable, Command {
     private static final Permission DUMMY_PERMISSION = new PropertyPermission( "os.name", "read" );
 
     /**
-     *  Create a new WikiContext for the given WikiPage. Delegates to {@link #WikiContext(WikiEngine, HttpServletRequest, WikiPage)}.
+     *  Create a new WikiContext for the given WikiPage. Delegates to {@link #WikiContext(Engine, HttpServletRequest, WikiPage)}.
      *
-     *  @param engine The WikiEngine that is handling the request.
+     *  @param engine The Engine that is handling the request.
      *  @param page The WikiPage. If you want to create a WikiContext for an older version of a page, you must use this constructor.
      */
-    public WikiContext( final WikiEngine engine, final WikiPage page )
+    public WikiContext( final Engine engine, final WikiPage page )
     {
         this( engine, null, findCommand( engine, null, page ) );
     }
 
     /**
      * <p>
-     * Creates a new WikiContext for the given WikiEngine, Command and HttpServletRequest.
+     * Creates a new WikiContext for the given Engine, Command and HttpServletRequest.
      * </p>
      * <p>
      * This constructor will also look up the HttpSession associated with the request, and determine if a WikiSession object is present.
      * If not, a new one is created.
      * </p>
-     * @param engine The WikiEngine that is handling the request
+     * @param engine The Engine that is handling the request
      * @param request The HttpServletRequest that should be associated with this context. This parameter may be <code>null</code>.
      * @param command the command
      * @throws IllegalArgumentException if <code>engine</code> or <code>command</code> are <code>null</code>
      */
-    public WikiContext( final WikiEngine engine, final HttpServletRequest request, final Command command ) throws IllegalArgumentException {
+    public WikiContext( final Engine engine, final HttpServletRequest request, final Command command ) throws IllegalArgumentException {
         if ( engine == null || command == null ) {
             throw new IllegalArgumentException( "Parameter engine and command must not be null." );
         }
@@ -207,7 +209,7 @@ public class WikiContext implements Cloneable, Command {
 
         // If page not supplied, default to front page to avoid NPEs
         if( m_page == null ) {
-            m_page = m_engine.getPageManager().getPage( m_engine.getFrontPage() );
+            m_page = m_engine.getManager( PageManager.class ).getPage( m_engine.getFrontPage() );
 
             // Front page does not exist?
             if( m_page == null ) {
@@ -234,22 +236,22 @@ public class WikiContext implements Cloneable, Command {
     }
 
     /**
-     * Creates a new WikiContext for the given WikiEngine, WikiPage and HttpServletRequest. This method simply looks up the appropriate
-     * Command using {@link #findCommand(WikiEngine, HttpServletRequest, WikiPage)} and delegates to
-     * {@link #WikiContext(WikiEngine, HttpServletRequest, Command)}.
+     * Creates a new WikiContext for the given Engine, WikiPage and HttpServletRequest. This method simply looks up the appropriate
+     * Command using {@link #findCommand(Engine, HttpServletRequest, WikiPage)} and delegates to
+     * {@link #WikiContext(Engine, HttpServletRequest, Command)}.
      *
-     * @param engine The WikiEngine that is handling the request
+     * @param engine The Engine that is handling the request
      * @param request The HttpServletRequest that should be associated with this context. This parameter may be <code>null</code>.
      * @param page The WikiPage. If you want to create a WikiContext for an older version of a page, you must supply this parameter
      */
-    public WikiContext( final WikiEngine engine, final HttpServletRequest request, final WikiPage page ) {
+    public WikiContext( final Engine engine, final HttpServletRequest request, final WikiPage page ) {
         this( engine, request, findCommand( engine, request, page ) );
     }
 
     /**
      *  Creates a new WikiContext from a supplied HTTP request, using a default wiki context.
      *
-     *  @param engine The WikiEngine that is handling the request
+     *  @param engine The Engine that is handling the request
      *  @param request the HTTP request
      *  @param requestContext the default context to use
      *  @return a new WikiContext object.
@@ -258,10 +260,10 @@ public class WikiContext implements Cloneable, Command {
      *  @see org.apache.wiki.ui.Command
      *  @since 2.1.15.
      */
-    public WikiContext( final WikiEngine engine, final HttpServletRequest request, final String requestContext ) {
-        this( engine, request, engine.getCommandResolver().findCommand( request, requestContext ) );
+    public WikiContext( final Engine engine, final HttpServletRequest request, final String requestContext ) {
+        this( engine, request, engine.getManager( CommandResolver.class ).findCommand( request, requestContext ) );
         if( !engine.isConfigured() ) {
-            throw new InternalWikiException( "WikiEngine has not been properly started.  It is likely that the configuration is faulty.  Please check all logs for the possible reason." );
+            throw new InternalWikiException( "Engine has not been properly started.  It is likely that the configuration is faulty.  Please check all logs for the possible reason." );
         }
     }
 
@@ -333,7 +335,7 @@ public class WikiContext implements Cloneable, Command {
      */
     public String getRedirectURL() {
         final String pagename = m_page.getName();
-        String redirURL = m_engine.getCommandResolver().getSpecialPageReference( pagename );
+        String redirURL = m_engine.getManager( CommandResolver.class ).getSpecialPageReference( pagename );
         if( redirURL == null ) {
             final String alias = m_page.getAttribute( WikiPage.ALIAS );
             if( alias != null ) {
@@ -349,9 +351,9 @@ public class WikiContext implements Cloneable, Command {
     /**
      *  Returns the handling engine.
      *
-     *  @return The wikiengine owning this context.
+     *  @return The engine owning this context.
      */
-    public WikiEngine getEngine()
+    public Engine getEngine()
     {
         return m_engine;
     }
@@ -650,7 +652,7 @@ public class WikiContext implements Cloneable, Command {
 
     /**
      *  Returns the WikiSession associated with the context. This method is guaranteed to always return a valid WikiSession.
-     *  If this context was constructed without an associated HttpServletRequest, it will return {@link WikiSession#guestSession(WikiEngine)}.
+     *  If this context was constructed without an associated HttpServletRequest, it will return {@link WikiSession#guestSession(Engine)}.
      *
      *  @return The WikiSession associate with this context.
      */
@@ -687,7 +689,7 @@ public class WikiContext implements Cloneable, Command {
         if ( WikiCommand.INSTALL.equals( m_command ) ) {
             // See if admin users exists
             try {
-                final UserManager userMgr = m_engine.getUserManager();
+                final UserManager userMgr = m_engine.getManager( UserManager.class );
                 final UserDatabase userDb = userMgr.getUserDatabase();
                 userDb.findByLoginName( Installer.ADMIN_ID );
             } catch ( final NoSuchPrincipalException e ) {
@@ -728,7 +730,7 @@ public class WikiContext implements Cloneable, Command {
      *  @return true, if the user has all permissions.
      */
     public boolean hasAdminPermissions() {
-        return m_engine.getAuthorizationManager().checkPermission( getWikiSession(), new AllPermission( m_engine.getApplicationName() ) );
+        return m_engine.getManager( AuthorizationManager.class ).checkPermission( getWikiSession(), new AllPermission( m_engine.getApplicationName() ) );
     }
 
     /**
@@ -741,7 +743,7 @@ public class WikiContext implements Cloneable, Command {
         //  Figure out which template we should be using for this page.
         String template = null;
         if ( request != null ) {
-            String skin = request.getParameter( "skin" );
+            final String skin = request.getParameter( "skin" );
             if( skin != null )
             {
                 template = skin.replaceAll("\\p{Punct}", "");
@@ -753,7 +755,7 @@ public class WikiContext implements Cloneable, Command {
         if( template == null ) {
             final WikiPage page = getPage();
             if ( page != null ) {
-                template = page.getAttribute( WikiEngine.PROP_TEMPLATEDIR );
+                template = page.getAttribute( Engine.PROP_TEMPLATEDIR );
             }
 
         }
@@ -776,9 +778,9 @@ public class WikiContext implements Cloneable, Command {
      * @param page the wiki page
      * @return the correct command
      */
-    protected static Command findCommand( final WikiEngine engine, final HttpServletRequest request, final WikiPage page ) {
+    protected static Command findCommand( final Engine engine, final HttpServletRequest request, final WikiPage page ) {
         final String defaultContext = PageCommand.VIEW.getRequestContext();
-        Command command = engine.getCommandResolver().findCommand( request, defaultContext );
+        Command command = engine.getManager( CommandResolver.class ).findCommand( request, defaultContext );
         if ( command instanceof PageCommand && page != null ) {
             command = command.targetedCommand( page );
         }
@@ -796,7 +798,7 @@ public class WikiContext implements Cloneable, Command {
         if ( requestContext == null ) {
             m_command = PageCommand.NONE;
         } else {
-            final CommandResolver resolver = m_engine.getCommandResolver();
+            final CommandResolver resolver = m_engine.getManager( CommandResolver.class );
             m_command = resolver.findCommand( m_request, requestContext );
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
index 756260f..39ac604 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
@@ -20,6 +20,7 @@ package org.apache.wiki;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.auth.NoSuchPrincipalException;
@@ -108,8 +109,8 @@ public final class WikiSession implements WikiEventListener {
 
     private final Map<String,Set<String>> m_messages  = new HashMap<>();
 
-    /** The WikiEngine that created this session. */
-    private WikiEngine          m_engine              = null;
+    /** The Engine that created this session. */
+    private Engine              m_engine              = null;
 
     private String              m_status              = ANONYMOUS;
 
@@ -362,7 +363,7 @@ public final class WikiSession implements WikiEventListener {
      * @param engine the wiki engine
      * @param request the users's HTTP request
      */
-    public static void removeWikiSession( final WikiEngine engine, final HttpServletRequest request ) {
+    public static void removeWikiSession( final Engine engine, final HttpServletRequest request ) {
         if ( engine == null || request == null ) {
             throw new IllegalArgumentException( "Request or engine cannot be null." );
         }
@@ -536,7 +537,7 @@ public final class WikiSession implements WikiEventListener {
         m_subject.getPrincipals().removeAll( m_subject.getPrincipals(GroupPrincipal.class) );
 
         // Get the GroupManager and test for each Group
-        final GroupManager manager = m_engine.getGroupManager();
+        final GroupManager manager = m_engine.getManager( GroupManager.class );
         for( final Principal group : manager.getRoles() ) {
             if ( manager.isUserInRole( this, group ) ) {
                 m_subject.getPrincipals().add( group );
@@ -559,7 +560,7 @@ public final class WikiSession implements WikiEventListener {
         }
 
         // Look up the user and go get the new Principals
-        final UserDatabase database = m_engine.getUserManager().getUserDatabase();
+        final UserDatabase database = m_engine.getManager( UserManager.class ).getUserDatabase();
         if( database == null ) {
             throw new IllegalStateException( "User database cannot be null." );
         }
@@ -603,7 +604,7 @@ public final class WikiSession implements WikiEventListener {
      * <p>Static factory method that returns the WikiSession object associated with the current HTTP request. This method looks up
      * the associated HttpSession in an internal WeakHashMap and attempts to retrieve the WikiSession. If not found, one is created.
      * This method is guaranteed to always return a WikiSession, although the authentication status is unpredictable until the user
-     * attempts to log in. If the servlet request parameter is <code>null</code>, a synthetic {@link #guestSession(WikiEngine)} is
+     * attempts to log in. If the servlet request parameter is <code>null</code>, a synthetic {@link #guestSession(Engine)} is
      * returned.</p>
      * <p>When a session is created, this method attaches a WikiEventListener to the GroupManager so that changes to groups are detected
      * automatically.</p>
@@ -612,7 +613,7 @@ public final class WikiSession implements WikiEventListener {
      * @param request the servlet request object
      * @return the existing (or newly created) wiki session
      */
-    public static WikiSession getWikiSession( final WikiEngine engine, final HttpServletRequest request ) {
+    public static WikiSession getWikiSession( final Engine engine, final HttpServletRequest request ) {
         if ( request == null ) {
             if ( log.isDebugEnabled() ) {
                 log.debug( "Looking up WikiSession for NULL HttpRequest: returning guestSession()" );
@@ -639,15 +640,15 @@ public final class WikiSession implements WikiEventListener {
      * @param engine the wiki engine
      * @return the guest wiki session
      */
-    public static WikiSession guestSession( final WikiEngine engine ) {
+    public static WikiSession guestSession( final Engine engine ) {
         final WikiSession session = new WikiSession();
         session.m_engine = engine;
         session.invalidate();
 
         // Add the session as listener for GroupManager, AuthManager, UserManager events
-        final GroupManager groupMgr = engine.getGroupManager();
-        final AuthenticationManager authMgr = engine.getAuthenticationManager();
-        final UserManager userMgr = engine.getUserManager();
+        final GroupManager groupMgr = engine.getManager( GroupManager.class );
+        final AuthenticationManager authMgr = engine.getManager( AuthenticationManager.class );
+        final UserManager userMgr = engine.getManager( UserManager.class );
         groupMgr.addWikiEventListener( session );
         authMgr.addWikiEventListener( session );
         userMgr.addWikiEventListener( session );
@@ -659,11 +660,11 @@ public final class WikiSession implements WikiEventListener {
      *  Returns a static guest session, which is available for this thread only.  This guest session is used internally whenever
      *  there is no HttpServletRequest involved, but the request is done e.g. when embedding JSPWiki code.
      *
-     *  @param engine WikiEngine for this session
+     *  @param engine Engine for this session
      *  @return A static WikiSession which is shared by all in this same Thread.
      */
     // FIXME: Should really use WeakReferences to clean away unused sessions.
-    private static WikiSession staticGuestSession( final WikiEngine engine ) {
+    private static WikiSession staticGuestSession( final Engine engine ) {
         WikiSession session = c_guestSession.get();
         if( session == null ) {
             session = guestSession( engine );
@@ -680,7 +681,7 @@ public final class WikiSession implements WikiEventListener {
      * @param engine the wiki session
      * @return the number of sessions
      */
-    public static int sessions( final WikiEngine engine ) {
+    public static int sessions( final Engine engine ) {
         final SessionMonitor monitor = SessionMonitor.getInstance( engine );
         return monitor.sessions();
     }
@@ -693,7 +694,7 @@ public final class WikiSession implements WikiEventListener {
      * @param engine the wiki engine
      * @return an array of Principal objects, sorted by name
      */
-    public static Principal[] userPrincipals( final WikiEngine engine ) {
+    public static Principal[] userPrincipals( final Engine engine ) {
         final SessionMonitor monitor = SessionMonitor.getInstance( engine );
         return monitor.userPrincipals();
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
index 6b608b0..fb59deb 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
@@ -18,8 +18,9 @@
  */
 package org.apache.wiki.attachment;
 
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
+
 
 /**
  *  Describes an attachment.  Attachments are actually derivatives of a WikiPage, since they do actually have a WikiName as well.
@@ -34,11 +35,11 @@ public class Attachment extends WikiPage {
      *  Creates a new attachment.  The final name of the attachment will be 
      *  a synthesis of the parent page name and the file name.
      *  
-     *  @param engine     The WikiEngine which is hosting this attachment.
+     *  @param engine     The Engine which is hosting this attachment.
      *  @param parentPage The page which will contain this attachment.
      *  @param fileName   The file name for the attachment.
      */
-    public Attachment( final WikiEngine engine, final String parentPage, final String fileName ) {
+    public Attachment( final Engine engine, final String parentPage, final String fileName ) {
         super( engine, parentPage + "/" + fileName );
 
         m_parentName = parentPage;
@@ -50,7 +51,7 @@ public class Attachment extends WikiPage {
      *  
      *  @return A debugging string
      */
-    public String toString() {
+    @Override public String toString() {
         return "Attachment [" + getName() + ";mod=" + getLastModified() + "]";
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
index c326a7b..4972c90 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
@@ -19,8 +19,8 @@
 package org.apache.wiki.auth;
 
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiSecurityEvent;
@@ -39,23 +39,21 @@ import java.util.concurrent.ConcurrentHashMap;
 
 /**
  *  <p>Manages WikiSession's for different WikiEngine's.</p>
- *  <p>The WikiSession's are stored both in the remote user
- *  HttpSession and in the SessionMonitor for the WikeEngine.
- *  This class must be configured as a session listener in the
- *  web.xml for the wiki web application.
+ *  <p>The WikiSession's are stored both in the remote user HttpSession and in the SessionMonitor for the WikeEngine.
+ *  This class must be configured as a session listener in the web.xml for the wiki web application.
  *  </p>
  */
 public class SessionMonitor implements HttpSessionListener {
 
-    private static Logger log = Logger.getLogger( SessionMonitor.class );
+    private static final Logger log = Logger.getLogger( SessionMonitor.class );
 
     /** Map with WikiEngines as keys, and SessionMonitors as values. */
-    private static ConcurrentHashMap<WikiEngine, SessionMonitor>          c_monitors   = new ConcurrentHashMap<>();
+    private static ConcurrentHashMap< Engine, SessionMonitor > c_monitors = new ConcurrentHashMap<>();
 
     /** Weak hashmap with HttpSessions as keys, and WikiSessions as values. */
-    private final Map<String, WikiSession>                 m_sessions   = new WeakHashMap<>();
+    private final Map< String, WikiSession > m_sessions = new WeakHashMap<>();
 
-    private       WikiEngine          m_engine;
+    private Engine m_engine;
 
     private final PrincipalComparator m_comparator = new PrincipalComparator();
 
@@ -65,8 +63,7 @@ public class SessionMonitor implements HttpSessionListener {
      * @param engine the wiki engine
      * @return the session monitor
      */
-    public static final SessionMonitor getInstance( WikiEngine engine )
-    {
+    public static final SessionMonitor getInstance( final Engine engine ) {
         if( engine == null )
         {
             throw new IllegalArgumentException( "Engine cannot be null." );
@@ -92,8 +89,7 @@ public class SessionMonitor implements HttpSessionListener {
     {
     }
 
-    private SessionMonitor( WikiEngine engine )
-    {
+    private SessionMonitor( final Engine engine ) {
         m_engine = engine;
     }
 
@@ -105,11 +101,10 @@ public class SessionMonitor implements HttpSessionListener {
      *  @param session the user's HTTP session
      *  @return the WikiSession, if found
      */
-    private WikiSession findSession( HttpSession session )
-    {
+    private WikiSession findSession( final HttpSession session ) {
         WikiSession wikiSession = null;
-        String sid = ( session == null ) ? "(null)" : session.getId();
-        WikiSession storedSession = m_sessions.get( sid );
+        final String sid = ( session == null ) ? "(null)" : session.getId();
+        final WikiSession storedSession = m_sessions.get( sid );
 
         // If the weak reference returns a wiki session, return it
         if( storedSession != null )
@@ -126,7 +121,7 @@ public class SessionMonitor implements HttpSessionListener {
     /**
      * <p>Looks up the wiki session associated with a user's Http session
      * and adds it to the session cache. This method will return the
-     * "guest session" as constructed by {@link WikiSession#guestSession(WikiEngine)}
+     * "guest session" as constructed by {@link org.apache.wiki.WikiSession#guestSession(Engine)}
      * if the HttpSession is not currently associated with a WikiSession.
      * This method is guaranteed to return a non-<code>null</code> WikiSession.</p>
      * <p>Internally, the session is stored in a HashMap; keys are
@@ -135,21 +130,17 @@ public class SessionMonitor implements HttpSessionListener {
      * @param session the HTTP session
      * @return the wiki session
      */
-    public final WikiSession find( HttpSession session )
-    {
+    public final WikiSession find( final HttpSession session ) {
         WikiSession wikiSession = findSession(session);
-        String sid = ( session == null ) ? "(null)" : session.getId();
+        final String sid = ( session == null ) ? "(null)" : session.getId();
 
         // Otherwise, create a new guest session and stash it.
-        if( wikiSession == null )
-        {
-            if( log.isDebugEnabled() )
-            {
+        if( wikiSession == null ) {
+            if( log.isDebugEnabled() ) {
                 log.debug( "Looking up WikiSession for session ID=" + sid + "... not found. Creating guestSession()" );
             }
             wikiSession = WikiSession.guestSession( m_engine );
-            synchronized( m_sessions )
-            {
+            synchronized( m_sessions ) {
                 m_sessions.put( sid, wikiSession );
             }
         }
@@ -162,7 +153,7 @@ public class SessionMonitor implements HttpSessionListener {
      * from the session cache.
      * @param session the user's HTTP session
      */
-    public final void remove( HttpSession session )
+    public final void remove( final HttpSession session )
     {
         if ( session == null )
         {
@@ -198,13 +189,13 @@ public class SessionMonitor implements HttpSessionListener {
      */
     public final Principal[] userPrincipals()
     {
-        Collection<Principal> principals = new ArrayList<>();
+        final Collection<Principal> principals = new ArrayList<>();
         synchronized ( m_sessions ) {
-            for (WikiSession session : m_sessions.values()) {
+            for ( final WikiSession session : m_sessions.values()) {
                 principals.add( session.getUserPrincipal() );
             }
         }
-        Principal[] p = principals.toArray( new Principal[principals.size()] );
+        final Principal[] p = principals.toArray( new Principal[principals.size()] );
         Arrays.sort( p, m_comparator );
         return p;
     }
@@ -214,7 +205,7 @@ public class SessionMonitor implements HttpSessionListener {
      * @param listener the event listener
      * @since 2.4.75
      */
-    public final synchronized void addWikiEventListener( WikiEventListener listener )
+    public final synchronized void addWikiEventListener( final WikiEventListener listener )
     {
         WikiEventManager.addWikiEventListener( this, listener );
     }
@@ -224,7 +215,7 @@ public class SessionMonitor implements HttpSessionListener {
      * @param listener the event listener
      * @since 2.4.75
      */
-    public final synchronized void removeWikiEventListener( WikiEventListener listener )
+    public final synchronized void removeWikiEventListener( final WikiEventListener listener )
     {
         WikiEventManager.removeWikiEventListener( this, listener );
     }
@@ -236,7 +227,7 @@ public class SessionMonitor implements HttpSessionListener {
      * @param session the wiki session
      * @since 2.4.75
      */
-    protected final void fireEvent( int type, Principal principal, WikiSession session )
+    protected final void fireEvent( final int type, final Principal principal, final WikiSession session )
     {
         if( WikiEventManager.isListening(this) )
         {
@@ -250,9 +241,9 @@ public class SessionMonitor implements HttpSessionListener {
      * @param se the HTTP session event
      */
     @Override
-    public void sessionCreated( HttpSessionEvent se )
+    public void sessionCreated( final HttpSessionEvent se )
     {
-        HttpSession session = se.getSession();
+        final HttpSession session = se.getSession();
         log.debug( "Created session: " + session.getId() + "." );
     }
 
@@ -262,15 +253,15 @@ public class SessionMonitor implements HttpSessionListener {
      * @param se the HTTP session event
      */
     @Override
-    public void sessionDestroyed( HttpSessionEvent se )
+    public void sessionDestroyed( final HttpSessionEvent se )
     {
-        HttpSession session = se.getSession();
-        Iterator<SessionMonitor> it = c_monitors.values().iterator();
+        final HttpSession session = se.getSession();
+        final Iterator<SessionMonitor> it = c_monitors.values().iterator();
         while( it.hasNext() )
         {
-            SessionMonitor monitor = it.next();
+            final SessionMonitor monitor = it.next();
 
-            WikiSession storedSession = monitor.findSession(session);
+            final WikiSession storedSession = monitor.findSession(session);
 
             monitor.remove(session);