struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddew...@apache.org
Subject svn commit: r470515 - in /struts/sandbox/trunk/tiles/tiles-core/src/main: java/org/apache/tiles/definition/ java/org/apache/tiles/impl/ java/org/apache/tiles/preparer/ java/org/apache/tiles/taglib/ java/org/apache/tiles/util/ resources/META-INF/
Date Thu, 02 Nov 2006 20:48:53 GMT
Author: ddewolf
Date: Thu Nov  2 12:48:52 2006
New Revision: 470515

URL: http://svn.apache.org/viewvc?view=rev&rev=470515
Log:
SB-61, SB-64; Removing preparerName and preparerType.  Standardizing on Preparer

Modified:
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtil.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtilImpl.java
    struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java
Thu Nov  2 12:48:52 2006
@@ -22,10 +22,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.tiles.definition.ComponentAttribute;
-import org.apache.tiles.preparer.UrlViewPreparer;
-import org.apache.tiles.preparer.ViewPreparer;
-import org.apache.tiles.util.RequestUtils;
 
 import java.io.Serializable;
 import java.util.HashMap;
@@ -74,38 +70,11 @@
     protected String preparer = null;
 
     /**
-     * Associated ViewPreparer typename, if preparerName defined.
-     * Can be PREPARER, ACTION or URL, or null.
-     */
-    protected String preparerType = null;
-
-    /**
      * Used for resolving inheritance.
      */
     private boolean isVisited = false;
 
     /**
-     * ViewPreparer name type.
-     */
-    public static final String URL = "url";
-
-    /**
-     * ViewPreparer name type.
-     */
-    public static final String PREPARER = "preparer";
-
-    /**
-     * ViewPreparer name type.
-     */
-    public static final String ACTION = "action";
-
-    /**
-     * ViewPreparer associated to Definition.
-     * Lazy creation : only on first request
-     */
-    private ViewPreparer preparerInstance = null;
-
-    /**
      * Constructor.
      */
     public ComponentDefinition() {
@@ -123,9 +92,7 @@
         this.name = definition.getName();
         this.path = definition.getPath();
         this.role = definition.getRole();
-        this.preparerInstance = definition.getPreparerInstance();
         this.preparer = definition.getPreparer();
-        this.preparerType = definition.getPreparerType();
     }
 
     /**
@@ -332,74 +299,22 @@
             + path
             + ", role="
             + role
-            + ", preparer="
-            + preparer
-            + ", preparerType="
-            + preparerType
             + ", preparerInstance="
-            + preparerInstance
+            + preparer
             + ", attributes="
             + attributes
             + "}\n";
     }
 
     /**
-     * Get associated preparer type.
-     * Type denote a fully qualified classname.
-     */
-    public String getPreparerType() {
-        return preparerType;
-    }
-
-    /**
-     * Set associated preparer type.
-     * Type denote a fully qualified classname.
-     *
-     * @param preparerType Typeof associated preparer
-     */
-    public void setPreparerType(String preparerType) {
-        this.preparerType = preparerType;
-    }
-
-    /**
-     * Set associated preparer name as an url, and preparer
-     * type as "url".
-     * Name must be an url (not checked).
-     * Convenience method.
-     *
-     * @param preparer ViewPreparer url
-     */
-    public void setPreparerUrl(String preparer) {
-        setPreparer(preparer);
-        setPreparerType("url");
-    }
-
-    /**
-     * Set associated preparer name as a classtype, and preparer
-     * type as "classname".
-     * Name denote a fully qualified classname
-     * Convenience method.
-     *
-     * @param preparer ViewPreparer classname.
-     */
-    public void setPreparerClass(String preparer) {
-        setPreparer(preparer);
-        setPreparerType("classname");
-    }
-
-    /**
-     * Get associated preparer local URL.
-     * URL should be local to webcontainer in order to allow request context followup.
-     * URL comes as a string.
+     * Get associated preparerInstance
      */
     public String getPreparer() {
         return preparer;
     }
 
     /**
-     * Set associated preparer URL.
-     * URL should be local to webcontainer in order to allow request context followup.
-     * URL is specified as a string.
+     * Set associated preparerInstance URL.
      *
      * @param url Url called locally
      */
@@ -408,134 +323,6 @@
     }
 
     /**
-     * Get preparer instance.
-     *
-     * @return preparer instance.
-     */
-    public ViewPreparer getPreparerInstance() {
-        return preparerInstance;
-    }
-
-    /**
-     * Get or create preparer.
-     * Get preparer, create it if necessary.
-     *
-     * @return preparer if preparer or preparerType is set, null otherwise.
-     * @throws InstantiationException if an error occur while instanciating ViewPreparer
:
-     *                                (classname can't be instanciated, Illegal access with
instanciated class,
-     *                                Error while instanciating class, classname can't be
instanciated.
-     */
-    public ViewPreparer getOrCreatePreparer() throws InstantiationException {
-
-        if (preparerInstance != null) {
-            return preparerInstance;
-        }
-
-        // Do we define a preparer ?
-        if (preparer == null && preparerType == null) {
-            return null;
-        }
-
-        // check parameters
-        if (preparerType != null && preparer == null) {
-            throw new InstantiationException("ViewPreparer name should be defined if preparerType
is set");
-        }
-
-        preparerInstance = createPreparer(preparer, preparerType);
-
-        return preparerInstance;
-    }
-
-    /**
-     * Set preparer.
-     */
-    public void setPreparerInstance(ViewPreparer preparer) {
-        this.preparerInstance = preparer;
-    }
-
-    /**
-     * Create a new instance of preparer named in parameter.
-     * If preparerType is specified, create preparer accordingly.
-     * Otherwise, if name denote a classname, create an instance of it. If class is
-     * subclass of org.apache.struts.action.Action, wrap preparer
-     * appropriately.
-     * Otherwise, consider name as an url.
-     *
-     * @param name         ViewPreparer name (classname, url, ...)
-     * @param preparerType Expected ViewPreparer type
-     * @return org.apache.struts.tiles.ViewPreparer
-     * @throws InstantiationException if an error occur while instanciating ViewPreparer
:
-     *                                (classname can't be instanciated, Illegal access with
instanciated class,
-     *                                Error while instanciating class, classname can't be
instanciated.
-     */
-    public static ViewPreparer createPreparer(String name, String preparerType)
-        throws InstantiationException {
-
-        if (log.isDebugEnabled()) {
-            log.debug("Create preparer name=" + name + ", type=" + preparerType);
-        }
-
-        ViewPreparer preparer = null;
-
-        if (preparerType == null) { // first try as a classname
-            try {
-                return createPreparerFromClassname(name);
-
-            } catch (InstantiationException ex) { // ok, try something else
-                preparer = new UrlViewPreparer(name);
-            }
-
-        } else if ("url".equalsIgnoreCase(preparerType)) {
-            preparer = new UrlViewPreparer(name);
-
-        } else if ("classname".equalsIgnoreCase(preparerType)) {
-            preparer = createPreparerFromClassname(name);
-        }
-
-        return preparer;
-    }
-
-    /**
-     * Create a preparer from specified classname
-     *
-     * @param classname ViewPreparer classname.
-     * @return org.apache.struts.tiles.ViewPreparer
-     * @throws InstantiationException if an error occur while instanciating ViewPreparer
:
-     *                                (classname can't be instanciated, Illegal access with
instanciated class,
-     *                                Error while instanciating class, classname can't be
instanciated.
-     */
-    public static ViewPreparer createPreparerFromClassname(String classname)
-        throws InstantiationException {
-
-        try {
-            Class requestedClass = RequestUtils.applicationClass(classname);
-            Object instance = requestedClass.newInstance();
-
-            if (log.isDebugEnabled()) {
-                log.debug("ViewPreparer created : " + instance);
-            }
-            return (ViewPreparer) instance;
-
-        } catch (java.lang.ClassNotFoundException ex) {
-            throw new InstantiationException(
-                "Error - Class not found :" + ex.getMessage());
-
-        } catch (java.lang.IllegalAccessException ex) {
-            throw new InstantiationException(
-                "Error - Illegal class access :" + ex.getMessage());
-
-        } catch (java.lang.InstantiationException ex) {
-            throw ex;
-
-        } catch (java.lang.ClassCastException ex) {
-            throw new InstantiationException(
-                "ViewPreparer of class '"
-                    + classname
-                    + "' should implements 'ViewPreparer' or extends 'Action'");
-        }
-    }
-
-    /**
      * Add an attribute to this component.
      * <p/>
      * This method is used by Digester to load definitions.
@@ -610,7 +397,6 @@
         }
         if (child.getPreparer() != null) {
             preparer = child.getPreparer();
-            preparerType = child.getPreparerType();
         }
         // put all child attributes in parent.
         attributes.putAll(child.getAttributes());

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
Thu Nov  2 12:48:52 2006
@@ -367,7 +367,6 @@
             child.setRole(parent.getRole());
         if (child.getPreparer() == null) {
             child.setPreparer(parent.getPreparer());
-            child.setPreparerType(parent.getPreparerType());
         }
     }
 }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
Thu Nov  2 12:48:52 2006
@@ -32,7 +32,6 @@
 import org.apache.tiles.preparer.ViewPreparer;
 
 import javax.servlet.jsp.PageContext;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -170,17 +169,17 @@
     /**
      * Standard Getter
      *
-     * @return return the preparer factory used by this container.
+     * @return return the preparerInstance factory used by this container.
      */
     public PreparerFactory getPreparerFactory() {
         return preparerFactory;
     }
 
     /**
-     * Set the preparer factory.  This method first ensures
+     * Set the preparerInstance factory.  This method first ensures
      * that the container has not yet been initialized.
      *
-     * @param preparerFactory the preparer factory for this conainer.
+     * @param preparerFactory the preparerInstance factory for this conainer.
      */
     public void setPreparerFactory(PreparerFactory preparerFactory) {
         this.preparerFactory = preparerFactory;
@@ -209,7 +208,7 @@
         ViewPreparer preparer = preparerFactory.getPreparer(preparerName, null);
         ComponentContext componentContext = ComponentContext.getContext(context);
 
-        // TODO: Temporary while preparer gets refactored to throw a more specific exception.
+        // TODO: Temporary while preparerInstance gets refactored to throw a more specific
exception.
         try {
             preparer.execute(context, componentContext);
         } catch (Exception e) {
@@ -259,13 +258,7 @@
         ComponentContext.setContext(subContext, request);
 
         try {
-            ViewPreparer preparer = definition.getOrCreatePreparer();
-            if (preparer != null) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Executing tiles preparer [" + preparer + "]");
-                }
-                preparer.execute(request, subContext);
-            }
+            prepare(request, definition.getPreparer());
 
             String dispatchPath = definition.getPath();
             request.dispatch(dispatchPath);
@@ -273,7 +266,7 @@
         } catch (TilesException e) {
             throw e;
         } catch (Exception e) {
-            // TODO it would be nice to make the preparer throw a more specific
+            // TODO it would be nice to make the preparerInstance throw a more specific
             // tiles exception so that it doesn't need to be rethrown.
             throw new TilesException(e.getMessage(), e);
         } finally {

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/BasicPreparerFactory.java
Thu Nov  2 12:48:52 2006
@@ -30,7 +30,7 @@
 /**
  * Default implementation of the {@link PreparerFactory}.
  * This factory provides no contextual configuration.  It
- * simply instantiates the named preparer and returns it.
+ * simply instantiates the named preparerInstance and returns it.
  */
 public class BasicPreparerFactory implements PreparerFactory {
 
@@ -45,10 +45,10 @@
 
 
     /**
-     * Create a new instance of the named preparer.  This factory
+     * Create a new instance of the named preparerInstance.  This factory
      * expects all names to be qualified class names.
      *
-     * @param name    the named preparer
+     * @param name    the named preparerInstance
      * @param context
      * @return
      * @throws NoSuchPreparerException

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/NoSuchPreparerException.java
Thu Nov  2 12:48:52 2006
@@ -20,7 +20,7 @@
 package org.apache.tiles.preparer;
 
 /**
- * Thrown when the named preparer can not be found.
+ * Thrown when the named preparerInstance can not be found.
  *
  * @version $Id$
  * @since 2.0

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/PreparerFactory.java
Thu Nov  2 12:48:52 2006
@@ -39,9 +39,9 @@
      * Create the named {link ViewPreparer} for the specified context.
      *
      * @param name    ViewPreparer name, commonly the qualified classname.
-     * @param context the context within which the preparer will be invoked.
+     * @param context the context within which the preparerInstance will be invoked.
      * @return instance of the ViewPreparer
-     * @throws NoSuchPreparerException when the named preparer can not be found.
+     * @throws NoSuchPreparerException when the named preparerInstance can not be found.
      */
     ViewPreparer getPreparer(String name, TilesRequestContext context)
         throws NoSuchPreparerException;

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/UrlViewPreparer.java
Thu Nov  2 12:48:52 2006
@@ -23,12 +23,12 @@
 import org.apache.tiles.TilesRequestContext;
 
 /**
- * Tiles preparer including a local URL.
+ * Tiles preparerInstance including a local URL.
  */
 public class UrlViewPreparer implements ViewPreparer {
 
     /**
-     * URL associated with this preparer.
+     * URL associated with this preparerInstance.
      */
     protected String url = null;
 

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparer.java
Thu Nov  2 12:48:52 2006
@@ -23,8 +23,8 @@
 import org.apache.tiles.TilesRequestContext;
 
 /**
- * A preparer is a piece of code called before rendering a jsp page.
- * A preparer can be associated to a tile. See &lt;insert&gt; or
+ * A preparerInstance is a piece of code called before rendering a jsp page.
+ * A preparerInstance can be associated to a tile. See &lt;insert&gt; or
  * &lt;definition&gt; for association syntax.
  */
 public interface ViewPreparer {

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/preparer/ViewPreparerSupport.java
Thu Nov  2 12:48:52 2006
@@ -30,7 +30,7 @@
 public class ViewPreparerSupport implements ViewPreparer {
 
     /**
-     * Stubs out preparer method.
+     * Stubs out preparerInstance method.
      */
     public void execute(TilesRequestContext tilesContext,
                         ComponentContext componentContext) throws Exception {

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/AttributeTag.java
Thu Nov  2 12:48:52 2006
@@ -146,7 +146,7 @@
             return processDefinition((ComponentDefinition) value.getValue());
         } else {
             return new InsertHandler((String) value.getValue(), role,
-                getPreparer());
+                getPreparerInstance());
         }
     }
 

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/BaseInsertTag.java
Thu Nov  2 12:48:52 2006
@@ -27,6 +27,8 @@
 import org.apache.tiles.TilesRequestContext;
 import org.apache.tiles.definition.ComponentDefinition;
 import org.apache.tiles.preparer.ViewPreparer;
+import org.apache.tiles.preparer.NoSuchPreparerException;
+import org.apache.tiles.preparer.PreparerFactory;
 import org.apache.tiles.taglib.util.TagUtils;
 import org.apache.tiles.util.TilesUtil;
 
@@ -253,22 +255,21 @@
     }
 
     /**
-     * Get instantiated ViewPreparer. Return preparer denoted by preparerType,
+     * Get instantiated ViewPreparer. Return preparerInstance denoted by preparerType,
      * or <code>null</code> if preparerType is null.
      *
-     * @throws JspException If preparer can't be created.
+     * @throws JspException If preparerInstance can't be created.
      */
-    protected ViewPreparer getPreparer() throws JspException {
-        if (preparerType == null) {
+    protected ViewPreparer getPreparerInstance() throws JspException {
+        if (preparer == null) {
             return null;
         }
 
         try {
-            return ComponentDefinition.createPreparer(preparerName,
-                preparerType);
-
-        } catch (InstantiationException ex) {
-            throw new JspException(ex);
+            PreparerFactory f = TilesUtil.getPreparerFactory();
+            return f.getPreparer(preparer, null);
+        } catch (NoSuchPreparerException e) {
+            throw new JspException(e);
         }
     }
 
@@ -343,17 +344,16 @@
      * @param definition Definition to process.
      * @return Appropriate TagHandler.
      * @throws JspException InstantiationException Can't create requested
-     *                      preparer
+     *                      preparerInstance
      */
     protected TagHandler processDefinition(ComponentDefinition definition)
         throws JspException {
         // Declare local variable in order to not change Tag attribute values.
         String role = this.role;
         String page = this.template;
-        ViewPreparer preparer = null;
+        ViewPreparer viewPreparer = null;
 
         try {
-            preparer = definition.getOrCreatePreparer();
 
             // Overload definition with tag's template and role.
             if (role == null) {
@@ -364,17 +364,16 @@
                 page = definition.getTemplate();
             }
 
-            if (preparerName != null) {
-                preparer = ComponentDefinition.createPreparer(preparerName,
-                    preparerType);
+            if (preparer != null) {
+                viewPreparer = TilesUtil.getPreparerFactory()
+                    .getPreparer(definition.getPreparer(), null);
             }
 
             // Can check if page is set
             return new InsertHandler(definition.getAttributes(), page, role,
-                preparer);
-
-        } catch (InstantiationException ex) {
-            throw new JspException(ex);
+                viewPreparer);
+        } catch (NoSuchPreparerException e) {
+            throw new JspException(e);
         }
     }
 
@@ -449,7 +448,7 @@
 
         protected String role;
 
-        protected ViewPreparer preparer;
+        protected ViewPreparer preparerInstance;
 
         /**
          * Constructor. Create insert handler using Component definition.
@@ -459,7 +458,7 @@
 
             this.page = page;
             this.role = role;
-            this.preparer = preparer;
+            this.preparerInstance = preparer;
             subCompContext = new ComponentContext(attributes);
         }
 
@@ -470,7 +469,7 @@
         public InsertHandler(String page, String role, ViewPreparer preparer) {
             this.page = page;
             this.role = role;
-            this.preparer = preparer;
+            this.preparerInstance = preparer;
             subCompContext = new ComponentContext();
         }
 
@@ -519,12 +518,12 @@
                 pageContext.setAttribute(ComponentConstants.COMPONENT_CONTEXT,
                     subCompContext, PageContext.REQUEST_SCOPE);
 
-                // Call preparer if any
-                if (preparer != null) {
+                // Call preparerInstance if any
+                if (preparerInstance != null) {
                     try {
                         TilesRequestContext tilesContext = TagUtils
                             .getTilesRequestContext(pageContext);
-                        preparer.execute(tilesContext, subCompContext);
+                        preparerInstance.execute(tilesContext, subCompContext);
                     } catch (Exception e) {
                         throw new ServletException(e);
                     }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/DefinitionTagSupport.java
Thu Nov  2 12:48:52 2006
@@ -29,13 +29,9 @@
  */
 public class DefinitionTagSupport extends TagSupport implements Serializable {
     /**
-     * Associated ViewPreparer type
-     */
-    protected String preparerType;
-    /**
      * Associated ViewPreparer name (classname or url)
      */
-    protected String preparerName;
+    protected String preparer;
     /**
      * Role associated to definition.
      */
@@ -51,88 +47,38 @@
      */
     public void release() {
         super.release();
-        preparerType = null;
-        preparerName = null;
+        preparer = null;
         role = null;
     }
 
     /**
-     * Get preparer type.
+     * Get preparerInstance type.
      * Type can be 'classname', 'url'.
      *
      * @return ViewPreparer type.
      */
-    public String getPreparerType() {
-        return preparerType;
-    }
 
     /**
-     * Get preparer name.
+     * Get preparerInstance name.
      * Name denotes a fully qualified classname, or an url.
-     * Exact type can be specified with {@link #setPreparerType}.
+     * Exact type can be specified with {@link #setPreparer}.
      *
      * @return ViewPreparer name.
      */
-    public String getPreparerName() {
-        return preparerName;
+    public String getPreparer() {
+        return preparer;
     }
 
-    /**
-     * Set associated preparer type.
-     * Type denotes a fully qualified classname.
-     *
-     * @param preparerType Type of associated preparer.
-     */
-    public void setPreparerType(String preparerType) {
-        this.preparerType = preparerType;
-    }
 
     /**
-     * Set associated preparer name.
-     * Name denotes a fully qualified classname, or an url.
-     * Exact type can be specified with {@link #setPreparerType}.
-     *
-     * @param preparer ViewPreparer classname or url.
-     */
-    public void setPreparer(String preparer) {
-        setPreparerName(preparer);
-    }
-
-    /**
-     * Set associated preparer name.
+     * Set associated preparerInstance name.
      * Name denote a fully qualified classname, or an url.
      * Exact type can be specified with setPreparerType.
      *
      * @param preparer ViewPreparer classname or url
      */
-    public void setPreparerName(String preparer) {
-        this.preparerName = preparer;
-    }
-
-    /**
-     * Set associated preparer name as an url, and preparer
-     * type as "url".
-     * Name must be an url (not checked).
-     * Convenience method.
-     *
-     * @param preparer ViewPreparer url
-     */
-    public void setPreparerUrl(String preparer) {
-        setPreparerName(preparer);
-        setPreparerType("url");
-    }
-
-    /**
-     * Set associated preparer name as a classtype and preparer
-     * type as "classname".
-     * Name denotes a fully qualified classname.
-     * Convenience method.
-     *
-     * @param preparer ViewPreparer classname.
-     */
-    public void setPreparerClass(String preparer) {
-        setPreparerName(preparer);
-        setPreparerType("classname");
+    public void setPreparer(String preparer) {
+        this.preparer = preparer;
     }
 
     /**

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertDefinitionTag.java
Thu Nov  2 12:48:52 2006
@@ -94,7 +94,7 @@
      * @throws JspException- DefinedComponentFactoryException General error in
      *                       factory.
      * @throws JspException  InstantiationException Can't create requested
-     *                       preparer
+     *                       preparerInstance
      */
     protected TagHandler processDefinitionName(String name) throws JspException {
 

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/taglib/InsertTemplateTag.java
Thu Nov  2 12:48:52 2006
@@ -42,9 +42,9 @@
     /**
      * Process the url.
      *
-     * @throws JspException If failed to create preparer
+     * @throws JspException If failed to create preparerInstance
      */
     protected TagHandler processUrl(String url) throws JspException {
-        return new InsertHandler(url, role, getPreparer());
+        return new InsertHandler(url, role, getPreparerInstance());
     }
 }

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtil.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtil.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtil.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtil.java
Thu Nov  2 12:48:52 2006
@@ -23,7 +23,6 @@
 import org.apache.tiles.TilesApplicationContext;
 import org.apache.tiles.TilesRequestContext;
 import org.apache.tiles.preparer.PreparerFactory;
-import org.apache.tiles.preparer.BasicPreparerFactory;
 import org.apache.tiles.definition.*;
 
 import javax.servlet.jsp.PageContext;
@@ -167,7 +166,7 @@
     }
 
     /**
-     * Get preparer factory
+     * Get preparerInstance factory
      */
     public static PreparerFactory getPreparerFactory() {
         return tilesUtilImpl.getPreparerFactory();

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtilImpl.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtilImpl.java?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtilImpl.java
(original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/util/TilesUtilImpl.java
Thu Nov  2 12:48:52 2006
@@ -172,7 +172,7 @@
     }
 
     /**
-     * Get preparer factory.
+     * Get preparerInstance factory.
      *
      * @return
      * @throws DefinitionsFactoryException

Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld?view=diff&rev=470515&r1=470514&r2=470515
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/resources/META-INF/tiles-core.tld Thu Nov
 2 12:48:52 2006
@@ -92,15 +92,14 @@
          ]]>
          </description>
       </attribute>
+
       <attribute>
-         <name>preparerUrl</name>
-         <required>false</required>
-         <rtexprvalue>true</rtexprvalue>
-      </attribute>
-      <attribute>
-         <name>preparerClass</name>
+         <name>preparer</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
+          <description>
+              The fully qualified class name of the preparer.
+          </description>
       </attribute>
    </tag>
    <tag>
@@ -195,15 +194,14 @@
          ]]>
          </description>
       </attribute>
+
       <attribute>
-         <name>preparerUrl</name>
-         <required>false</required>
-         <rtexprvalue>true</rtexprvalue>
-      </attribute>
-      <attribute>
-         <name>preparerClass</name>
+         <name>preparer</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
+          <description>
+              The fully qualified class name of preparer.
+          </description>
       </attribute>
    </tag>
    <tag>
@@ -295,14 +293,12 @@
          </description>
       </attribute>
       <attribute>
-         <name>preparerUrl</name>
-         <required>false</required>
-         <rtexprvalue>true</rtexprvalue>
-      </attribute>
-      <attribute>
-         <name>preparerClass</name>
+         <name>preparer</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
+          <description>
+              The fully qualified name of the preparer.
+          </description>
       </attribute>
    </tag>
    <tag>



Mime
View raw message