Return-Path: Delivered-To: apmail-incubator-jspwiki-commits-archive@locus.apache.org Received: (qmail 46559 invoked from network); 12 Oct 2008 04:46:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Oct 2008 04:46:43 -0000 Received: (qmail 28008 invoked by uid 500); 12 Oct 2008 04:46:43 -0000 Delivered-To: apmail-incubator-jspwiki-commits-archive@incubator.apache.org Received: (qmail 27992 invoked by uid 500); 12 Oct 2008 04:46:43 -0000 Mailing-List: contact jspwiki-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jspwiki-dev@incubator.apache.org Delivered-To: mailing list jspwiki-commits@incubator.apache.org Received: (qmail 27983 invoked by uid 99); 12 Oct 2008 04:46:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Oct 2008 21:46:43 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Oct 2008 04:45:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 86A03238895D; Sat, 11 Oct 2008 21:45:52 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r703762 - in /incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH: ./ src/com/ecyrd/jspwiki/action/ tests/com/ecyrd/jspwiki/ui/stripes/ Date: Sun, 12 Oct 2008 04:45:51 -0000 To: jspwiki-commits@incubator.apache.org From: ajaquith@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081012044552.86A03238895D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ajaquith Date: Sat Oct 11 21:45:51 2008 New Revision: 703762 URL: http://svn.apache.org/viewvc?rev=703762&view=rev Log: Added Stripes SiteStructure feature to Ant script 'migrate' target. Also, added ability to migrate nested fmt:message tags to StripesJspTransformer. Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/build.xml incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiActionBeanFactory.java incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspMigrator.java incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspTransformer.java incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/StripesJspTransformer.java incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/StripesJspTransformerTest.java Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/build.xml URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/build.xml?rev=703762&r1=703761&r2=703762&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/build.xml (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/build.xml Sat Oct 11 21:45:51 2008 @@ -286,6 +286,19 @@ + + + + + + + + + + + + + Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java?rev=703762&r1=703761&r2=703762&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/UserProfileActionBean.java Sat Oct 11 21:45:51 2008 @@ -125,7 +125,7 @@ return new RedirectResolution( builder.toString() ); } - // Otherwise, return user to source page + // Otherwise, send user to source page UrlBuilder builder = new UrlBuilder( this.getContext().getLocale(), context.getSourcePage(), false ); builder.addParameter( "tab", "profile" ); return new RedirectResolution( builder.toString() ); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiActionBeanFactory.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiActionBeanFactory.java?rev=703762&r1=703761&r2=703762&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiActionBeanFactory.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/action/WikiActionBeanFactory.java Sat Oct 11 21:45:51 2008 @@ -66,13 +66,13 @@ private static final String PROP_SPECIALPAGE = "jspwiki.specialPage."; /** Default list of packages to search for WikiActionBean implementations. */ - private static final String DEFAULT_ACTIONBEAN_PACKAGES = "com.ecyrd.jspwiki.action"; + public static final String DEFAULT_ACTIONBEAN_PACKAGES = "com.ecyrd.jspwiki.action"; /** * Property in jspwiki.properties that specifies packages to search for * WikiActionBean implementations. */ - private static final String PROPS_ACTIONBEAN_PACKAGES = "jspwiki.actionBean.packages"; + public static final String PROPS_ACTIONBEAN_PACKAGES = "jspwiki.actionBean.packages"; /** Private map with JSPs as keys, Resolutions as values */ private final Map m_specialRedirects; Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java?rev=703762&r1=703761&r2=703762&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JSPWikiJspTransformer.java Sat Oct 11 21:45:51 2008 @@ -11,8 +11,9 @@ /** * {@inheritDoc} */ - public void initialize( Map sharedState, JspDocument doc ) + public void initialize( Map sharedState ) { + System.out.println( "Initialized JSPWikiJspTransformer." ); } /** Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspMigrator.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspMigrator.java?rev=703762&r1=703761&r2=703762&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspMigrator.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspMigrator.java Sat Oct 11 21:45:51 2008 @@ -152,6 +152,12 @@ { // Clear the shared state m_sharedState.clear(); + + // Initialize the transformers + for ( JspTransformer transformer: m_transformers ) + { + transformer.initialize( m_sharedState ); + } // Find the files we need to migrate String sourcePath = sourceDir.getPath(); Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspTransformer.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspTransformer.java?rev=703762&r1=703761&r2=703762&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspTransformer.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/JspTransformer.java Sat Oct 11 21:45:51 2008 @@ -14,9 +14,8 @@ * @param sharedState a map containing key/value pairs that represent any * shared-state information that this method might need during * transformation. - * @param doc the JSP to transform */ - public void initialize( Map sharedState, JspDocument doc ); + public void initialize( Map sharedState ); /** * Executes the transformation on the JSP and returns the result. This Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/StripesJspTransformer.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/StripesJspTransformer.java?rev=703762&r1=703761&r2=703762&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/StripesJspTransformer.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/StripesJspTransformer.java Sat Oct 11 21:45:51 2008 @@ -1,18 +1,97 @@ package com.ecyrd.jspwiki.ui.stripes; -import java.util.List; -import java.util.Map; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Field; +import java.util.*; + +import net.sourceforge.stripes.action.ActionBean; +import net.sourceforge.stripes.action.UrlBinding; +import net.sourceforge.stripes.util.ResolverUtil; + +import com.ecyrd.jspwiki.action.WikiActionBeanFactory; /** * Transforms a JspDocument from standard JSP markup to Stripes markup. */ public class StripesJspTransformer extends AbstractJspTransformer { + private Map, Set> beanProperties = new HashMap, Set>(); + + private Map> beanBindings = new HashMap>(); + /** * {@inheritDoc} */ - public void initialize( Map sharedState, JspDocument doc ) + public void initialize( Map sharedState ) + { + // Find all ActionBean implementations on the classpath + String beanPackagesProp = System.getProperty( WikiActionBeanFactory.PROPS_ACTIONBEAN_PACKAGES, + WikiActionBeanFactory.DEFAULT_ACTIONBEAN_PACKAGES ).trim(); + String[] beanPackages = beanPackagesProp.split( "," ); + ResolverUtil resolver = new ResolverUtil(); + resolver.findImplementations( ActionBean.class, beanPackages ); + Set> beanClasses = resolver.getClasses(); + + // Fetch the URL bindings + initUrlBindingCache( beanClasses ); + + // Initialize properties that "should" bind to each class + initActionBeanPropertyCache( beanClasses ); + + System.out.println( "Initialized StripesJspTransformer." ); + } + + private void initUrlBindingCache( Set> beanClasses ) { + for( Class beanClass : beanClasses ) + { + UrlBinding binding = beanClass.getAnnotation( UrlBinding.class ); + if( binding != null && binding.value() != null ) + { + beanBindings.put( binding.value(), beanClass ); + } + } + } + + private void initActionBeanPropertyCache( Set> beanClasses ) + { + for( Class beanClass : beanClasses ) + { + PropertyDescriptor[] pds; + Set properties = new HashSet(); + try + { + pds = Introspector.getBeanInfo( beanClass ).getPropertyDescriptors(); + for( PropertyDescriptor pd : pds ) + { + String propertyName = pd.getName(); + boolean hasSetter = pd.getWriteMethod() != null; + boolean hasField = false; + try + { + Field field = beanClass.getDeclaredField( propertyName ); + hasField = (field != null); + } + catch( NoSuchFieldException e ) + { + } + if( hasSetter || hasField ) + { + properties.add( propertyName ); + } + } + if( properties.size() > 0 ) + { + beanProperties.put( beanClass, properties ); + } + } + catch( IntrospectionException e ) + { + e.printStackTrace(); + } + } } /** @@ -48,8 +127,8 @@ { migrated = migrateTextArea( tag ) || migrated; } - - else if ( "label".equals( tag.getName() ) ) + + else if( "label".equals( tag.getName() ) ) { migrated = migrateLabel( tag ) || migrated; } @@ -101,8 +180,8 @@ * element whose key attribute contains a value, that value * will become the name attribute of the * stripes:labelelement. - *
  • In all other cases, the label element is simply re-named to - * stripes:label.
  • + *
  • In all other cases, the label element is simply + * re-named to stripes:label.
  • * *

    * For example, the ordinary HTML tag <label @@ -119,42 +198,70 @@ { // Change the name to tag.setName( "stripes:label" ); - + + // If child fmt:message, pull into element + migrateMessageTag( tag ); + message( tag, "Changed