You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2010/02/14 19:39:52 UTC

svn commit: r910061 - in /incubator/jspwiki/trunk: ./ etc/ src/java/org/apache/wiki/ src/java/org/apache/wiki/url/ tests/etc/ tests/java/org/apache/wiki/parser/

Author: ajaquith
Date: Sun Feb 14 18:39:46 2010
New Revision: 910061

URL: http://svn.apache.org/viewvc?rev=910061&view=rev
Log:
Installed StripesURLContructor as the default (and only) URL constructor. URLs are constructed according to the @UrlBinding annotations in the ActionBeans. Because of the checkins svn-201 through -203, the generated URLs are identical to the ones previously generated by DefaultURLConstructor (with one or two exceptions are previously noted). In the Beta timeframe, the FileBasedActionResolver will allow URL bindings to be externalized. The other URLConstructors will be removed before Beta... but not today.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/etc/jspwiki.properties
    incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java
    incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java
    incubator/jspwiki/trunk/tests/etc/jspwiki.properties
    incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=910061&r1=910060&r2=910061&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Feb 14 18:39:46 2010
@@ -1,3 +1,29 @@
+2010-02-14 Andrew Jaquith <ajaquith AT apache DOT org>
+
+        * 3.0.0-svn-206
+
+        * Fixed bug in TemplateResolution that prevented some JSPs from resolving.
+
+        * Installed StripesURLContructor as the default (and only) URL constructor.
+        URLs are constructed according to the @UrlBinding annotations in the
+        ActionBeans. Because of the checkins svn-201 through -203, the generated
+        URLs are identical to the ones previously generated by DefaultURLConstructor
+        (with one or two exceptions are previously noted). In the Beta timeframe,
+        the FileBasedActionResolver will allow URL bindings to be externalized.
+        The other URLConstructors will be removed before Beta... but not today.
+
+        * Changed a few classes that depend on Stripes to use "lazy
+        initialization." WikiContextFactory and StripesURLConstructor
+        must lazily initialize because they depend on StripesFilter
+        being initialized first. Cleaned up TestEngine also: it now
+        initializes a full mock Stripes filter stack at startup.
+        
+        * Eliminated WikiRuntimeConfiguration: it is no longer needed
+        because WikiEngine can easily be obtained without needing
+        a special Stripes config class. Less classes are always better.
+        
+        * Renamed ShortUrlRedirectFilter to ShortUrlFilter.
+
 2010-02-12 Andrew Jaquith <ajaquith AT apache DOT org>
 
         * 3.0.0-svn-205

Modified: incubator/jspwiki/trunk/etc/jspwiki.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/jspwiki.properties?rev=910061&r1=910060&r2=910061&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/jspwiki.properties (original)
+++ incubator/jspwiki/trunk/etc/jspwiki.properties Sun Feb 14 18:39:46 2010
@@ -328,41 +328,6 @@
 
 #############################################################################
 #
-#  URL Constructor
-#
-#  JSPWiki by default generates page and attachment links that use JSP
-#  pages and request parameters. It can also use alternative URL
-#  constructors so that URL pages resemble traditional website paths, too.
-#  You have three choices for generating URLs:
-#
-#     DefaultURLConstructor - uses JSPs for all references:
-#         http://mywiki.com/jspwiki/Wiki.jsp?page=Main
-#         http://mywiki.com/jspwiki/Edit.jsp?page=Main
-#
-#     ShortURLConstructor - uses path-like reference style:
-#         http://mywiki.com/jspwiki/wiki/Main
-#         http://mywiki.com/jspwiki/wiki/Main?do=Edit
-#
-#     ShortViewURLConstructor - uses path-like references for views; JSPs for everything else:
-#         http://mywiki.com/jspwiki/wiki/Main
-#         http://mywiki.com/jspwiki/Edit.jsp?page=Main
-#
-#  Of course, you can also write your own implementation if you wish.
-#
-#  For either of the ShortURL constructors, you can also specify a
-#  prefix path to go in front of page names. By default, the
-#  prefix is 'wiki/'.
-#
-#  Be warned that the ShortURLConstructor does not work well with any other editor
-#  except the built-in plaintext one.  Use ShortViewURLConstructor if you plan
-#  to enable any other ones.
-#
-#jspwiki.urlConstructor = DefaultURLConstructor
-#jspwiki.urlConstructor = ShortViewURLConstructor
-#jspwiki.shortURLConstructor.prefix = wiki/
-
-#############################################################################
-#
 # Rendering
 #
 # At this time, entries here are strictly for development and testing.

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=910061&r1=910060&r2=910061&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Sun Feb 14 18:39:46 2010
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "205";
+    public static final String     BUILD         = "206";
 
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java?rev=910061&r1=910060&r2=910061&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java Sun Feb 14 18:39:46 2010
@@ -81,6 +81,7 @@
 import org.apache.wiki.ui.progress.ProgressManager;
 import org.apache.wiki.ui.stripes.WikiActionBeanContext;
 import org.apache.wiki.ui.stripes.WikiInterceptor;
+import org.apache.wiki.url.StripesURLConstructor;
 import org.apache.wiki.url.URLConstructor;
 import org.apache.wiki.util.*;
 import org.apache.wiki.workflow.*;
@@ -240,7 +241,7 @@
     private ProgressManager  m_progressManager;
 
     /** Constructs URLs */
-    private URLConstructor   m_urlConstructor;
+    private StripesURLConstructor   m_urlConstructor;
 
     /** Generates RSS feed when requested. */
     private RSSGenerator     m_rssGenerator;
@@ -562,7 +563,7 @@
             
             Class<?> urlclass = ClassUtil.findClass( "org.apache.wiki.url",
                     TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
-            m_urlConstructor = (URLConstructor) urlclass.newInstance();
+            m_urlConstructor = new StripesURLConstructor();
             m_urlConstructor.initialize( this, props );
 
             m_contentManager    = (ContentManager)ClassUtil.getMappedObject(ContentManager.class.getName(), this );
@@ -605,7 +606,7 @@
             m_adminBeanManager = (AdminBeanManager)
                 ClassUtil.getMappedObject(AdminBeanManager.class.getName(),this);
 
-            // Since we want to use a page filters initilize() method
+            // Since we want to use a page filters initialize() method
             // as a engine startup listener where we can initialize global event listeners,
             // it must be called lastly, so that all object references in the engine
             // are availabe to the initialize() method
@@ -639,16 +640,6 @@
             log.error( "JSPWiki could not start, URLConstructor was not found, stacktrace follows: ", e );
             throw new WikiException( e.getMessage(), e );
         }
-        catch (InstantiationException e)
-        {
-            log.error( "JSPWiki could not start, URLConstructor could not be instantiated, stacktrace follows: ", e );
-            throw new WikiException( e.getMessage(), e );
-        }
-        catch (IllegalAccessException e)
-        {
-            log.error( "JSPWiki could not start, URLConstructor cannot be accessed, stacktrace follows: ", e );
-            throw new WikiException( e.getMessage(), e );
-        }
         catch( Exception e )
         {
             // Final catch-all for everything
@@ -2299,7 +2290,7 @@
      * @since 2.2.6
      * @return the URL constructor
      */
-    public URLConstructor getURLConstructor()
+    public StripesURLConstructor getURLConstructor()
     {
         return m_urlConstructor;
     }

Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java?rev=910061&r1=910060&r2=910061&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/url/StripesURLConstructor.java Sun Feb 14 18:39:46 2010
@@ -34,15 +34,15 @@
 import net.sourceforge.stripes.util.bean.ParseException;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
-import org.apache.wiki.action.GroupActionBean;
+import org.apache.wiki.action.AbstractPageActionBean;
 import org.apache.wiki.action.AttachmentActionBean;
-import org.apache.wiki.action.WikiActionBean;
+import org.apache.wiki.action.GroupActionBean;
 import org.apache.wiki.log.Logger;
 import org.apache.wiki.log.LoggerFactory;
 import org.apache.wiki.ui.stripes.HandlerInfo;
-import org.apache.wiki.ui.stripes.WikiRuntimeConfiguration;
 
 
 /**
@@ -65,13 +65,10 @@
      */
     private String m_pathPrefix;
 
-    /**
-     * Keeps references to Stripes UrlBindingFactory; lazily initialized.
-     */
-    private UrlBindingFactory m_urlBindingFactory = null;
-    
     private WikiEngine m_engine;
 
+    private UrlBindingFactory m_urlBindingFactory = null;
+    
     /**
      * Contains the base URL of the JSPWiki Web application before the
      * servlet context, with trailing slash removed.
@@ -97,15 +94,10 @@
     @Override
     public String makeURL( String context, String name, boolean absolute, String parameters )
     {
-        // Lazily initialize the binding factory
+        // Lazily obtain the binding factory reference
         if ( m_urlBindingFactory == null )
         {
             m_urlBindingFactory = getUrlBindingFactory();
-            if ( m_urlBindingFactory == null )
-            {
-                // If no UrlBindingFactory, bail
-                throw new RuntimeException( "Could not retrieve the Stripes UrlBindingFactory!" );
-            }
         }
         
         // Get the path prefix
@@ -128,7 +120,7 @@
         else
         {
             HandlerInfo handler = m_engine.getWikiContextFactory().findEventHandler( context );
-            Class<? extends WikiActionBean> beanClass = handler.getActionBeanClass();
+            Class<? extends ActionBean> beanClass = handler.getActionBeanClass();
             UrlBinding mapping = m_urlBindingFactory.getBindingPrototype(beanClass);
             baseUrl = mapping == null ? null : mapping.getPath();
             urlBuilder = new UrlBuilder( null, baseUrl, false );
@@ -149,7 +141,7 @@
                         urlBuilder.addParameter( "attachment", name.substring( slashAt + 1,  name.length() ) );
                     }
                 }
-                else if( WikiContext.class.isAssignableFrom( beanClass ) )
+                else if( AbstractPageActionBean.class.isAssignableFrom( beanClass ) )
                 {
                     urlBuilder.addParameter( "page", name );
                 }
@@ -224,16 +216,19 @@
     private UrlBindingFactory getUrlBindingFactory()
     {
         // Load the Stripes UrlBindingFactory
-        Configuration stripesConfig = WikiRuntimeConfiguration.getConfiguration( m_engine.getServletContext() );
-        if( stripesConfig != null )
+        Configuration stripesConfig;
+        stripesConfig = StripesFilter.getConfiguration();
+        if ( stripesConfig == null )
         {
-            ActionResolver resolver = stripesConfig.getActionResolver();
-            if( resolver instanceof AnnotatedClassActionResolver )
-            {
-                return ((AnnotatedClassActionResolver) resolver).getUrlBindingFactory();
-            }
+            throw new InternalWikiException( "No Stripes configuration found!" );
         }
-        return null;
+            
+        ActionResolver resolver = stripesConfig.getActionResolver();
+        if( resolver instanceof AnnotatedClassActionResolver )
+        {
+            return ((AnnotatedClassActionResolver) resolver).getUrlBindingFactory();
+        }
+        throw new InternalWikiException( "Stripes ActionResolver did not have an URLBindingFactory!" );
     }
 
     /**
@@ -327,5 +322,4 @@
             }
         };
     }
-
 }

Modified: incubator/jspwiki/trunk/tests/etc/jspwiki.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/jspwiki.properties?rev=910061&r1=910060&r2=910061&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/jspwiki.properties (original)
+++ incubator/jspwiki/trunk/tests/etc/jspwiki.properties Sun Feb 14 18:39:46 2010
@@ -123,9 +123,6 @@
 jspwiki.approver.workflow.foo=janne
 jspwiki.approver.workflow.bar=Admin
 
-# URL Constructor
-jspwiki.urlConstructor = StripesURLConstructor
-
 # Keychain and admin password
 admin.passwordHash={SSHA}JtQ3xFdBNDuYw5R8u8nhsg5xqsUpbiZhvOoisQ==
 jspwiki.keychainPassword=Ga5ZrVe859WUPqG8

Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java?rev=910061&r1=910060&r2=910061&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java Sun Feb 14 18:39:46 2010
@@ -32,7 +32,6 @@
 import junit.framework.TestSuite;
 
 import org.apache.wiki.*;
-import org.apache.wiki.api.WikiException;
 import org.apache.wiki.api.WikiPage;
 import org.apache.wiki.content.WikiPath;
 import org.apache.wiki.providers.ProviderException;