JSPWIKI-120: propagate WikiContext#getEngine() now returns Engine instead of WikiEngine (6)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
index 53c6b7f..9abea2d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
@@ -109,11 +109,11 @@
      *  Initializes the servlet from WikiEngine properties.
      *
      */
-    public void init( ServletConfig config ) throws ServletException {
-        String tmpDir;
+    @Override public void init( final ServletConfig config ) throws ServletException {
+        final String tmpDir;
 
         m_engine         = WikiEngine.getInstance( config );
-        Properties props = m_engine.getWikiProperties();
+        final Properties props = m_engine.getWikiProperties();
 
         tmpDir         = m_engine.getWorkDir()+File.separator+"attach-tmp";
 
@@ -121,7 +121,7 @@
                 AttachmentManager.PROP_MAXSIZE,
                 Integer.MAX_VALUE );
 
-        String allowed = TextUtil.getStringProperty( props,
+        final String allowed = TextUtil.getStringProperty( props,
                 AttachmentManager.PROP_ALLOWEDEXTENSIONS,
                 null );
 
@@ -130,7 +130,7 @@
         else
             m_allowedPatterns = new String[0];
 
-        String forbidden = TextUtil.getStringProperty( props,
+        final String forbidden = TextUtil.getStringProperty( props,
                 AttachmentManager.PROP_FORBIDDENEXTENSIONS,
                 null );
 
@@ -139,7 +139,7 @@
         else
             m_forbiddenPatterns = new String[0];
 
-        File f = new File( tmpDir );
+        final File f = new File( tmpDir );
         if( !f.exists() )
         {
             f.mkdirs();
@@ -181,7 +181,7 @@
      *  @param res The servlet response
      */
 
-    protected void doOptions( HttpServletRequest req, HttpServletResponse res )
+    @Override protected void doOptions( final HttpServletRequest req, final HttpServletResponse res )
     {
         res.setHeader( "Allow", "GET, PUT, POST, OPTIONS, PROPFIND, PROPPATCH, MOVE, COPY, DELETE");
         res.setStatus( HttpServletResponse.SC_OK );
@@ -193,9 +193,9 @@
      *
      */
     // FIXME: Messages would need to be localized somehow.
-    public void doGet( final HttpServletRequest  req, final HttpServletResponse res ) throws IOException {
+    @Override public void doGet( final HttpServletRequest  req, final HttpServletResponse res ) throws IOException {
         final WikiContext context = new WikiContext( m_engine, req, WikiContext.ATTACH );
-        final AttachmentManager mgr = m_engine.getAttachmentManager();
+        final AttachmentManager mgr = m_engine.getManager( AttachmentManager.class );
         final AuthorizationManager authmgr = m_engine.getAuthorizationManager();
 
         final String version = req.getParameter( HDR_VERSION );
@@ -339,14 +339,14 @@
      * @param fileName The name to check for.
      * @return A valid mime type, or application/binary, if not recognized
      */
-    private static String getMimeType(WikiContext ctx, String fileName )
+    private static String getMimeType( final WikiContext ctx, final String fileName )
     {
         String mimetype = null;
 
-        HttpServletRequest req = ctx.getHttpRequest();
+        final HttpServletRequest req = ctx.getHttpRequest();
         if( req != null )
         {
-            ServletContext s = req.getSession().getServletContext();
+            final ServletContext s = req.getSession().getServletContext();
 
             if( s != null )
             {
@@ -373,13 +373,13 @@
      * content of the file.
      *
      */
-    public void doPost( final HttpServletRequest req, final HttpServletResponse res ) throws IOException {
+    @Override public void doPost( final HttpServletRequest req, final HttpServletResponse res ) throws IOException {
         try {
             final String nextPage = upload( req );
             req.getSession().removeAttribute("msg");
             res.sendRedirect( nextPage );
         } catch( final RedirectException e ) {
-            WikiSession session = WikiSession.getWikiSession( m_engine, req );
+            final WikiSession session = WikiSession.getWikiSession( m_engine, req );
             session.addMessage( e.getMessage() );
 
             req.getSession().setAttribute("msg", e.getMessage());
@@ -391,7 +391,7 @@
      *  Validates the next page to be on the same server as this webapp.
      *  Fixes [JSPWIKI-46].
      */
-    private String validateNextPage( String nextPage, String errorPage )
+    private String validateNextPage( String nextPage, final String errorPage )
     {
         if( nextPage.indexOf("://") != -1 )
         {
@@ -444,12 +444,12 @@
                 upload.setFileSizeMax( m_maxSize );
             }
             upload.setProgressListener( pl );
-            List<FileItem> items = upload.parseRequest( req );
+            final List<FileItem> items = upload.parseRequest( req );
 
             String   wikipage   = null;
             String   changeNote = null;
             //FileItem actualFile = null;
-            List<FileItem> fileItems = new ArrayList<>();
+            final List<FileItem> fileItems = new ArrayList<>();
 
             for( final FileItem item : items ) {
                 if( item.isFormField() ) {
@@ -459,7 +459,7 @@
                         //
 
                         wikipage = item.getString("UTF-8");
-                        int x = wikipage.indexOf("/");
+                        final int x = wikipage.indexOf("/");
 
                         if( x != -1 ) wikipage = wikipage.substring(0,x);
                     } else if( item.getFieldName().equals("changenote") ) {
@@ -479,10 +479,10 @@
                 throw new RedirectException( "Broken file upload", errorPage );
 
             } else {
-                for( FileItem actualFile : fileItems ) {
-                    String filename = actualFile.getName();
-                    long   fileSize = actualFile.getSize();
-                    try( InputStream in  = actualFile.getInputStream() ) {
+                for( final FileItem actualFile : fileItems ) {
+                    final String filename = actualFile.getName();
+                    final long   fileSize = actualFile.getSize();
+                    try( final InputStream in  = actualFile.getInputStream() ) {
                         executeUpload( context, in, filename, nextPage, wikipage, changeNote, fileSize );
                     }
                 }
@@ -528,10 +528,10 @@
      * @throws IOException       If there is a problem in the upload.
      * @throws ProviderException If there is a problem in the backend.
      */
-    protected boolean executeUpload( WikiContext context, InputStream data,
-                                     String filename, String errorPage,
-                                     String parentPage, String changenote,
-                                     long contentLength )
+    protected boolean executeUpload( final WikiContext context, final InputStream data,
+                                     String filename, final String errorPage,
+                                     final String parentPage, final String changenote,
+                                     final long contentLength )
             throws RedirectException,
             IOException, ProviderException
     {
@@ -564,7 +564,7 @@
         }
 
         final Principal user    = context.getCurrentUser();
-        final AttachmentManager mgr = m_engine.getAttachmentManager();
+        final AttachmentManager mgr = m_engine.getManager( AttachmentManager.class );
 
         log.debug("file="+filename);
 
@@ -607,7 +607,7 @@
             }
 
             try {
-                m_engine.getAttachmentManager().storeAttachment( att, data );
+                m_engine.getManager( AttachmentManager.class ).storeAttachment( att, data );
             } catch( final ProviderException pe ) {
                 // this is a kludge, the exception that is caught here contains the i18n key
                 // here we have the context available, so we can internationalize it properly :
@@ -630,12 +630,12 @@
         public long m_currentBytes;
         public long m_totalBytes;
 
-        public void update( final long recvdBytes, final long totalBytes, final int item) {
+        @Override public void update( final long recvdBytes, final long totalBytes, final int item) {
             m_currentBytes = recvdBytes;
             m_totalBytes   = totalBytes;
         }
 
-        public int getProgress() {
+        @Override public int getProgress() {
             return ( int )( ( ( float )m_currentBytes / m_totalBytes ) * 100 + 0.5 );
         }
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
index 4cf397c..3070d2f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
@@ -66,7 +66,7 @@
     /**
      *  Creates a new AttachmentManager.  Note that creation will never fail, but it's quite likely that attachments do not function.
      *  <p><b>DO NOT CREATE</b> an AttachmentManager on your own, unless you really know what you're doing. Just use
-     *  WikiEngine.getAttachmentManager() if you're making a module for JSPWiki.
+     *  Wikiengine.getManager( AttachmentManager.class ) if you're making a module for JSPWiki.
      *
      *  @param engine The wikiengine that owns this attachment manager.
      *  @param props A list of properties from which the AttachmentManager will seek its configuration. Typically this is the "jspwiki.properties".
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
index e586d45..3df9abd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
@@ -21,15 +21,19 @@
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageRenameEvent;
+import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.JSPWikiMarkupParser;
 import org.apache.wiki.parser.MarkupParser;
+import org.apache.wiki.references.ReferenceManager;
+import org.apache.wiki.search.SearchManager;
 import org.apache.wiki.util.TextUtil;
 
 import java.util.Collection;
@@ -62,7 +66,7 @@
      *  @return The final new name (in case it had to be modified)
      *  @throws WikiException If the page cannot be renamed.
      */
-    public String renamePage( final WikiContext context, final String renameFrom, final String renameTo, final boolean changeReferrers ) throws WikiException {
+    @Override public String renamePage( final WikiContext context, final String renameFrom, final String renameTo, final boolean changeReferrers ) throws WikiException {
         //  Sanity checks first
         if( renameFrom == null || renameFrom.length() == 0 ) {
             throw new WikiException( "From name may not be null or empty" );
@@ -78,12 +82,12 @@
         }
         
         //  Preconditions: "from" page must exist, and "to" page must not yet exist.
-        final WikiEngine engine = context.getEngine();
-        final WikiPage fromPage = engine.getPageManager().getPage( renameFrom );
+        final Engine engine = context.getEngine();
+        final WikiPage fromPage = engine.getManager( PageManager.class ).getPage( renameFrom );
         if( fromPage == null ) {
             throw new WikiException("No such page "+renameFrom);
         }
-        WikiPage toPage = engine.getPageManager().getPage( renameToClean );
+        WikiPage toPage = engine.getManager( PageManager.class ).getPage( renameToClean );
         if( toPage != null ) {
             throw new WikiException( "Page already exists " + renameToClean );
         }
@@ -92,29 +96,29 @@
 
         //  Do the actual rename by changing from the frompage to the topage, including all of the attachments
         //  Remove references to attachments under old name
-        final List< Attachment > attachmentsOldName = engine.getAttachmentManager().listAttachments( fromPage );
+        final List< Attachment > attachmentsOldName = engine.getManager( AttachmentManager.class ).listAttachments( fromPage );
         for( final Attachment att: attachmentsOldName ) {
-            final WikiPage fromAttPage = engine.getPageManager().getPage( att.getName() );
-            engine.getReferenceManager().pageRemoved( fromAttPage );
+            final WikiPage fromAttPage = engine.getManager( PageManager.class ).getPage( att.getName() );
+            engine.getManager( ReferenceManager.class ).pageRemoved( fromAttPage );
         }
 
-        engine.getPageManager().getProvider().movePage( renameFrom, renameToClean );
-        if( engine.getAttachmentManager().attachmentsEnabled() ) {
-            engine.getAttachmentManager().getCurrentProvider().moveAttachmentsForPage( renameFrom, renameToClean );
+        engine.getManager( PageManager.class ).getProvider().movePage( renameFrom, renameToClean );
+        if( engine.getManager( AttachmentManager.class ).attachmentsEnabled() ) {
+            engine.getManager( AttachmentManager.class ).getCurrentProvider().moveAttachmentsForPage( renameFrom, renameToClean );
         }
         
         //  Add a comment to the page notifying what changed.  This adds a new revision to the repo with no actual change.
-        toPage = engine.getPageManager().getPage( renameToClean );
+        toPage = engine.getManager( PageManager.class ).getPage( renameToClean );
         if( toPage == null ) {
             throw new InternalWikiException( "Rename seems to have failed for some strange reason - please check logs!" );
         }
         toPage.setAttribute( WikiPage.CHANGENOTE, fromPage.getName() + " ==> " + toPage.getName() );
         toPage.setAuthor( context.getCurrentUser().getName() );
-        engine.getPageManager().putPageText( toPage, engine.getPageManager().getPureText( toPage ) );
+        engine.getManager( PageManager.class ).putPageText( toPage, engine.getManager( PageManager.class ).getPureText( toPage ) );
 
         //  Update the references
-        engine.getReferenceManager().pageRemoved( fromPage );
-        engine.getReferenceManager().updateReferences( toPage );
+        engine.getManager( ReferenceManager.class ).pageRemoved( fromPage );
+        engine.getManager( ReferenceManager.class ).updateReferences( toPage );
 
         //  Update referrers
         if( changeReferrers ) {
@@ -122,14 +126,14 @@
         }
 
         //  re-index the page including its attachments
-        engine.getSearchManager().reindexPage( toPage );
+        engine.getManager( SearchManager.class ).reindexPage( toPage );
         
-        final Collection< Attachment > attachmentsNewName = engine.getAttachmentManager().listAttachments( toPage );
+        final Collection< Attachment > attachmentsNewName = engine.getManager( AttachmentManager.class ).listAttachments( toPage );
         for( final Attachment att:attachmentsNewName ) {
-            final WikiPage toAttPage = engine.getPageManager().getPage( att.getName() );
+            final WikiPage toAttPage = engine.getManager( PageManager.class ).getPage( att.getName() );
             // add reference to attachment under new page name
-            engine.getReferenceManager().updateReferences( toAttPage );
-            engine.getSearchManager().reindexPage( att );
+            engine.getManager( ReferenceManager.class ).updateReferences( toAttPage );
+            engine.getManager( SearchManager.class ).reindexPage( att );
         }
 
         firePageRenameEvent( renameFrom, renameToClean );
@@ -145,7 +149,7 @@
      * @param oldName the former page name
      * @param newName the new page name
      */
-    public void firePageRenameEvent( final String oldName, final String newName ) {
+    @Override public void firePageRenameEvent( final String oldName, final String newName ) {
         if( WikiEventManager.isListening(this) ) {
             WikiEventManager.fireEvent(this, new WikiPageRenameEvent(this, oldName, newName ) );
         }
@@ -164,16 +168,16 @@
             return;
         }
 
-        final WikiEngine engine = context.getEngine();
+        final Engine engine = context.getEngine();
         for( String pageName : referrers ) {
             //  In case the page was just changed from under us, let's do this small kludge.
             if( pageName.equals( fromPage.getName() ) ) {
                 pageName = toPage.getName();
             }
             
-            final WikiPage p = engine.getPageManager().getPage( pageName );
+            final WikiPage p = engine.getManager( PageManager.class ).getPage( pageName );
 
-            final String sourceText = engine.getPageManager().getPureText( p );
+            final String sourceText = engine.getManager( PageManager.class ).getPureText( p );
             String newText = replaceReferrerString( context, sourceText, fromPage.getName(), toPage.getName() );
 
             m_camelCase = TextUtil.getBooleanProperty( engine.getWikiProperties(), JSPWikiMarkupParser.PROP_CAMELCASELINKS, m_camelCase );
@@ -186,8 +190,8 @@
                 p.setAuthor( context.getCurrentUser().getName() );
          
                 try {
-                    engine.getPageManager().putPageText( p, newText );
-                    engine.getReferenceManager().updateReferences( p );
+                    engine.getManager( PageManager.class ).putPageText( p, newText );
+                    engine.getManager( ReferenceManager.class ).updateReferences( p );
                 } catch( final ProviderException e ) {
                     //  We fail with an error, but we will try to continue to rename other referrers as well.
                     log.error("Unable to perform rename.",e);
@@ -196,17 +200,17 @@
         }
     }
 
-    private Set<String> getReferencesToChange( final WikiPage fromPage, final WikiEngine engine ) {
+    private Set<String> getReferencesToChange( final WikiPage fromPage, final Engine engine ) {
         final Set< String > referrers = new TreeSet<>();
-        final Collection< String > r = engine.getReferenceManager().findReferrers( fromPage.getName() );
+        final Collection< String > r = engine.getManager( ReferenceManager.class ).findReferrers( fromPage.getName() );
         if( r != null ) {
             referrers.addAll( r );
         }
         
         try {
-            final List< Attachment > attachments = engine.getAttachmentManager().listAttachments( fromPage );
+            final List< Attachment > attachments = engine.getManager( AttachmentManager.class ).listAttachments( fromPage );
             for( final Attachment att : attachments  ) {
-                final Collection< String > c = engine.getReferenceManager().findReferrers( att.getName() );
+                final Collection< String > c = engine.getManager( ReferenceManager.class ).findReferrers( att.getName() );
                 if( c != null ) {
                     referrers.addAll( c );
                 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
index 62229b9..859aed6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
@@ -23,6 +23,7 @@
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
+import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.providers.WikiPageProvider;
 import org.apache.wiki.util.ClassUtil;
 
@@ -85,7 +86,7 @@
      * @param secondWikiText the new text
      * @return XHTML, or empty string, if no difference detected.
      */
-    public String makeDiff( final WikiContext context, final String firstWikiText, final String secondWikiText ) {
+    @Override public String makeDiff( final WikiContext context, final String firstWikiText, final String secondWikiText ) {
         String diff;
         try {
             diff = m_provider.makeDiffHtml( context, firstWikiText, secondWikiText );
@@ -111,10 +112,10 @@
      *
      *  @return A HTML-ized difference between two pages.  If there is no difference, returns an empty string.
      */
-    public String getDiff( final WikiContext context, final int version1, final int version2 ) {
+    @Override public String getDiff( final WikiContext context, final int version1, final int version2 ) {
         final String page = context.getPage().getName();
-        String page1 = context.getEngine().getPageManager().getPureText( page, version1 );
-        final String page2 = context.getEngine().getPageManager().getPureText( page, version2 );
+        String page1 = context.getEngine().getManager( PageManager.class ).getPureText( page, version1 );
+        final String page2 = context.getEngine().getManager( PageManager.class ).getPureText( page, version2 );
 
         // Kludge to make diffs for new pages to work this way.
         if( version1 == WikiPageProvider.LATEST_VERSION ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
index f2a139a..6e1bfe6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
@@ -21,6 +21,7 @@
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.xmlrpc.AsyncCallback;
 import org.apache.xmlrpc.XmlRpcClient;
@@ -52,16 +53,16 @@
     /**
      *  {@inheritDoc}
      */
-    public void initialize( final WikiEngine engine, final Properties props ) {
+    @Override public void initialize( final WikiEngine engine, final Properties props ) {
         m_pingURL = props.getProperty( PROP_PINGURL, "http://rpc.weblogs.com/RPC2" );
     }
 
     /**
      *  {@inheritDoc}
      */
-    public void postSave( final WikiContext context, final String pagecontent ) {
+    @Override public void postSave( final WikiContext context, final String pagecontent ) {
         String blogName = context.getPage().getName();
-        final WikiEngine engine   = context.getEngine();
+        final Engine engine   = context.getEngine();
 
         final int blogentryTxt = blogName.indexOf("_blogentry_");
         if( blogentryTxt == -1 ) {
@@ -86,11 +87,11 @@
 
             xmlrpc.executeAsync("weblogUpdates.ping", params, 
                                 new AsyncCallback() {
-                                    public void handleError( final Exception ex, final URL url, final String method ) {
+                                    @Override public void handleError( final Exception ex, final URL url, final String method ) {
                                         log.error( "Unable to execute weblogs.com ping to URL: " + url.toString(), ex );
                                     }
 
-                                    public void handleResult( final Object result, final URL url, final String method ) {
+                                    @Override public void handleResult( final Object result, final URL url, final String method ) {
                                         @SuppressWarnings("unchecked")
                                         final Hashtable< String, Object > res = (Hashtable < String, Object > ) result;
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
index c018bfc..0175d6c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
@@ -33,11 +33,14 @@
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.RedirectException;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.auth.user.UserProfile;
+import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.ui.EditorManager;
 import org.apache.wiki.util.FileUtil;
 import org.apache.wiki.util.HttpUtil;
@@ -194,11 +197,11 @@
     private static  Logger  log = Logger.getLogger( SpamFilter.class );
 
 
-    private Vector<Host>    m_temporaryBanList = new Vector<Host>();
+    private Vector<Host>    m_temporaryBanList = new Vector<>();
 
     private int             m_banTime = 60; // minutes
 
-    private Vector<Host>    m_lastModifications = new Vector<Host>();
+    private Vector<Host>    m_lastModifications = new Vector<>();
 
     /**
      *  How many times a single IP address can change a page per minute?
@@ -247,7 +250,7 @@
      *  {@inheritDoc}
      */
     @Override
-    public void initialize( WikiEngine engine, Properties properties ) {
+    public void initialize( final WikiEngine engine, final Properties properties ) {
         m_forbiddenWordsPage = properties.getProperty( PROP_WORDLIST, m_forbiddenWordsPage );
         m_forbiddenIPsPage = properties.getProperty( PROP_IPLIST, m_forbiddenIPsPage);
         m_pageNameMaxLength = properties.getProperty( PROP_MAX_PAGENAME_LENGTH, m_pageNameMaxLength);
@@ -272,7 +275,7 @@
 
         try {
             m_urlPattern = m_compiler.compile( URL_REGEXP );
-        } catch( MalformedPatternException e ) {
+        } catch( final MalformedPatternException e ) {
             log.fatal( "Internal error: Someone put in a faulty pattern.", e );
             throw new InternalWikiException( "Faulty pattern." , e);
         }
@@ -295,15 +298,15 @@
     private static final int ACCEPT = 1;
     private static final int NOTE   = 2;
 
-    private static String log( WikiContext ctx, int type, String source, String message ) {
+    private static String log( final WikiContext ctx, final int type, final String source, String message ) {
         message = TextUtil.replaceString( message, "\r\n", "\\r\\n" );
         message = TextUtil.replaceString( message, "\"", "\\\"" );
 
-        String uid = getUniqueID();
+        final String uid = getUniqueID();
 
-        String page   = ctx.getPage().getName();
+        final String page   = ctx.getPage().getName();
         String reason = "UNKNOWN";
-        String addr   = ctx.getHttpRequest() != null ? HttpUtil.getRemoteAddress( ctx.getHttpRequest() ) : "-";
+        final String addr   = ctx.getHttpRequest() != null ? HttpUtil.getRemoteAddress( ctx.getHttpRequest() ) : "-";
 
         switch( type ) {
             case REJECT:
@@ -324,10 +327,10 @@
     }
 
     /** {@inheritDoc} */
-    public String preSave( WikiContext context, String content ) throws RedirectException {
+    @Override public String preSave( final WikiContext context, final String content ) throws RedirectException {
         cleanBanList();
         refreshBlacklists( context );
-        Change change = getChange( context, content );
+        final Change change = getChange( context, content );
 
         if( !ignoreThisUser( context ) ) {
             checkBanList( context, change );
@@ -338,7 +341,7 @@
         }
 
         if( !m_stopAtFirstMatch ) {
-            Integer score = ( Integer )context.getVariable( ATTR_SPAMFILTER_SCORE );
+            final Integer score = ( Integer )context.getVariable( ATTR_SPAMFILTER_SCORE );
 
             if( score != null && score.intValue() >= m_scoreLimit ) {
                 throw new RedirectException( "Herb says you got too many points", getRedirectPage( context ) );
@@ -349,16 +352,16 @@
         return content;
     }
 
-    private void checkPageName(WikiContext context, String content, Change change) throws RedirectException {
-        WikiPage page = context.getPage();
-        String pageName = page.getName();
-        int maxlength = Integer.valueOf(m_pageNameMaxLength);
+    private void checkPageName( final WikiContext context, final String content, final Change change) throws RedirectException {
+        final WikiPage page = context.getPage();
+        final String pageName = page.getName();
+        final int maxlength = Integer.valueOf(m_pageNameMaxLength);
         if ( pageName.length() > maxlength) {
             //
             //  Spam filter has a match.
             //
 
-            String uid = log( context, REJECT, REASON_PAGENAME_TOO_LONG + "(" + m_pageNameMaxLength + ")" , pageName);
+            final String uid = log( context, REJECT, REASON_PAGENAME_TOO_LONG + "(" + m_pageNameMaxLength + ")" , pageName);
 
             log.info("SPAM:PageNameTooLong (" + uid + "). The length of the page name is too large (" + pageName.length() + " , limit is " + m_pageNameMaxLength + ")");
             checkStrategy( context, REASON_PAGENAME_TOO_LONG, "Herb says '" + pageName + "' is a bad pageName and I trust Herb! (Incident code " + uid + ")" );
@@ -366,7 +369,7 @@
         }
     }
 
-    private void checkStrategy( WikiContext context, String error, String message ) throws RedirectException {
+    private void checkStrategy( final WikiContext context, final String error, final String message ) throws RedirectException {
         if( m_stopAtFirstMatch ) {
             throw new RedirectException( message, getRedirectPage( context ) );
         }
@@ -389,18 +392,18 @@
      * @param list
      * @return A Collection of the Patterns that were found from the lists.
      */
-    private Collection< Pattern > parseWordList( WikiPage source, String list ) {
-        ArrayList< Pattern > compiledpatterns = new ArrayList< Pattern >();
+    private Collection< Pattern > parseWordList( final WikiPage source, final String list ) {
+        final ArrayList< Pattern > compiledpatterns = new ArrayList<>();
 
         if( list != null ) {
-            StringTokenizer tok = new StringTokenizer( list, " \t\n" );
+            final StringTokenizer tok = new StringTokenizer( list, " \t\n" );
 
             while( tok.hasMoreTokens() ) {
-                String pattern = tok.nextToken();
+                final String pattern = tok.nextToken();
 
                 try {
                     compiledpatterns.add( m_compiler.compile( pattern ) );
-                } catch( MalformedPatternException e ) {
+                } catch( final MalformedPatternException e ) {
                     log.debug( "Malformed spam filter pattern " + pattern );
                     source.setAttribute("error", "Malformed spam filter pattern " + pattern);
                 }
@@ -416,12 +419,12 @@
      *  @param list
      *  @return The parsed blacklist patterns.
      */
-    private Collection< Pattern > parseBlacklist( String list ) {
-        ArrayList< Pattern > compiledpatterns = new ArrayList< Pattern >();
+    private Collection< Pattern > parseBlacklist( final String list ) {
+        final ArrayList< Pattern > compiledpatterns = new ArrayList<>();
 
         if( list != null ) {
             try {
-                BufferedReader in = new BufferedReader( new StringReader(list) );
+                final BufferedReader in = new BufferedReader( new StringReader(list) );
                 String line;
                 while( (line = in.readLine() ) != null ) {
                     line = line.trim();
@@ -434,11 +437,11 @@
 
                     try {
                         compiledpatterns.add( m_compiler.compile( line ) );
-                    } catch( MalformedPatternException e ) {
+                    } catch( final MalformedPatternException e ) {
                         log.debug( "Malformed spam filter pattern " + line );
                     }
                 }
-            } catch( IOException e ) {
+            } catch( final IOException e ) {
                 log.info( "Could not read patterns; returning what I got" , e );
             }
         }
@@ -454,21 +457,21 @@
      *  @param content
      *  @throws RedirectException
      */
-    private synchronized void checkSinglePageChange( WikiContext context, String content, Change change ) 
+    private synchronized void checkSinglePageChange( final WikiContext context, final String content, final Change change )
     		throws RedirectException {
-        HttpServletRequest req = context.getHttpRequest();
+        final HttpServletRequest req = context.getHttpRequest();
 
         if( req != null ) {
-            String addr = HttpUtil.getRemoteAddress( req );
+            final String addr = HttpUtil.getRemoteAddress( req );
             int hostCounter = 0;
             int changeCounter = 0;
 
             log.debug( "Change is " + change.m_change );
 
-            long time = System.currentTimeMillis() - 60*1000L; // 1 minute
+            final long time = System.currentTimeMillis() - 60*1000L; // 1 minute
 
-            for( Iterator< Host > i = m_lastModifications.iterator(); i.hasNext(); ) {
-                Host host = i.next();
+            for( final Iterator< Host > i = m_lastModifications.iterator(); i.hasNext(); ) {
+                final Host host = i.next();
 
                 //
                 //  Check if this item is invalid
@@ -500,19 +503,19 @@
             //  Now, let's check against the limits.
             //
             if( hostCounter >= m_limitSinglePageChanges ) {
-                Host host = new Host( addr, null );
+                final Host host = new Host( addr, null );
                 m_temporaryBanList.add( host );
 
-                String uid = log( context, REJECT, REASON_TOO_MANY_MODIFICATIONS, change.m_change );
+                final String uid = log( context, REJECT, REASON_TOO_MANY_MODIFICATIONS, change.m_change );
                 log.info( "SPAM:TooManyModifications (" + uid + "). Added host " + addr + " to temporary ban list for doing too many modifications/minute" );
                 checkStrategy( context, REASON_TOO_MANY_MODIFICATIONS, "Herb says you look like a spammer, and I trust Herb! (Incident code " + uid + ")" );
             }
 
             if( changeCounter >= m_limitSimilarChanges ) {
-                Host host = new Host( addr, null );
+                final Host host = new Host( addr, null );
                 m_temporaryBanList.add( host );
 
-                String uid = log( context, REJECT, REASON_SIMILAR_MODIFICATIONS, change.m_change );
+                final String uid = log( context, REJECT, REASON_SIMILAR_MODIFICATIONS, change.m_change );
                 log.info( "SPAM:SimilarModifications (" + uid + "). Added host " + addr + " to temporary ban list for doing too many similar modifications" );
                 checkStrategy( context, REASON_SIMILAR_MODIFICATIONS, "Herb says you look like a spammer, and I trust Herb! (Incident code "+uid+")");
             }
@@ -523,16 +526,16 @@
             String tstChange  = change.toString();
             int    urlCounter = 0;
             while( m_matcher.contains( tstChange,m_urlPattern ) ) {
-                MatchResult m = m_matcher.getMatch();
+                final MatchResult m = m_matcher.getMatch();
                 tstChange = tstChange.substring( m.endOffset(0) );
                 urlCounter++;
             }
 
             if( urlCounter > m_maxUrls ) {
-                Host host = new Host( addr, null );
+                final Host host = new Host( addr, null );
                 m_temporaryBanList.add( host );
 
-                String uid = log( context, REJECT, REASON_TOO_MANY_URLS, change.toString() );
+                final String uid = log( context, REJECT, REASON_TOO_MANY_URLS, change.toString() );
                 log.info( "SPAM:TooManyUrls (" + uid + "). Added host " + addr + " to temporary ban list for adding too many URLs" );
                 checkStrategy( context, REASON_TOO_MANY_URLS, "Herb says you look like a spammer, and I trust Herb! (Incident code " + uid + ")" );
             }
@@ -565,7 +568,7 @@
      * @param change
      * @throws RedirectException
      */
-    private void checkAkismet( WikiContext context, Change change ) throws RedirectException {
+    private void checkAkismet( final WikiContext context, final Change change ) throws RedirectException {
         if( m_akismetAPIKey != null ) {
             if( m_akismet == null ) {
                 log.info( "Initializing Akismet spam protection." );
@@ -578,7 +581,7 @@
                 }
             }
 
-            HttpServletRequest req = context.getHttpRequest();
+            final HttpServletRequest req = context.getHttpRequest();
 
             //
             //  Akismet will mark all empty statements as spam, so we'll just
@@ -591,19 +594,19 @@
             if( req != null && m_akismet != null ) {
                 log.debug( "Calling Akismet to check for spam..." );
 
-                StopWatch sw = new StopWatch();
+                final StopWatch sw = new StopWatch();
                 sw.start();
 
-                String ipAddress     = HttpUtil.getRemoteAddress( req );
-                String userAgent     = req.getHeader( "User-Agent" );
-                String referrer      = req.getHeader( "Referer");
-                String permalink     = context.getViewURL( context.getPage().getName() );
-                String commentType   = context.getRequestContext().equals( WikiContext.COMMENT ) ? "comment" : "edit";
-                String commentAuthor = context.getCurrentUser().getName();
-                String commentAuthorEmail = null;
-                String commentAuthorURL   = null;
+                final String ipAddress     = HttpUtil.getRemoteAddress( req );
+                final String userAgent     = req.getHeader( "User-Agent" );
+                final String referrer      = req.getHeader( "Referer");
+                final String permalink     = context.getViewURL( context.getPage().getName() );
+                final String commentType   = context.getRequestContext().equals( WikiContext.COMMENT ) ? "comment" : "edit";
+                final String commentAuthor = context.getCurrentUser().getName();
+                final String commentAuthorEmail = null;
+                final String commentAuthorURL   = null;
 
-                boolean isSpam = m_akismet.commentCheck( ipAddress,
+                final boolean isSpam = m_akismet.commentCheck( ipAddress,
                                                          userAgent,
                                                          referrer,
                                                          permalink,
@@ -621,7 +624,7 @@
                     // Host host = new Host( ipAddress, null );
                     // m_temporaryBanList.add( host );
 
-                    String uid = log( context, REJECT, REASON_AKISMET, change.toString() );
+                    final String uid = log( context, REJECT, REASON_AKISMET, change.toString() );
                     log.info( "SPAM:Akismet (" + uid + "). Akismet thinks this change is spam; added host to temporary ban list." );
                     checkStrategy( context, REASON_AKISMET, "Akismet tells Herb you're a spammer, Herb trusts Akismet, and I trust Herb! (Incident code " + uid + ")" );
                 }
@@ -645,13 +648,13 @@
      * @param change
      * @throws RedirectException
      */
-    private void checkBotTrap( WikiContext context, Change change ) throws RedirectException {
-        HttpServletRequest request = context.getHttpRequest();
+    private void checkBotTrap( final WikiContext context, final Change change ) throws RedirectException {
+        final HttpServletRequest request = context.getHttpRequest();
 
         if( request != null ) {
-            String unspam = request.getParameter( getBotFieldName() );
+            final String unspam = request.getParameter( getBotFieldName() );
             if( unspam != null && unspam.length() > 0 ) {
-                String uid = log( context, REJECT, REASON_BOT_TRAP, change.toString() );
+                final String uid = log( context, REJECT, REASON_BOT_TRAP, change.toString() );
 
                 log.info( "SPAM:BotTrap (" + uid + ").  Wildly behaving bot detected." );
                 checkStrategy( context, REASON_BOT_TRAP, "Spamming attempt detected. (Incident code " + uid + ")" );
@@ -659,14 +662,14 @@
         }
     }
 
-    private void checkUTF8( WikiContext context, Change change ) throws RedirectException {
-        HttpServletRequest request = context.getHttpRequest();
+    private void checkUTF8( final WikiContext context, final Change change ) throws RedirectException {
+        final HttpServletRequest request = context.getHttpRequest();
 
         if( request != null ) {
-            String utf8field = request.getParameter( "encodingcheck" );
+            final String utf8field = request.getParameter( "encodingcheck" );
 
             if( utf8field != null && !utf8field.equals( "\u3041" ) ) {
-                String uid = log( context, REJECT, REASON_UTF8_TRAP, change.toString() );
+                final String uid = log( context, REJECT, REASON_UTF8_TRAP, change.toString() );
 
                 log.info( "SPAM:UTF8Trap (" + uid + ").  Wildly posting dumb bot detected." );
                 checkStrategy( context, REASON_UTF8_TRAP, "Spamming attempt detected. (Incident code " + uid + ")" );
@@ -676,10 +679,10 @@
 
     /** Goes through the ban list and cleans away any host which has expired from it. */
     private synchronized void cleanBanList() {
-        long now = System.currentTimeMillis();
+        final long now = System.currentTimeMillis();
 
-        for( Iterator< Host > i = m_temporaryBanList.iterator(); i.hasNext(); ) {
-            Host host = i.next();
+        for( final Iterator< Host > i = m_temporaryBanList.iterator(); i.hasNext(); ) {
+            final Host host = i.next();
 
             if( host.getReleaseTime() < now ) {
                 log.debug( "Removed host " + host.getAddress() + " from temporary ban list (expired)" );
@@ -694,16 +697,16 @@
      *  @param context
      *  @throws RedirectException
      */
-    private void checkBanList( WikiContext context, Change change ) throws RedirectException {
-        HttpServletRequest req = context.getHttpRequest();
+    private void checkBanList( final WikiContext context, final Change change ) throws RedirectException {
+        final HttpServletRequest req = context.getHttpRequest();
 
         if( req != null ) {
-            String remote = HttpUtil.getRemoteAddress(req);
-            long now = System.currentTimeMillis();
+            final String remote = HttpUtil.getRemoteAddress(req);
+            final long now = System.currentTimeMillis();
 
-            for( Host host : m_temporaryBanList ) {
+            for( final Host host : m_temporaryBanList ) {
                 if( host.getAddress().equals( remote ) ) {
-                    long timeleft = ( host.getReleaseTime() - now ) / 1000L;
+                    final long timeleft = ( host.getReleaseTime() - now ) / 1000L;
 
                     log( context, REJECT, REASON_IP_BANNED_TEMPORARILY, change.m_change );
                     checkStrategy( context, REASON_IP_BANNED_TEMPORARILY,
@@ -726,21 +729,21 @@
             //
             //  Rebuild, if the spam words page, the attachment or the IP ban page has changed since.
             //
-            final WikiPage sourceSpam = context.getEngine().getPageManager().getPage( m_forbiddenWordsPage );
+            final WikiPage sourceSpam = context.getEngine().getManager( PageManager.class ).getPage( m_forbiddenWordsPage );
             if( sourceSpam != null ) {
                 if( m_spamPatterns == null || m_spamPatterns.isEmpty() || sourceSpam.getLastModified().after( m_lastRebuild ) ) {
                     rebuild = true;
                 }
             }
 
-            final Attachment att = context.getEngine().getAttachmentManager().getAttachmentInfo( context, m_blacklist );
+            final Attachment att = context.getEngine().getManager( AttachmentManager.class ).getAttachmentInfo( context, m_blacklist );
             if( att != null ) {
                 if( m_spamPatterns == null || m_spamPatterns.isEmpty() || att.getLastModified().after( m_lastRebuild ) ) {
                     rebuild = true;
                 }
             }
 
-            final WikiPage sourceIPs = context.getEngine().getPageManager().getPage( m_forbiddenIPsPage );
+            final WikiPage sourceIPs = context.getEngine().getManager( PageManager.class ).getPage( m_forbiddenIPsPage );
             if( sourceIPs != null ) {
                 if( m_IPPatterns == null || m_IPPatterns.isEmpty() || sourceIPs.getLastModified().after( m_lastRebuild ) ) {
                     rebuild = true;
@@ -761,7 +764,7 @@
                 log.info( "IP filter reloaded - recognizing " + m_IPPatterns.size() + " patterns from page " + m_forbiddenIPsPage );
 
                 if( att != null ) {
-                    final InputStream in = context.getEngine().getAttachmentManager().getAttachmentStream(att);
+                    final InputStream in = context.getEngine().getManager( AttachmentManager.class ).getAttachmentStream(att);
                     final StringWriter out = new StringWriter();
                     FileUtil.copyContents( new InputStreamReader( in, StandardCharsets.UTF_8 ), out );
                     final Collection< Pattern > blackList = parseBlacklist( out.toString() );
@@ -784,7 +787,7 @@
      *  @param change
      *  @throws RedirectException
      */
-    private void checkPatternList( WikiContext context, String content, Change change ) throws RedirectException {
+    private void checkPatternList( final WikiContext context, final String content, final Change change ) throws RedirectException {
         //
         //  If we have no spam patterns defined, or we're trying to save
         //  the page containing the patterns, just return.
@@ -798,14 +801,14 @@
             ch += HttpUtil.getRemoteAddress( context.getHttpRequest() );
         }
 
-        for( Pattern p : m_spamPatterns ) {
+        for( final Pattern p : m_spamPatterns ) {
             // log.debug("Attempting to match page contents with "+p.getPattern());
 
             if( m_matcher.contains( ch, p ) ) {
                 //
                 //  Spam filter has a match.
                 //
-                String uid = log( context, REJECT, REASON_REGEXP + "(" + p.getPattern() + ")", ch );
+                final String uid = log( context, REJECT, REASON_REGEXP + "(" + p.getPattern() + ")", ch );
 
                 log.info( "SPAM:Regexp (" + uid + "). Content matches the spam filter '" + p.getPattern() + "'" );
                 checkStrategy( context, REASON_REGEXP, "Herb says '" + p.getPattern() + "' is a bad spam word and I trust Herb! (Incident code " + uid + ")" );
@@ -820,7 +823,7 @@
      *  @param context
      *  @throws RedirectException
      */
-    private void checkIPList( WikiContext context ) throws RedirectException {
+    private void checkIPList( final WikiContext context ) throws RedirectException {
         //
         //  If we have no IP patterns defined, or we're trying to save
         //  the page containing the IP patterns, just return.
@@ -829,17 +832,17 @@
             return;
         }
 
-        String remoteIP = HttpUtil.getRemoteAddress( context.getHttpRequest() );
+        final String remoteIP = HttpUtil.getRemoteAddress( context.getHttpRequest() );
         log.info("Attempting to match remoteIP " + remoteIP + " against " + m_IPPatterns.size() + " patterns");
 
-        for( Pattern p : m_IPPatterns ) {
+        for( final Pattern p : m_IPPatterns ) {
              log.debug("Attempting to match remoteIP with " + p.getPattern());
 
             if( m_matcher.contains( remoteIP, p ) ) {
 
                 //  IP filter has a match.
                 //
-                String uid = log( context, REJECT, REASON_IP_BANNED_PERMANENTLY + "(" + p.getPattern() + ")", remoteIP );
+                final String uid = log( context, REJECT, REASON_IP_BANNED_PERMANENTLY + "(" + p.getPattern() + ")", remoteIP );
 
                 log.info( "SPAM:IPBanList (" + uid + "). remoteIP matches the IP filter '" + p.getPattern() + "'" );
                 checkStrategy( context, REASON_IP_BANNED_PERMANENTLY, "Herb says '" + p.getPattern() + "' is a banned IP and I trust Herb! (Incident code " + uid + ")" );
@@ -847,8 +850,8 @@
         }
     }
 
-    private void checkPatternList( WikiContext context, String content, String change ) throws RedirectException {
-        Change c = new Change();
+    private void checkPatternList( final WikiContext context, final String content, final String change ) throws RedirectException {
+        final Change c = new Change();
         c.m_change = change;
         checkPatternList( context, content, c );
     }
@@ -863,13 +866,13 @@
     private static Change getChange( final WikiContext context, final String newText ) {
         final WikiPage page = context.getPage();
         final StringBuffer change = new StringBuffer();
-        final WikiEngine engine = context.getEngine();
+        final Engine engine = context.getEngine();
         // Get current page version
 
         final Change ch = new Change();
         
         try {
-            final String oldText = engine.getPageManager().getPureText( page.getName(), WikiProvider.LATEST_VERSION );
+            final String oldText = engine.getManager( PageManager.class ).getPureText( page.getName(), WikiProvider.LATEST_VERSION );
             final String[] first  = Diff.stringToArray( oldText );
             final String[] second = Diff.stringToArray( newText );
             final Revision rev = Diff.diff( first, second, new MyersDiff() );
@@ -924,7 +927,7 @@
      * @param context
      * @return True, if this users should be ignored.
      */
-    private boolean ignoreThisUser( WikiContext context ) {
+    private boolean ignoreThisUser( final WikiContext context ) {
         if( context.hasAdminPermissions() ) {
             return true;
         }
@@ -946,11 +949,11 @@
      *  @return A random string
      */
     private static String getUniqueID() {
-        StringBuilder sb = new StringBuilder();
-        Random rand = new Random();
+        final StringBuilder sb = new StringBuilder();
+        final Random rand = new Random();
 
         for( int i = 0; i < 6; i++ ) {
-            char x = ( char )( 'A' + rand.nextInt( 26 ) );
+            final char x = ( char )( 'A' + rand.nextInt( 26 ) );
             sb.append( x );
         }
 
@@ -963,7 +966,7 @@
      *  @param ctx WikiContext
      *  @return An URL to redirect to
      */
-    private String getRedirectPage( WikiContext ctx ) {
+    private String getRedirectPage( final WikiContext ctx ) {
         if( m_useCaptcha ) {
             return ctx.getURL( WikiContext.NONE, "Captcha.jsp", "page="+ctx.getEngine().encodeName( ctx.getPage().getName() ) );
         }
@@ -979,12 +982,12 @@
      *  @return False, if this userprofile is suspect and should not be allowed to be added.
      *  @since 2.6.1
      */
-    public boolean isValidUserProfile( WikiContext context, UserProfile profile ) {
+    public boolean isValidUserProfile( final WikiContext context, final UserProfile profile ) {
         try {
             checkPatternList( context, profile.getEmail(), profile.getEmail() );
             checkPatternList( context, profile.getFullname(), profile.getFullname() );
             checkPatternList( context, profile.getLoginName(), profile.getLoginName() );
-        } catch( RedirectException e ) {
+        } catch( final RedirectException e ) {
             log.info("Detected attempt to create a spammer user account (see above for rejection reason)");
             return false;
         }
@@ -1001,13 +1004,13 @@
      *  @since 2.6
      *  @return A hash value for this page and session
      */
-    public static final String getSpamHash( WikiPage page, HttpServletRequest request ) {
+    public static final String getSpamHash( final WikiPage page, final HttpServletRequest request ) {
         long lastModified = 0;
 
         if( page.getLastModified() != null ) {
             lastModified = page.getLastModified().getTime();
         }
-        long remote = HttpUtil.getRemoteAddress( request ).hashCode();
+        final long remote = HttpUtil.getRemoteAddress( request ).hashCode();
 
         return Long.toString( lastModified ^ remote );
     }
@@ -1020,7 +1023,7 @@
      *  @return The name to be used in the hash field
      *  @since  2.6
      */
-    public static final String getHashFieldName( HttpServletRequest request ) {
+    public static final String getHashFieldName( final HttpServletRequest request ) {
         String hash = null;
 
         if( request.getSession() != null ) {
@@ -1055,15 +1058,15 @@
      *  @throws IOException If redirection fails
      *  @since 2.6
      */
-    public static final boolean checkHash( WikiContext context, PageContext pageContext ) throws IOException {
-        String hashName = getHashFieldName( (HttpServletRequest)pageContext.getRequest() );
+    public static final boolean checkHash( final WikiContext context, final PageContext pageContext ) throws IOException {
+        final String hashName = getHashFieldName( (HttpServletRequest)pageContext.getRequest() );
 
         if( pageContext.getRequest().getParameter(hashName) == null ) {
             if( pageContext.getAttribute( hashName ) == null ) {
-                Change change = getChange( context, EditorManager.getEditedText( pageContext ) );
+                final Change change = getChange( context, EditorManager.getEditedText( pageContext ) );
                 log( context, REJECT, "MissingHash", change.m_change );
 
-                String redirect = context.getURL( WikiContext.VIEW,"SessionExpired" );
+                final String redirect = context.getURL( WikiContext.VIEW,"SessionExpired" );
                 ( ( HttpServletResponse )pageContext.getResponse() ).sendRedirect( redirect );
                 return false;
             }
@@ -1081,7 +1084,7 @@
      */
     public static final String insertInputFields( final PageContext pageContext ) {
         final WikiContext ctx = WikiContext.findContext( pageContext );
-        final WikiEngine engine = ctx.getEngine();
+        final Engine engine = ctx.getEngine();
         final StringBuilder sb = new StringBuilder();
         if( engine.getContentEncoding().equals( StandardCharsets.UTF_8 ) ) {
             sb.append( "<input name='encodingcheck' type='hidden' value='\u3041' />\n" );
@@ -1118,7 +1121,7 @@
             return m_change;
         }
 
-        public Host( String ipaddress, Change change ) {
+        public Host( final String ipaddress, final Change change ) {
             m_address = ipaddress;
             m_change  = change;
             m_releaseTime = System.currentTimeMillis() + m_banTime * 60 * 1000L;
@@ -1132,18 +1135,18 @@
         public int    m_adds;
         public int    m_removals;
         
-        public String toString() {
+        @Override public String toString() {
             return m_change;
         }
         
-        public boolean equals( Object o ) {
+        @Override public boolean equals( final Object o ) {
             if( o instanceof Change ) {
                 return m_change.equals( ( ( Change )o ).m_change );
             }
             return false;
         }
         
-        public int hashCode() {
+        @Override public int hashCode() {
             return m_change.hashCode() + 17;
         }
         
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java
index 1789031..8c56300 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java
@@ -55,53 +55,44 @@
      * @param params {@inheritDoc}
      * @return {@inheritDoc}
      */
-    public String execute( WikiContext ctx, Map< String, String > params )
-        throws PluginException
-    {
-        //
+    @Override public String execute( final WikiContext ctx, final Map< String, String > params ) throws PluginException {
         //  If there is no HTTP request, returns immediately.
-        //
-        if( ctx.getHttpRequest() == null )
-        {
+        if( ctx.getHttpRequest() == null ) {
             return "";
         }
-        ResourceBundle rb = Preferences.getBundle( ctx, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
+        final ResourceBundle rb = Preferences.getBundle( ctx, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
         
         // If we are NOT here due to this form being submitted, we do nothing.
         // The submitted form MUST have parameter 'formname' equal to the name
         // parameter of this Form plugin.
 
-        String formName   = params.get( PARAM_FORM );
-        String submitForm = ctx.getHttpParameter( PARAM_FORMNAMEHIDDEN );
-        String populator  = params.get( PARAM_POPULATE );
+        final String formName   = params.get( PARAM_FORM );
+        final String submitForm = ctx.getHttpParameter( PARAM_FORMNAMEHIDDEN );
+        final String populator  = params.get( PARAM_POPULATE );
 
-        if( submitForm == null || formName == null || 
-            !formName.equals( submitForm ) )
-        {
+        if( formName == null || !formName.equals( submitForm ) ) {
             // No submitForm -> this was not a submission from the
             // generated form.  If populate is specified, we'll go
             // ahead and let the handler (populator) put stuff into
             // the context, otherwise we'll just hide.
-            if( populator == null || !PARAM_HANDLER.equals( populator ) )
+            if( !PARAM_HANDLER.equals( populator ) )
                 return "";
             // If population was allowed, we should first  
         }
 
-        String handler = params.get( PARAM_HANDLER );
-        if( handler == null || handler.length() == 0 )
-        {
+        final String handler = params.get( PARAM_HANDLER );
+        if( handler == null || handler.length() == 0 ) {
             // Need to print out an error here as this form is misconfigured
             return "<p class=\"error\">" + MessageFormat.format( rb.getString( "formoutput.missingargument" ), PARAM_HANDLER ) + "</p>";
         }
 
-        String sourcePage = ctx.getPage().getName();
-        String submitServlet = ctx.getURL( WikiContext.VIEW, sourcePage );
+        final String sourcePage = ctx.getPage().getName();
+        final String submitServlet = ctx.getURL( WikiContext.VIEW, sourcePage );
 
         // If there is previous FormInfo available - say, from a
         // FormSet plugin - use it.
         FormInfo info = getFormInfo( ctx );
-        if( info == null )
-        {
+        if( info == null ) {
             // Reconstruct the form info from post data
             info = new FormInfo();
             info.setName( formName );
@@ -110,31 +101,24 @@
         info.setHandler( handler );
         info.setAction( submitServlet );
 
-        // Sift out all extra parameters, leaving only those submitted
-        // in the HTML FORM.
-        Map< String, String > handlerParams = FormUtil.requestToMap( ctx.getHttpRequest(), 
-                                                                     HANDLERPARAM_PREFIX );
+        // Sift out all extra parameters, leaving only those submitted in the HTML FORM.
+        final Map< String, String > handlerParams = FormUtil.requestToMap( ctx.getHttpRequest(), HANDLERPARAM_PREFIX );
         // Previous submission info may be available from FormSet
         // plugin - add, don't replace.
         info.addSubmission( handlerParams );
 
         // Pass the _body parameter from FormOutput on to the handler
-        info.getSubmission().put( DefaultPluginManager.PARAM_BODY, 
-                                  params.get(DefaultPluginManager.PARAM_BODY)); 
+        info.getSubmission().put( DefaultPluginManager.PARAM_BODY, params.get(DefaultPluginManager.PARAM_BODY ) );
 
         String handlerOutput = null;
         String error = null;
-        try
-        {
-            // The plugin _can_ modify the parameters, so we make sure
-            // they stay with us.
-            PluginManager pm = ctx.getEngine().getPluginManager();
+        try {
+            // The plugin _can_ modify the parameters, so we make sure they stay with us.
+            final PluginManager pm = ctx.getEngine().getManager( PluginManager.class );
             handlerOutput = pm.execute( ctx, handler, info.getSubmission() );
             info.setResult( handlerOutput );
             info.setStatus( FormInfo.EXECUTED );
-        }
-        catch( PluginException pe )
-        {
+        } catch( final PluginException pe ) {
             error = "<p class=\"error\">" + pe.getMessage() + "</p>";
             info.setError( error );
             info.setStatus( FormInfo.ERROR );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 324d347..8dcaa8f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -35,6 +35,7 @@
 import org.apache.wiki.auth.acl.AclEntry;
 import org.apache.wiki.auth.acl.AclEntryImpl;
 import org.apache.wiki.auth.user.UserProfile;
+import org.apache.wiki.diff.DifferenceManager;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
@@ -43,6 +44,7 @@
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.providers.RepositoryModifiedException;
 import org.apache.wiki.providers.WikiPageProvider;
+import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.ClassUtil;
 import org.apache.wiki.util.TextUtil;
 import org.apache.wiki.workflow.Decision;
@@ -184,7 +186,7 @@
             //  Empty the references and yay, it shall be recalculated
             final WikiPage p = m_provider.getPageInfo( pageName, version );
 
-            m_engine.getReferenceManager().updateReferences( p );
+            m_engine.getManager( ReferenceManager.class ).updateReferences( p );
             m_engine.getSearchManager().reindexPage( p );
             text = m_provider.getPageText( pageName, version );
         }
@@ -196,7 +198,7 @@
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPureText(String, int)
      */
-    public String getPureText( final String page, final int version ) {
+    @Override public String getPureText( final String page, final int version ) {
         String result = null;
         try {
             result = getPageText( page, version );
@@ -214,12 +216,12 @@
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getText(String, int)
      */
-    public String getText( final String page, final int version ) {
+    @Override public String getText( final String page, final int version ) {
         final String result = getPureText( page, version );
         return TextUtil.replaceEntities( result );
     }
 
-    public void saveText( final WikiContext context, final String text ) throws WikiException {
+    @Override public void saveText( final WikiContext context, final String text ) throws WikiException {
         // Check if page data actually changed; bail if not
         final WikiPage page = context.getPage();
         final String oldText = getPureText( page );
@@ -243,7 +245,7 @@
         final Principal submitter = context.getCurrentUser();
         final Step prepTask = m_engine.getTasksManager().buildPreSaveWikiPageTask( context, proposedText );
         final Step completionTask = m_engine.getTasksManager().buildSaveWikiPageTask();
-        final String diffText = m_engine.getDifferenceManager().makeDiff( context, oldText, proposedText );
+        final String diffText = m_engine.getManager( DifferenceManager.class ).makeDiff( context, oldText, proposedText );
         final boolean isAuthenticated = context.getWikiSession().isAuthenticated();
         final Fact[] facts = new Fact[ 5 ];
         facts[ 0 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PAGE_NAME, page.getName() );
@@ -363,7 +365,7 @@
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPage(java.lang.String)
      */
-    public WikiPage getPage( final String pagereq ) {
+    @Override public WikiPage getPage( final String pagereq ) {
         return getPage( pagereq, WikiProvider.LATEST_VERSION );
     }
 
@@ -371,7 +373,7 @@
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPage(java.lang.String, int)
      */
-    public WikiPage getPage( final String pagereq, final int version ) {
+    @Override public WikiPage getPage( final String pagereq, final int version ) {
         try {
             WikiPage p = getPageInfo( pagereq, version );
             if( p == null ) {
@@ -404,9 +406,9 @@
             LOG.info("Repository has been modified externally while fetching info for " + pageName);
             page = m_provider.getPageInfo(pageName, version);
             if (page != null) {
-                m_engine.getReferenceManager().updateReferences(page);
+                m_engine.getManager( ReferenceManager.class ).updateReferences(page);
             } else {
-                m_engine.getReferenceManager().pageRemoved(new WikiPage(m_engine, pageName));
+                m_engine.getManager( ReferenceManager.class ).pageRemoved(new WikiPage(m_engine, pageName));
             }
         }
 
@@ -440,7 +442,7 @@
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getCurrentProvider()
      */
-    public String getCurrentProvider() {
+    @Override public String getCurrentProvider() {
         return getProvider().getClass().getName();
     }
 
@@ -519,7 +521,7 @@
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#wikiPageExists(java.lang.String)
      */
-    public boolean wikiPageExists( final String page ) {
+    @Override public boolean wikiPageExists( final String page ) {
         if( m_engine.getCommandResolver().getSpecialPageReference( page ) != null ) {
             return true;
         }
@@ -542,7 +544,7 @@
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#wikiPageExists(java.lang.String, int)
      */
-    public boolean wikiPageExists( final String page, final int version ) throws ProviderException {
+    @Override public boolean wikiPageExists( final String page, final int version ) throws ProviderException {
         if( m_engine.getCommandResolver().getSpecialPageReference( page ) != null ) {
             return true;
         }
@@ -583,13 +585,13 @@
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#deletePage(java.lang.String)
      */
-    public void deletePage( final String pageName ) throws ProviderException {
+    @Override public void deletePage( final String pageName ) throws ProviderException {
         final WikiPage p = getPage( pageName );
         if( p != null ) {
             if( p instanceof Attachment ) {
                 m_engine.getAttachmentManager().deleteAttachment( ( Attachment )p );
             } else {
-                final Collection< String > refTo = m_engine.getReferenceManager().findRefersTo( pageName );
+                final Collection< String > refTo = m_engine.getManager( ReferenceManager.class ).findRefersTo( pageName );
                 // May return null, if the page does not exist or has not been indexed yet.
 
                 if( m_engine.getAttachmentManager().hasAttachments( p ) ) {