cedric 2002/10/10 09:32:27
Modified: src/share/org/apache/struts/tiles/xmlDefinition
XmlDefinition.java XmlAttribute.java
I18nFactorySet.java
src/share/org/apache/struts/tiles TilesServlet.java
TilesRequestProcessor.java TilesPlugin.java
DefinitionsUtil.java ComponentDefinition.java
src/share/org/apache/struts/taglib/tiles InsertTag.java
DefinitionTag.java
doc/userGuide dev_tiles.xml
src/share/org/apache/struts/tiles/actions
DefinitionDispatcherAction.java
Log:
Switch to use commons-logging package.
This solve "Bugzilla Bug 11757 Tiles code needs to be converted to use Commons
Logging"
Revision Changes Path
1.2 +12 -11
jakarta-struts/src/share/org/apache/struts/tiles/xmlDefinition/XmlDefinition.java
Index: XmlDefinition.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/xmlDefinition/XmlDefinition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XmlDefinition.java 25 Jun 2002 03:15:43 -0000 1.1
+++ XmlDefinition.java 10 Oct 2002 16:32:26 -0000 1.2
@@ -64,6 +64,8 @@
import org.apache.struts.tiles.ComponentDefinition;
import org.apache.struts.tiles.NoSuchDefinitionException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.util.Iterator;
@@ -77,8 +79,8 @@
*/
private String inherit;
- /** Debug flag */
- static public final boolean debug = false;
+ /** Commons Logging instance. */
+ protected static Log log = LogFactory.getLog(XmlDefinition.class);
/**
* Use for resolving inheritance.
@@ -149,7 +151,7 @@
* First, resolve parent's inheritance, then set path to the parent's path.
* Also copy attributes setted in parent, and not set in child
* If instance doesn't extends something, do nothing.
- * @throws NoSuchInstanceException If a inheritance can be solved.
+ * @throws NoSuchDefinitionException If a inheritance can be solved.
*/
public void resolveInheritance( XmlDefinitionsSet definitionsSet )
throws NoSuchDefinitionException
@@ -158,10 +160,9 @@
if( isVisited || !isExtending() )
return;
- if( debug)
- System.out.println( "Resolve definition for child name='"
- + getName() + "' extends='"
- + getExtends() + "'." );
+ if(log.isDebugEnabled())
+ log.debug( "Resolve definition for child name='" + getName()
+ + "' extends='" + getExtends() + "'.");
// Set as visited to avoid endless recurisvity.
setIsVisited( true );
@@ -173,7 +174,7 @@
String msg = "Error while resolving definition inheritance: child '"
+ getName() + "' can't find its ancestor '"
+ getExtends() + "'. Please check your description
file.";
- System.out.println( msg );
+ log.error( msg );
// to do : find better exception
throw new NoSuchDefinitionException( msg );
}
1.2 +3 -6
jakarta-struts/src/share/org/apache/struts/tiles/xmlDefinition/XmlAttribute.java
Index: XmlAttribute.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/xmlDefinition/XmlAttribute.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XmlAttribute.java 25 Jun 2002 03:15:43 -0000 1.1
+++ XmlAttribute.java 10 Oct 2002 16:32:26 -0000 1.2
@@ -62,10 +62,8 @@
package org.apache.struts.tiles.xmlDefinition;
-import org.apache.struts.tiles.AttributeDefinition;
import org.apache.struts.tiles.DirectStringAttribute;
import org.apache.struts.tiles.PathAttribute;
-import org.apache.struts.tiles.DefinitionAttribute;
import org.apache.struts.tiles.DefinitionNameAttribute;
import org.apache.struts.tiles.UntyppedAttribute;
@@ -229,7 +227,6 @@
{
if( body.length() == 0 )
return;
- //System.out.println("body set to'" + body + "'");
setValue(body);
}
/**
1.4 +31 -33
jakarta-struts/src/share/org/apache/struts/tiles/xmlDefinition/I18nFactorySet.java
Index: I18nFactorySet.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/xmlDefinition/I18nFactorySet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- I18nFactorySet.java 11 Jul 2002 16:48:25 -0000 1.3
+++ I18nFactorySet.java 10 Oct 2002 16:32:26 -0000 1.4
@@ -65,6 +65,8 @@
import org.apache.struts.tiles.DefinitionsFactoryException;
import org.apache.struts.tiles.FactoryNotFoundException;
import org.apache.struts.tiles.DefinitionsUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.servlet.ServletRequest;
import javax.servlet.ServletContext;
@@ -98,8 +100,9 @@
*/
public class I18nFactorySet extends FactorySet
{
- /** Debug flag */
- static public final boolean debug = false;
+ /** Commons Logging instance. */
+ protected static Log log = LogFactory.getLog(I18nFactorySet.class);
+
/** Config file parameter name
* @deprecated use DEFINITIONS_CONFIG_PARAMETER_NAME
*/
@@ -195,10 +198,7 @@
}
catch( NumberFormatException ex )
{
- System.out.println( "Bad format for parameter '"
- + PARSER_DETAILS_PARAMETER_NAME
- + "'. Integer expected.");
- servletContext.log( "Tiles factory init : Bad format for parameter '"
+ log.error( "Bad format for parameter '"
+ PARSER_DETAILS_PARAMETER_NAME
+ "'. Integer expected.");
}
@@ -213,12 +213,12 @@
try
{
initFactory( servletContext, filename );
- if( DefinitionsUtil.userDebugLevel > 0)
- System.out.println( "Factory initialized from file '" + filename + "'."
);
+ if(log.isDebugEnabled())
+ log.debug( "Factory initialized from file '" + filename + "'." );
}
catch( FileNotFoundException ex )
{ // A filename is specified, throw appropriate error.
- System.out.println( ex.getMessage() + " : Can't find file '" +filename +
"'" );
+ log.error( ex.getMessage() + " : Can't find file '" +filename + "'" );
throw new FactoryNotFoundException( ex.getMessage() + " : Can't find file
'" +filename + "'" ) ;
} // end catch
}
@@ -230,9 +230,9 @@
try
{
initFactory( servletContext, filename );
- if( DefinitionsUtil.userDebugLevel > 0)
+ if(log.isInfoEnabled())
{
- System.out.println( "Factory initialized from file '" + filename + "'."
);
+ log.info( "Factory initialized from file '" + filename + "'." );
}
}
catch( FileNotFoundException ex )
@@ -265,8 +265,8 @@
loaded = new HashMap();
defaultFactory = createDefaultFactory( servletContext );
- if(debug)
- System.out.println( "default factory:" + defaultFactory );
+ if(log.isDebugEnabled())
+ log.debug( "default factory:" + defaultFactory );
}
/**
@@ -297,12 +297,12 @@
rootXmlConfig.resolveInheritances();
- if(debug)
- System.out.println( rootXmlConfig );
+ if(log.isDebugEnabled())
+ log.debug( rootXmlConfig );
DefinitionsFactory factory = new DefinitionsFactory( rootXmlConfig );
- if( DefinitionsUtil.userDebugLevel > DefinitionsUtil.NO_DEBUG )
- System.out.println( "factory loaded : " + factory );
+ if(log.isInfoEnabled())
+ log.info( "factory loaded : " + factory );
return factory;
}
@@ -325,7 +325,7 @@
}
catch( ClassCastException ex )
{ //
- System.out.println( "Error - I18nFactorySet.getDefinitionsFactoryKey" );
+ log.error( "I18nFactorySet.getDefinitionsFactoryKey" );
ex.printStackTrace();
}
@@ -396,8 +396,8 @@
factory = new DefinitionsFactory(rootXmlConfig);
loaded.put( lastPostfix, factory );
// User help
- if( DefinitionsUtil.userDebugLevel > DefinitionsUtil.NO_DEBUG )
- System.out.println( "factory loaded : " + factory );
+ if(log.isDebugEnabled())
+ log.debug( "factory loaded : " + factory );
// return last available found !
return factory;
}
@@ -408,8 +408,6 @@
* Method copied from java.util.ResourceBundle
* @param baseName the base bundle name
* @param locale the locale
- * @param names the vector used to return the names of the bundles along
- * the search path.
*/
private static List calculatePostixes(String baseName, Locale locale) {
final List result = new ArrayList(MAX_BUNDLES_SEARCHED);
@@ -502,8 +500,8 @@
// If still nothing found, this mean no config file is associated
if(input == null )
{
- //if(debug)
- //System.out.println( "Can't open file '" + filename + "'" );
+ if(log.isDebugEnabled())
+ log.debug( "Can't open file '" + filename + "'" );
return xmlDefinitions;
}
@@ -512,8 +510,8 @@
//if( xmlParser == null )
if( true )
{ // create it
- if(debug)
- System.out.println( "Create xmlParser");
+ //if(log.isDebugEnabled())
+ //log.debug( "Create xmlParser");
xmlParser = new XmlParser();
xmlParser.setValidating(isValidatingParser);
xmlParser.setDetailLevel(parserDetailLevel);
@@ -521,8 +519,8 @@
// Check if definition set already exist.
if( xmlDefinitions == null )
{ // create it
- if(debug)
- System.out.println( "Create xmlDefinitions");
+ //if(log.isDebugEnabled())
+ //log.debug( "Create xmlDefinitions");
xmlDefinitions = new XmlDefinitionsSet();
}
@@ -530,9 +528,9 @@
}
catch( SAXException ex )
{
- if( debug)
+ if(log.isDebugEnabled())
{
- System.out.println( "Error while parsing file '" + filename + "'.");
+ log.debug( "Error while parsing file '" + filename + "'.");
ex.printStackTrace();
}
throw new DefinitionsFactoryException( "Error while parsing file '" +
filename + "'. " + ex.getMessage(), ex );
1.3 +19 -10
jakarta-struts/src/share/org/apache/struts/tiles/TilesServlet.java
Index: TilesServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesServlet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TilesServlet.java 19 Jul 2002 09:40:22 -0000 1.2
+++ TilesServlet.java 10 Oct 2002 16:32:27 -0000 1.3
@@ -64,9 +64,10 @@
import org.apache.struts.tiles.DefinitionsUtil;
import org.apache.struts.tiles.DefinitionsFactoryException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.servlet.ServletException;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;
@@ -80,6 +81,8 @@
public class TilesServlet extends HttpServlet
{
+ /** Commons Logging instance. */
+ protected static Log log = LogFactory.getLog(TilesServlet.class);
/**
* Initialize this servlet
@@ -88,8 +91,8 @@
*/
public void init() throws ServletException
{
- log( "Start Tiles initialization");
- System.out.println( "Start Tiles initialization" );
+ if(log.isInfoEnabled())
+ log.info("Start Tiles initialization");
super.init();
// Create tiles definitions config object
@@ -101,18 +104,24 @@
}
catch(Exception ex)
{
- throw new ServletException( "Can't populate DefinitionsFactoryConfig class from
'web.xml': " + ex.getMessage() );
+ String msg="Can't populate DefinitionsFactoryConfig class from 'web.xml'";
+ if (log.isErrorEnabled())
+ log.error(msg, ex);
+ throw new ServletException( msg + ex.getMessage() );
}
try
{
- System.out.println( "Try to load Tiles factory" );
+ if(log.isInfoEnabled())
+ log.info("Try to load Tiles factory");
DefinitionsUtil.createDefinitionsFactory(getServletContext(), factoryConfig );
- log( "Tiles Factory loaded");
+ if(log.isInfoEnabled())
+ log.info("Tiles Factory successfully loaded");
}
catch( DefinitionsFactoryException ex )
{
- log( "Tiles Factory load fail !", ex);
+ if(log.isErrorEnabled())
+ log.error("Tiles Factory load fail !", ex);
throw new ServletException( ex );
}
1.7 +31 -28
jakarta-struts/src/share/org/apache/struts/tiles/TilesRequestProcessor.java
Index: TilesRequestProcessor.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesRequestProcessor.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TilesRequestProcessor.java 29 Aug 2002 13:24:03 -0000 1.6
+++ TilesRequestProcessor.java 10 Oct 2002 16:32:27 -0000 1.7
@@ -62,27 +62,16 @@
package org.apache.struts.tiles;
-import org.apache.struts.taglib.tiles.ComponentConstants;
-
-import java.util.Locale;
-
import org.apache.struts.action.RequestProcessor;
import org.apache.struts.action.ActionServlet;
-import org.apache.struts.action.ActionForward;
import org.apache.struts.config.ForwardConfig;
-import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.ActionErrors;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.Action;
import org.apache.struts.config.ApplicationConfig;
import javax.servlet.*;
import javax.servlet.http.*;
-import java.io.InputStream;
import java.io.IOException;
-import java.io.FileNotFoundException;
-import org.apache.struts.taglib.html.Constants;
-import org.apache.struts.upload.MultipartRequestWrapper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* <p><strong>RequestProcessor</strong> contains the processing logic that
@@ -98,10 +87,12 @@
*/
public class TilesRequestProcessor extends RequestProcessor
{
- /** Debug flag */
- public static final boolean debug = false;
/** Definitions factory */
private DefinitionsFactory definitionsFactory;
+ /**
+ * Commons Logging instance.
+ */
+ protected static Log log = LogFactory.getLog(RequestProcessor.class);
/**
* Initialize this request processor instance.
@@ -127,12 +118,18 @@
definitionsFactory = DefinitionsUtil.getDefinitionsFactory(getServletContext());
if( definitionsFactory == null )
{ // problem !
- log( "Error - TilesRequestProcessor : Definition Factory not found for subapp
'"
- + appConfig.getPrefix() + "'. "
- + "Do you have declared appropriate plugin in struts-config.xml ?" );
+ if(log.isErrorEnabled())
+ {
+ log.error( "Definition Factory not found for subapp '"
+ + appConfig.getPrefix() + "'. "
+ + "Have you declared the appropriate plugin in struts-config.xml ?"
);
+ }
return;
}
- log( "Tiles definition factory found for request processor '" +
appConfig.getPrefix() + "'.");
+ if(log.isInfoEnabled())
+ {
+ log.info("Tiles definition factory found for request processor '" +
appConfig.getPrefix() + "'.");
+ }
}
@@ -211,6 +208,10 @@
}
catch( java.lang.InstantiationException ex )
{
+ if (log.isErrorEnabled())
+ {
+ log.error("Can't create associated controller", ex);
+ }
throw new ServletException( "Can't create associated controller", ex );
}
catch( DefinitionsFactoryException ex )
@@ -231,6 +232,8 @@
// If request comes from a previous Tile, do an include.
// This allows to insert an action in a Tile.
+ if(log.isDebugEnabled())
+ log.debug( "uri=" + uri + " doInclude=" + doInclude);
if( doInclude )
doInclude(uri, request, response);
else
@@ -282,20 +285,20 @@
return;
}
- if(debug)
- System.out.println( "processActionForward("
+ if(log.isDebugEnabled())
+ log.debug( "processForwardConfig("
+ forward.getPath() + ", "
+ forward.getContextRelative() + ")" );
// Try to process the definition.
if (processTilesDefinition( forward.getPath(), forward.getContextRelative(),
request, response))
{
- if(debug)
- System.out.println( " '" +forward.getPath() + "' - processed as
definition" );
+ if(log.isDebugEnabled())
+ log.debug( " '" +forward.getPath() + "' - processed as definition" );
return;
}
- if(debug)
- System.out.println( " '" +forward.getPath() + "' - processed as uri" );
+ if(log.isDebugEnabled())
+ log.debug( " '" +forward.getPath() + "' - processed as uri" );
// forward doesn't contains a definition, let parent do processing
super.processForwardConfig(request, response, forward );
}
1.4 +26 -17
jakarta-struts/src/share/org/apache/struts/tiles/TilesPlugin.java
Index: TilesPlugin.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesPlugin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TilesPlugin.java 19 Jul 2002 10:03:03 -0000 1.3
+++ TilesPlugin.java 10 Oct 2002 16:32:27 -0000 1.4
@@ -70,7 +70,8 @@
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.RequestProcessor;
-import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.util.Map;
@@ -104,8 +105,8 @@
*/
public class TilesPlugin implements PlugIn {
- /** Debug flag */
- public static final boolean debug = true;
+ /** Commons Logging instance. */
+ protected static Log log = LogFactory.getLog(TilesPlugin.class);
/** Associated definition factory */
protected DefinitionsFactory definitionFactory;
@@ -133,10 +134,9 @@
definitionFactory = DefinitionsUtil.getDefinitionsFactory(
servlet.getServletContext() );
if( definitionFactory != null )
{
- if(debug)
+ if(log.isInfoEnabled())
{
- System.out.println( "Info - TilesPlugin : factory already exists. No new
creation." );
- servlet.log( "Info - TilesPlugin : factory already exists. No new creation."
);
+ log.info("Factory already exists. No new creation." );
}
return;
} // end if
@@ -150,8 +150,12 @@
{
throw new ServletException( ex );
}
+ if(log.isInfoEnabled())
+ {
+ log.info( "Tiles definition factory loaded for processor '" +
config.getPrefix() + "'." );
+ }
- servlet.log( "Tiles definition factory loaded for processor '" +
config.getPrefix() + "'." );
+ //servlet.log( "Tiles definition factory loaded for processor '" +
config.getPrefix() + "'." );
}
/**
@@ -185,8 +189,8 @@
}
catch(Exception ex)
{
- if( debug )
- ex.printStackTrace();
+ if(log.isDebugEnabled())
+ log.debug( "", ex);
throw new UnavailableException( "Can't populate DefinitionsFactoryConfig class
from 'web.xml': " + ex.getMessage() );
}
// Get init parameters from struts-config.xml
@@ -197,8 +201,8 @@
}
catch(Exception ex)
{
- if( debug )
- ex.printStackTrace();
+ if(log.isDebugEnabled())
+ log.debug( "", ex);
throw new UnavailableException( "Can't populate DefinitionsFactoryConfig class
from '"
+ config.getPrefix() + "/struts-config.xml':"
+ ex.getMessage() );
@@ -231,8 +235,10 @@
if( plugIns[index] != this )
{
String msg = "Can't initialize tiles definition factory : plugin configuration
object not found.";
- System.out.println( msg );
- servlet.log( msg );
+ if(log.isFatalEnabled())
+ {
+ log.fatal(msg);
+ }
throw new ServletException( msg );
} // end if
// Get plugin
@@ -272,7 +278,10 @@
if( !tilesProcessorClass.isAssignableFrom( configProcessorClass))
{ // Not compatible
String msg = "TilesPlugin : Specified RequestProcessor not compatible with
TilesRequestProcessor";
- System.out.println( msg );
+ if(log.isFatalEnabled())
+ {
+ log.fatal(msg);
+ }
throw new ServletException( msg );
} // end if
}
1.4 +21 -31
jakarta-struts/src/share/org/apache/struts/tiles/DefinitionsUtil.java
Index: DefinitionsUtil.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/DefinitionsUtil.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefinitionsUtil.java 11 Jul 2002 17:37:01 -0000 1.3
+++ DefinitionsUtil.java 10 Oct 2002 16:32:27 -0000 1.4
@@ -65,22 +65,18 @@
import javax.servlet.jsp.PageContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletRequest;
import java.util.Map;
import java.util.HashMap;
import java.util.Enumeration;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import org.apache.struts.tiles.definition.ReloadableDefinitionsFactory;
import org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper;
-import org.apache.struts.tiles.xmlDefinition.I18nFactorySet;
import org.apache.struts.taglib.tiles.ComponentConstants;
-import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Utilities class for definitions factory.
@@ -89,6 +85,8 @@
*/
public class DefinitionsUtil implements ComponentConstants
{
+ /** Commons Logging instance. */
+ protected static Log log = LogFactory.getLog(DefinitionsUtil.class);
/** Global user defined debug level */
public static int userDebugLevel = 0;
@@ -120,15 +118,10 @@
}
/**
- * Create Definition factory.
- * If
- * Create MapperCollection, and put it in appropriate servlet context.
- * This method is used to initialize Component Instances. It is usually
- * called by the initialization servlet.
- * @param servletContext
- * @return newly created MapperCollection.
- * @throws DefinitionsFactoryException If an error occur while initializing
factory
- * @deprecated Use createDefinitionsFactory instead.
+ * Init user debug level.
+ *
+ * @param servletConfig
+ * @deprecated Use commons-logging package instead.
*/
public static void initUserDebugLevel(ServletConfig servletConfig)
{
@@ -144,12 +137,12 @@
int level = Integer.parseInt( str );
setUserDebugLevel( level );
if( userDebugLevel > 1 )
- System.out.println( "Component Definitions debug level = " +
userDebugLevel );
+ log.debug( "Component Definitions debug level = " + userDebugLevel );
}
}
catch(Exception ex)
{ // silently fail
- System.out.println( "Set user level fail" );
+ log.debug( "Set user level fail" );
ex.printStackTrace();
}
}
@@ -338,7 +331,7 @@
* Get a definition by its name.
* First, retrieve definition factory, and then get requested definition.
* Throw appropriate exception if definition or definition factory is not found.
- * @param name Name of requested definition.
+ * @param definitionName Name of requested definition.
* @param request Current servelet request
* @param servletContext current servlet context
* @throws FactoryNotFoundException Can't find definition factory.
@@ -364,9 +357,8 @@
* Get a component / template definition by its name.
* First, retrieve instance factory, and then get requested instance.
* Throw appropriate exception if definition is not found.
- * @param name Name of requested definition.
- * @param request Current servelet request
- * @param servletContext current servlet context
+ * @param definitionName Name of requested definition.
+ * @param pageContext Current pageContext
* @throws FactoryNotFoundException Can't find definition factory.
* @throws DefinitionsFactoryException General error in factory while getting
definition.
* @throws NoSuchDefinitionException No definition found for specified name
@@ -430,11 +422,11 @@
/**
* Populate Definition Factory Config from web.xml properties.
- * @param config Definition Factory Config to populate.
- * @param servletContext Current servlet context containing web.xml properties.
+ * @param factoryConfig Definition Factory Config to populate.
+ * @param servletConfig Current servlet config containing web.xml properties.
* @exception IllegalAccessException if the caller does not have
* access to the property accessor method
- * @exception InvocationTargetException if the property accessor method
+ * @exception java.lang.reflect.InvocationTargetException if the property
accessor method
* throws an exception
* @see org.apache.commons.beanutils.BeanUtil
* @since tiles 20020708
@@ -449,11 +441,9 @@
/**
* Create FactoryConfig and initialize it from web.xml.
*
- * @param servlet ActionServlet that is managing all the sub-applications
- * in this web application
- * @param config ApplicationConfig for the sub-application with which
+ * @param servletConfig ServletConfig for the sub-application with which
* this plug in is associated
- * @exception ServletException if this <code>PlugIn</code> cannot
+ * @exception DefinitionsFactoryException if this <code>PlugIn</code> cannot
* be successfully initialized
*/
static protected DefinitionsFactoryConfig readFactoryConfig(ServletConfig
servletConfig)
1.2 +16 -23
jakarta-struts/src/share/org/apache/struts/tiles/ComponentDefinition.java
Index: ComponentDefinition.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/ComponentDefinition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ComponentDefinition.java 25 Jun 2002 03:14:49 -0000 1.1
+++ ComponentDefinition.java 10 Oct 2002 16:32:27 -0000 1.2
@@ -63,13 +63,13 @@
package org.apache.struts.tiles;
import org.apache.struts.tiles.Controller;
-import org.apache.struts.action.Action;
import java.util.Map;
import java.util.HashMap;
-import java.util.Iterator;
import java.io.Serializable;
-import org.apache.struts.taglib.tiles.DefinitionTagSupport;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Definition of a template / component attributes.
@@ -78,8 +78,8 @@
*/
public class ComponentDefinition implements Serializable
{
- /** Debug flag */
- public static final boolean debug = false;
+ /** Commons Logging instance. */
+ protected static Log log = LogFactory.getLog(ComponentDefinition.class);
/**
* Definition name
@@ -118,7 +118,6 @@
private Controller controllerInstance;
/**
- * @return void
* Sets the value of the attributes property.
*
* @param aAttributes the new value of the attributes property
@@ -193,7 +192,6 @@
return name;}
/**
- * @return void
* Sets the value of the name property.
*
* @param aName the new value of the name property
@@ -215,7 +213,6 @@
* Sets the value of the path property.
*
* @param aPath the new value of the path property
- * @return void
*/
public void setPage(String page)
{
@@ -233,7 +230,6 @@
}
/**
- * @return void
* Sets the value of the path property.
*
* @param aPath the new value of the path property
@@ -254,7 +250,6 @@
}
/**
- * @return void
* Sets the value of the template property.
* Same as setPath()
*
@@ -267,7 +262,7 @@
/**
* Access method for the role property.
- * @return the current value of the template property
+ * @return the current value of the role property
*/
public String getRole()
{
@@ -275,10 +270,9 @@
}
/**
- * @return void
* Sets the value of the role property.
*
- * @param template the new value of the path property
+ * @param role the new value of the path property
*/
public void setRole(String role)
{
@@ -478,9 +472,9 @@
* URL is specified as a string.
* @param url Url called locally
*/
- public void setController(String name)
+ public void setController(String url)
{
- this.controller = name;
+ this.controller = url;
}
/**
@@ -544,8 +538,8 @@
static public Controller createController(String name, String controllerType)
throws InstantiationException
{
- if(debug)
- System.out.println( "Create controller name="+ name+", type=" + controllerType
);
+ if(log.isDebugEnabled())
+ log.debug( "Create controller name="+ name+", type=" + controllerType );
Controller controller = null;
if( controllerType == null )
@@ -570,7 +564,6 @@
/**
* Create a controller from specified classname
* @param classname Controller classname.
- * @param controllerType Expected Controller type
* @return org.apache.struts.tiles.Controller
* @throws InstantiationException if an error occur while instanciating
Controller :
* (classname can't be instanciated, Illegal access with instanciated class,
@@ -589,8 +582,8 @@
instance = new ActionController( (Action)instance );
} // end if
*/
- if(debug)
- System.out.println( "Controller created : " + instance );
+ if(log.isDebugEnabled())
+ log.debug( "Controller created : " + instance );
return (Controller)instance;
}
catch( java.lang.ClassNotFoundException ex)
1.4 +15 -15
jakarta-struts/src/share/org/apache/struts/taglib/tiles/InsertTag.java
Index: InsertTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/tiles/InsertTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InsertTag.java 15 Aug 2002 09:35:56 -0000 1.3
+++ InsertTag.java 10 Oct 2002 16:32:27 -0000 1.4
@@ -72,19 +72,19 @@
import org.apache.struts.tiles.AttributeDefinition;
import org.apache.struts.tiles.DirectStringAttribute;
-import org.apache.struts.tiles.PathAttribute;
import org.apache.struts.tiles.DefinitionAttribute;
import org.apache.struts.tiles.DefinitionNameAttribute;
import org.apache.struts.taglib.tiles.util.TagUtils;
import org.apache.struts.action.Action;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.util.Map;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.PageContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -101,8 +101,8 @@
*/
public class InsertTag extends DefinitionTagSupport implements PutTagParent,
ComponentConstants, PutListTagParent
{
- /** debug flag */
- public final static boolean debug = false;
+ /** Commons Logging instance. */
+ protected static Log log = LogFactory.getLog(InsertTag.class);
/* JSP Tag attributes */
/** Flush attribute value */
@@ -617,7 +617,7 @@
} // end catch
catch( DefinitionsFactoryException ex )
{
- if(debug)
+ if(log.isDebugEnabled())
ex.printStackTrace( );
// Save exception to be able to show it later
pageContext.setAttribute(Action.EXCEPTION_KEY, ex,
PageContext.REQUEST_SCOPE);
@@ -861,8 +861,8 @@
} // end if
try {
- if( DefinitionsUtil.userDebugLevel > DefinitionsUtil.NO_DEBUG )
- System.out.println( "insert page='" + page + "'." );
+ if(log.isDebugEnabled())
+ log.debug( "insert page='" + page + "'." );
// set new context for included component.
pageContext.setAttribute( ComponentConstants.COMPONENT_CONTEXT,
subCompContext, pageContext.REQUEST_SCOPE);
@@ -919,9 +919,9 @@
if( msg == null )
msg = ex.getMessage();
- if(debug)
+ if(log.isDebugEnabled())
{ // show full trace
- System.out.println( msg );
+ log.debug( msg );
ex.printStackTrace();
pageContext.getOut().println(msg);
ex.printStackTrace(new PrintWriter(pageContext.getOut(), true) );
@@ -987,8 +987,8 @@
}
catch (IOException ex)
{
- if(debug)
- System.out.println( "Can't write string '"+ value + "' : " +
ex.getMessage() );
+ if(log.isDebugEnabled())
+ log.debug( "Can't write string '"+ value + "' : " + ex.getMessage() );
pageContext.setAttribute(ComponentConstants.EXCEPTION_KEY, ex,
PageContext.REQUEST_SCOPE);
throw new JspException( "Can't write string '"+ value + "' : " +
ex.getMessage() );
}
1.3 +13 -8
jakarta-struts/src/share/org/apache/struts/taglib/tiles/DefinitionTag.java
Index: DefinitionTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/tiles/DefinitionTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefinitionTag.java 17 Jul 2002 09:24:29 -0000 1.2
+++ DefinitionTag.java 10 Oct 2002 16:32:27 -0000 1.3
@@ -66,8 +66,9 @@
import org.apache.struts.tiles.ComponentDefinition;
import org.apache.struts.tiles.AttributeDefinition;
import org.apache.struts.tiles.UntyppedAttribute;
-import org.apache.struts.tiles.DefinitionsUtil;
-import javax.servlet.jsp.tagext.TagSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import javax.servlet.jsp.JspException;
/**
@@ -80,6 +81,8 @@
*/
public class DefinitionTag extends DefinitionTagSupport implements PutTagParent,
PutListTagParent
{
+ /** Commons Logging instance. */
+ //protected static Log log = LogFactory.getLog(DefinitionTag.class);
/* JSP Tag attributes */
/**
@@ -263,7 +266,8 @@
if( extendsDefinition != null && !extendsDefinition.equals("") )
{
ComponentDefinition parentDef = TagUtils.getComponentDefinition(
extendsDefinition, pageContext );
- //System.out.println( "parent definition=" + parentDef );
+ //if(log.isDebugEnabled())
+ //log.debug( "parent definition=" + parentDef );
definition = new ComponentDefinition( parentDef );
} // end if
else
@@ -275,7 +279,8 @@
if( role != null )
definition.setRole(role);
- //System.out.println( "definition=" + definition );
+ //if(log.isDebugEnabled())
+ //log.debug( "definition=" + definition );
return EVAL_BODY_INCLUDE;
}
1.9 +38 -24 jakarta-struts/doc/userGuide/dev_tiles.xml
Index: dev_tiles.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/doc/userGuide/dev_tiles.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- dev_tiles.xml 31 Aug 2002 13:15:02 -0000 1.8
+++ dev_tiles.xml 10 Oct 2002 16:32:27 -0000 1.9
@@ -7,17 +7,17 @@
<body>
<chapter name="Tiles Guide">
<section href="tiles" name="The Tiles Document Assembly
Framework">
- <p>Tiles builds on the "include" feature provided by
the JavaServer Page
-specification to provided a full-featured, robust framework for assembling
-presentation pages from component parts. Each part, or tile, can be
-reused as often as needed throughout your application. This reduces the
-amount of markup that needs to be maintained and makes it easier to
+ <p>Tiles builds on the "include" feature provided by
the JavaServer Page
+specification to provided a full-featured, robust framework for assembling
+presentation pages from component parts. Each part, or tile, can be
+reused as often as needed throughout your application. This reduces the
+amount of markup that needs to be maintained and makes it easier to
change the look and feel of a website. </p>
</section>
<section href="features" name="Overview of Tiles Features">
<ul>
<li>
- Screen definitions
+ Screen definitions
<ul>
<li>
Create a screen by assembling
@@ -27,7 +27,7 @@
menu, body
</li>
<li>
- Definitions can take place :
+ Definitions can take place :
<ul>
<li>
in a centralized xml
@@ -49,7 +49,7 @@
</ul>
</li>
<li>
- Templating
+ Templating
<ul>
<li>
<strong>
@@ -69,7 +69,7 @@
</ul>
</li>
<li>
- Layouts
+ Layouts
<ul>
<li>
Define common page layouts and reuse
@@ -93,7 +93,7 @@
</ul>
</li>
<li>
- Dynamic page building
+ Dynamic page building
<ul>
<li>
Tiles are gather dynamically during
@@ -107,7 +107,7 @@
Reuse of <strong>
<em>Tiles</em>
</strong> /
- Components
+ Components
<ul>
<li>
If well defined, a
@@ -172,11 +172,11 @@
</ul>
</section>
<section href="setup" name="Enabling your application for
Tiles">
- <p>The Tiles framework is bundled with Struts. It is
not enabled by default.
+ <p>The Tiles framework is bundled with Struts. It is
not enabled by default.
To enable Tiles you need to:
</p>
<ul>
- <li>Setup the struts-tiles taglib in your
<code>WEB-INF/web.xml</code>
+ <li>Setup the struts-tiles taglib in your
<code>WEB-INF/web.xml</code>
file to include the following tag library declarations:</li>
</ul>
<pre><taglib>
@@ -198,38 +198,52 @@
files.</li>
<ul>
<li>Create a file containing your
definitions and give it a name (ex :
- <code>WEB-INF/tiles-defs.xml</code>). You can use the
<code>tiles-defs.xml</code>
+ <code>WEB-INF/tiles-defs.xml</code>). You can use the
<code>tiles-defs.xml</code>
file from the Tiles application for a detailed example of the required
syntax.</li>
<li>Setup Tiles plugin in each
<code>struts-config.xml</code> file corresponding to
a module:</li>
</ul>
<pre>
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
- <set-property property="definitions-config"
+ <set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml,
/WEB-INF/tiles-tests-defs.xml" />
- <set-property property="definitions-debug" value="0" />
- <set-property property="definitions-parser-details" value="0" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>
</pre>
<ul>
<li>
- <strong>note:</strong> This
plugin creates one single shared factory even if you have
- several modules. The plugin first read factory parameters from
<code>web.xml</code> and
- then overload them with parameters from the first
<code>struts-config.xml</code> file read.
+ <strong>note:</strong> This
plugin creates one single shared factory even if you have
+ several modules. The plugin first read factory parameters from
<code>web.xml</code> and
+ then overload them with parameters from the first
<code>struts-config.xml</code> file read.
Read order is determined by the order of module declarations in
<code>web.xml</code>.</li>
</ul>
</ul>
+ <ul>
+ <li>
+ <strong>note:</strong> Tiles framework now use the commons-logging
package to output different
+ information or debug data. Please refer to this package documentation
to enable it. The
+ simplest way to enable logging is to create two files under
<code>WEB-INF/classes</code>:
+ <pre>
+ <strong>commons-logging.properties</strong>
+ org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
+ <strong>simplelog.properties</strong>
+ # Logging detail level,
+ # Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
+ org.apache.commons.logging.simplelog.defaultlog=trace
+</pre>
+
+ </li>
+ </ul>
</section>
<section href="tiles" name="Tiles API Guide">
<ul>
-<li>A concise
+<li>A concise
<a
href="../api/org/apache/struts/tiles/package-summary.html#package_description">Tiles
API Guide</a> is available to help you get started with the Tiles framework.</li>
<li><a href="struts-tiles.html">Tiles Taglib Syntax Reference</a></li>
</ul>
</section>
-
+
<section href="resources" name="Tiles Resources">
<p>
<a
href="http://www-106.ibm.com/developerworks/java/library/j-strutstiles.html?loc=j">
@@ -245,8 +259,8 @@
<p>
<b>
<u>Developing applications with
Tiles</u>
- </b> by Cedric Dumoulin and Ted Husted.
-Sample chapter from <u>Java Web Development with Struts</u>; available as a
+ </b> by Cedric Dumoulin and Ted Husted.
+Sample chapter from <u>Java Web Development with Struts</u>; available as a
<u>free download</u> (PDF).
</p>
-->
1.3 +10 -7
jakarta-struts/src/share/org/apache/struts/tiles/actions/DefinitionDispatcherAction.java
Index: DefinitionDispatcherAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/actions/DefinitionDispatcherAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefinitionDispatcherAction.java 11 Jul 2002 16:46:40 -0000 1.2
+++ DefinitionDispatcherAction.java 10 Oct 2002 16:32:27 -0000 1.3
@@ -66,14 +66,14 @@
import java.io.IOException;
import java.io.PrintWriter;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
@@ -110,6 +110,8 @@
*/
public final class DefinitionDispatcherAction extends Action {
+ /** Commons Logging instance. */
+ protected static Log log = LogFactory.getLog(DefinitionDispatcherAction.class);
/**
* Process the specified HTTP request, and create the corresponding HTTP
@@ -153,7 +155,8 @@
{
// Read definition from factory, but we can create it here.
ComponentDefinition definition = DefinitionsUtil.getDefinition( name,
request, getServlet().getServletContext() );
- System.out.println("get Definition " + definition );
+ if(log.isDebugEnabled())
+ log.debug("get Definition " + definition );
DefinitionsUtil.setActionDefinition( request, definition);
}
catch( FactoryNotFoundException ex )
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>