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/27 15:10:31 UTC

[jspwiki] 06/20: JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (1)

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 d127551e953d368d2ad23cf2c669246130456d4b
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:07:09 2020 +0100

    JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (1)
---
 .../src/main/java/org/apache/wiki/WatchDog.java         |  4 ++--
 .../main/java/org/apache/wiki/WikiBackgroundThread.java | 13 ++++++-------
 .../src/main/java/org/apache/wiki/WikiPage.java         |  2 +-
 .../src/main/java/org/apache/wiki/WikiProvider.java     |  2 +-
 .../src/main/java/org/apache/wiki/WikiServlet.java      | 17 ++++++++---------
 .../java/org/apache/wiki/api/filters/PageFilter.java    |  2 +-
 .../org/apache/wiki/api/plugin/InitializablePlugin.java |  2 +-
 .../org/apache/wiki/attachment/AttachmentServlet.java   |  2 +-
 .../org/apache/wiki/auth/AuthenticationManager.java     | 16 ++++++++--------
 .../apache/wiki/auth/DefaultAuthenticationManager.java  |  2 +-
 .../auth/login/CookieAuthenticationLoginModule.java     |  3 ++-
 .../org/apache/wiki/diff/DefaultDifferenceManager.java  |  2 +-
 .../org/apache/wiki/filters/DefaultFilterManager.java   |  5 +++--
 13 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WatchDog.java b/jspwiki-main/src/main/java/org/apache/wiki/WatchDog.java
index ad261bd..07b6ac1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WatchDog.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WatchDog.java
@@ -60,7 +60,7 @@ public final class WatchDog {
      *  Returns the current watchdog for the current thread. This is the preferred method of getting you a Watchdog, since it
      *  keeps an internal list of Watchdogs for you so that there won't be more than one watchdog per thread.
      *
-     *  @param engine The WikiEngine to which the Watchdog should be bonded to.
+     *  @param engine The Engine to which the Watchdog should be bonded to.
      *  @return A usable WatchDog object.
      */
     public static WatchDog getCurrentWatchDog( final Engine engine ) {
@@ -102,7 +102,7 @@ public final class WatchDog {
     /**
      *  Creates a new WatchDog for a Thread.  The Thread is wrapped in a Watchable wrapper for this purpose.
      *
-     *  @param engine The WikiEngine
+     *  @param engine The Engine
      *  @param thread A Thread for watching.
      */
     public WatchDog( final Engine engine, final Thread thread ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java
index 8bda0fa..b878173 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java
@@ -28,8 +28,7 @@ import org.apache.wiki.event.WikiEventListener;
 /**
  * Abstract Thread subclass that operates in the background; when it detects the {@link WikiEngineEvent#SHUTDOWN} event,
  * it terminates itself. Subclasses of this method need only implement the method {@link #backgroundTask()}, instead of
- * the normal {@link Thread#run()}, and provide a constructor that passes the WikiEngine and sleep interval. This 
- * class is thread-safe.
+ * the normal {@link Thread#run()}, and provide a constructor that passes the Engine and sleep interval. This class is thread-safe.
  */
 public abstract class WikiBackgroundThread extends Thread implements WikiEventListener {
 	
@@ -78,7 +77,7 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
     public abstract void backgroundTask() throws Exception;
     
     /**
-     * Returns the WikiEngine that created this background thread.
+     * Returns the Engine that created this background thread.
      * 
      * @return the wiki engine
      */
@@ -104,7 +103,8 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
      * 
      * @see java.lang.Thread#run()
      */
-    @Override public final void run() {
+    @Override
+    public final void run() {
         try {
             // Perform the initial startup task
             final String name = getName();
@@ -154,9 +154,8 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
     }
     
     /**
-     * Executes a task just after the thread's {@link Thread#run()} method starts, but before the 
-     * {@link #backgroundTask()} task executes. By default, this method does nothing; override it to implement 
-     * custom functionality.
+     * Executes a task just after the thread's {@link Thread#run()} method starts, but before the {@link #backgroundTask()} task executes.
+     * By default, this method does nothing; override it to implement custom functionality.
      * 
      * @throws Exception Any exception can be thrown.
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
index b69b240..9dbc46b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
@@ -74,7 +74,7 @@ public class WikiPage implements Cloneable, Comparable< WikiPage > {
     /**
      *  Create a new WikiPage using a given engine and name.
      *  
-     *  @param engine The WikiEngine that owns this page.
+     *  @param engine The Engine that owns this page.
      *  @param name   The name of the page.
      */
     public WikiPage( final Engine engine, final String name ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
index c401dae..a001f7f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
@@ -38,7 +38,7 @@ public interface WikiProvider {
     /**
      *  Initializes the page provider.
      *
-     *  @param engine WikiEngine to own this provider
+     *  @param engine Engine to own this provider
      *  @param properties A set of properties used to initialize this provider
      *  @throws NoRequiredPropertyException If the provider needs a property which is not found in the property set
      *  @throws IOException If there is an IO problem
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
index 45c5f2f..a2dcdaa 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
@@ -20,7 +20,9 @@ package org.apache.wiki;
 
 import net.sf.ehcache.CacheManager;
 import org.apache.log4j.Logger;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.url.DefaultURLConstructor;
+import org.apache.wiki.url.URLConstructor;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletConfig;
@@ -32,16 +34,15 @@ import java.io.IOException;
 
 
 /**
- * This provides a master servlet for dealing with short urls.  It mostly does
- * redirects to the proper JSP pages. It also intercepts the servlet
- * shutdown events and uses it to signal wiki shutdown.
+ * This provides a master servlet for dealing with short urls.  It mostly does redirects to the proper JSP pages. It also intercepts the
+ * servlet shutdown events and uses it to signal wiki shutdown.
  *
  * @since 2.2
  */
 public class WikiServlet extends HttpServlet {
 
     private static final long serialVersionUID = 3258410651167633973L;
-    private WikiEngine m_engine;
+    private Engine m_engine;
     private static final Logger log = Logger.getLogger( WikiServlet.class.getName() );
 
     /**
@@ -55,10 +56,8 @@ public class WikiServlet extends HttpServlet {
     }
 
     /**
-     * Destroys the WikiServlet; called by the servlet container
-     * when shutting down the webapp. This method calls the
-     * protected method {@link WikiEngine#shutdown()}, which
-     * sends {@link org.apache.wiki.event.WikiEngineEvent#SHUTDOWN}
+     * Destroys the WikiServlet; called by the servlet container when shutting down the webapp. This method calls the
+     * protected method {@link WikiEngine#shutdown()}, which sends {@link org.apache.wiki.event.WikiEngineEvent#SHUTDOWN}
      * events to registered listeners.
      *
      * @see javax.servlet.GenericServlet#destroy()
@@ -91,7 +90,7 @@ public class WikiServlet extends HttpServlet {
             pageName = m_engine.getFrontPage(); // FIXME: Add special pages as well
         }
 
-        final String jspPage = m_engine.getURLConstructor().getForwardPage( req );
+        final String jspPage = m_engine.getManager( URLConstructor.class ).getForwardPage( req );
         final RequestDispatcher dispatcher = req.getRequestDispatcher( "/" + jspPage + "?page=" +
                                                                        m_engine.encodeName( pageName ) + "&" + req.getQueryString() );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
index 26d9008..36c906d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
@@ -43,7 +43,7 @@ public interface PageFilter {
     /**
      *  Is called whenever the a new PageFilter is instantiated and reset.
      *  
-     *  @param engine The WikiEngine whic owns this PageFilter
+     *  @param engine The Engine which owns this PageFilter
      *  @param properties The properties ripped from filters.xml.
      *  @throws FilterException If the filter could not be initialized. If this is thrown, the filter is not added to the internal queues.
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
index 1f4d33e..bb7a68a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
@@ -33,7 +33,7 @@ public interface InitializablePlugin {
     /**
      *  Called whenever the plugin is being instantiated for the first time.
      *  
-     *  @param engine The WikiEngine.
+     *  @param engine The Engine.
      *  @throws PluginException If something goes wrong.
      */
     void initialize( Engine engine ) throws PluginException;
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 366666b..1a1e0c4 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
@@ -108,7 +108,7 @@ public class AttachmentServlet extends HttpServlet {
     //private final DateFormat rfcDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
 
     /**
-     *  Initializes the servlet from WikiEngine properties.
+     *  Initializes the servlet from Engine properties.
      */
     @Override
     public void init( final ServletConfig config ) throws ServletException {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
index b1a01a2..e2c349b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
@@ -37,7 +37,7 @@ import java.util.Set;
 
 
 /**
- * Manages authentication activities for a WikiEngine: user login, logout, and credential refreshes. This class uses JAAS to determine how
+ * Manages authentication activities for a Engine: user login, logout, and credential refreshes. This class uses JAAS to determine how
  * users log in.
  * <p>
  * The login procedure is protected in addition by a mechanism which prevents a hacker to try and force-guess passwords by slowing down
@@ -68,7 +68,7 @@ public interface AuthenticationManager {
     String PROP_LOGIN_MODULE = "jspwiki.loginModule.class";
 
     /**
-     * Creates an AuthenticationManager instance for the given WikiEngine and
+     * Creates an AuthenticationManager instance for the given Engine and
      * the specified set of properties. All initialization for the modules is
      * done here.
      * @param engine the wiki engine
@@ -78,7 +78,7 @@ public interface AuthenticationManager {
     void initialize( Engine engine, Properties props ) throws WikiException;
 
     /**
-     * Returns true if this WikiEngine uses container-managed authentication. This method is used primarily for cosmetic purposes in the
+     * Returns true if this Engine uses container-managed authentication. This method is used primarily for cosmetic purposes in the
      * JSP tier, and performs no meaningful security function per se. Delegates to
      * {@link org.apache.wiki.auth.authorize.WebContainerAuthorizer#isContainerAuthorized()},
      * if used as the external authorizer; otherwise, returns <code>false</code>.
@@ -117,7 +117,7 @@ public interface AuthenticationManager {
     
     /**
      * Attempts to perform a WikiSession login for the given username/password combination using JSPWiki's custom authentication mode. In
-     * order to log in, the JAAS LoginModule supplied by the WikiEngine property {@link #PROP_LOGIN_MODULE} will be instantiated, and its
+     * order to log in, the JAAS LoginModule supplied by the Engine property {@link #PROP_LOGIN_MODULE} will be instantiated, and its
      * {@link javax.security.auth.spi.LoginModule#initialize(Subject, CallbackHandler, Map, Map)} method will be invoked. By default,
      * the {@link org.apache.wiki.auth.login.UserDatabaseLoginModule} class will be used. When the LoginModule's <code>initialize</code>
      * method is invoked, an options Map populated by properties keys prefixed by {@link #PREFIX_LOGIN_MODULE_OPTIONS} will be passed as a
@@ -143,16 +143,16 @@ public interface AuthenticationManager {
     void logout( HttpServletRequest request );
 
     /**
-     * Determines whether this WikiEngine allows users to assert identities using cookies instead of passwords. This is determined by inspecting
-     * the WikiEngine property {@link #PROP_ALLOW_COOKIE_ASSERTIONS}.
+     * Determines whether this Engine allows users to assert identities using cookies instead of passwords. This is determined by inspecting
+     * the Engine property {@link #PROP_ALLOW_COOKIE_ASSERTIONS}.
      *
      * @return <code>true</code> if cookies are allowed
      */
     boolean allowsCookieAssertions();
 
     /**
-     * Determines whether this WikiEngine allows users to authenticate using cookies instead of passwords. This is determined by inspecting
-     * the WikiEngine property {@link #PROP_ALLOW_COOKIE_AUTH}.
+     * Determines whether this Engine allows users to authenticate using cookies instead of passwords. This is determined by inspecting
+     * the Engine property {@link #PROP_ALLOW_COOKIE_AUTH}.
      *
      *  @return <code>true</code> if cookies are allowed for authentication
      *  @since 2.5.62
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
index ce76804..a5a9f13 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
@@ -400,7 +400,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
      * firing appropriate authentication events.
      *
      * @param session the user's current WikiSession
-     * @param authorizer the WikiEngine's configured Authorizer
+     * @param authorizer the Engine's configured Authorizer
      * @param request the user's HTTP session, which may be <code>null</code>
      */
     private void injectAuthorizerRoles( final WikiSession session, final Authorizer authorizer, final HttpServletRequest request ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
index 92b7057..9d93be4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
@@ -103,7 +103,8 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule {
      * @see javax.security.auth.spi.LoginModule#login()
      * {@inheritDoc}
      */
-    @Override public boolean login() throws LoginException {
+    @Override
+    public boolean login() throws LoginException {
         // Otherwise, let's go and look for the cookie!
         final HttpRequestCallback hcb = new HttpRequestCallback();
         final WikiEngineCallback wcb = new WikiEngineCallback();
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 2e10917..c4645ca 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
@@ -44,7 +44,7 @@ public class DefaultDifferenceManager implements DifferenceManager {
     /**
      * Creates a new DifferenceManager for the given engine.
      *
-     * @param engine The WikiEngine.
+     * @param engine The Engine.
      * @param props  A set of properties.
      */
     public DefaultDifferenceManager( final Engine engine, final Properties props ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
index b0004ef..619a7e7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
@@ -96,7 +96,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
     /**
      *  Constructs a new FilterManager object.
      *
-     *  @param engine The WikiEngine which owns the FilterManager
+     *  @param engine The Engine which owns the FilterManager
      *  @param props Properties to initialize the FilterManager with
      *  @throws WikiException If something goes wrong.
      */
@@ -116,7 +116,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @param priority The priority in which position to add it in.
      *  @throws IllegalArgumentException If the PageFilter is null or invalid.
      */
-    @Override public void addPageFilter( final PageFilter f, final int priority ) throws IllegalArgumentException {
+    @Override
+    public void addPageFilter( final PageFilter f, final int priority ) throws IllegalArgumentException {
         if( f == null ) {
             throw new IllegalArgumentException("Attempt to provide a null filter - this should never happen.  Please check your configuration (or if you're a developer, check your own code.)");
         }