dgraham 2003/07/08 17:14:01
Modified: src/share/org/apache/struts/tiles TilesUtilImpl.java
TilesUtilStrutsImpl.java TilesUtil.java
src/share/org/apache/struts/tiles/definition
ReloadableDefinitionsFactory.java
ComponentDefinitionsFactoryWrapper.java
Log:
Removed deprecated TilesUtil.applicationClass() method.
Revision Changes Path
1.5 +116 -111
jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilImpl.java
Index: TilesUtilImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TilesUtilImpl.java 17 Apr 2003 03:51:12 -0000 1.4
+++ TilesUtilImpl.java 9 Jul 2003 00:14:00 -0000 1.5
@@ -76,18 +76,19 @@
import org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper;
import org.apache.struts.util.RequestUtils;
- /**
- * Default implementation of TilesUtil.
- * This class contains default implementation of utilities. This implementation
- * is intended to be used without Struts.
- */
-public class TilesUtilImpl implements Serializable
-{
- /** Commons Logging instance.*/
- protected Log log = LogFactory.getLog(TilesUtil.class);
+/**
+ * Default implementation of TilesUtil.
+ * This class contains default implementation of utilities. This implementation
+ * is intended to be used without Struts.
+ */
+public class TilesUtilImpl implements Serializable {
+
+ /** Commons Logging instance.*/
+ protected Log log = LogFactory.getLog(TilesUtil.class);
/** Constant name used to store factory in servlet context */
- public static final String DEFINITIONS_FACTORY =
"org.apache.struts.tiles.DEFINITIONS_FACTORY";
+ public static final String DEFINITIONS_FACTORY =
+ "org.apache.struts.tiles.DEFINITIONS_FACTORY";
/**
* Do a forward using request dispatcher.
@@ -97,12 +98,15 @@
* @param request Current page request.
* @param servletContext Current servlet context.
*/
- public void doForward(String uri, HttpServletRequest request, HttpServletResponse
response,
- ServletContext servletContext)
- throws IOException, ServletException
- {
- request.getRequestDispatcher( uri ).forward(request, response);
- }
+ public void doForward(
+ String uri,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ ServletContext servletContext)
+ throws IOException, ServletException {
+
+ request.getRequestDispatcher(uri).forward(request, response);
+ }
/**
* Do an include using request dispatcher.
@@ -114,12 +118,15 @@
* @param response Current page response.
* @param servletContext Current servlet context.
*/
- public void doInclude(String uri, HttpServletRequest request, HttpServletResponse
response,
- ServletContext servletContext)
- throws IOException, ServletException
- {
- request.getRequestDispatcher( uri ).include(request, response);
- }
+ public void doInclude(
+ String uri,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ ServletContext servletContext)
+ throws IOException, ServletException {
+
+ request.getRequestDispatcher(uri).include(request, response);
+ }
/**
* Do an include using PageContext.include().
@@ -131,20 +138,22 @@
* @param response Current page response.
* @param servletContext Current servlet context.
*/
- public static void doInclude(String uri, PageContext pageContext)
- throws IOException, ServletException
- {
- pageContext.include(uri);
- }
+ public static void doInclude(String uri, PageContext pageContext)
+ throws IOException, ServletException {
+
+ pageContext.include(uri);
+ }
/**
* Get definition factory from appropriate servlet context.
* @return Definitions factory or <code>null</code> if not found.
*/
- public DefinitionsFactory getDefinitionsFactory(ServletRequest request,
ServletContext servletContext)
- {
- return (DefinitionsFactory)servletContext.getAttribute(DEFINITIONS_FACTORY);
- }
+ public DefinitionsFactory getDefinitionsFactory(
+ ServletRequest request,
+ ServletContext servletContext) {
+
+ return (DefinitionsFactory)
servletContext.getAttribute(DEFINITIONS_FACTORY);
+ }
/**
* Create Definition factory from specified configuration object.
@@ -160,84 +169,80 @@
* @return newly created factory of type specified in the config object.
* @throws DefinitionsFactoryException If an error occur while initializing
factory
*/
- public DefinitionsFactory createDefinitionsFactory(ServletContext servletContext,
DefinitionsFactoryConfig factoryConfig)
- throws DefinitionsFactoryException
- {
- // Create configurable factory
- DefinitionsFactory factory =
createDefinitionFactoryInstance(factoryConfig.getFactoryClassname());
- factory.init( factoryConfig, servletContext );
- // Make factory accessible from jsp tags (push it in appropriate context)
- makeDefinitionsFactoryAccessible(factory, servletContext );
- return factory;
- }
-
- /**
- * Create Definition factory of specified classname.
- * Factory class must extend the [EMAIL PROTECTED] DefinitionsFactory} class.
- * The factory is wrapped appropriately with [EMAIL PROTECTED]
ComponentDefinitionsFactoryWrapper}
- * if it is an instance of the deprecated ComponentDefinitionsFactory class.
- * @param classname Class name of the factory to create.
- * @return newly created factory.
- * @throws DefinitionsFactoryException If an error occur while initializing
factory
- */
- protected DefinitionsFactory createDefinitionFactoryInstance(String classname)
- throws DefinitionsFactoryException
- {
- try
- {
- Class factoryClass = applicationClass(classname);
- Object factory = factoryClass.newInstance();
-
- // Backward compatibility : if factory classes implements old interface,
- // provide appropriate wrapper
- if( factory instanceof ComponentDefinitionsFactory )
- {
- factory = new ComponentDefinitionsFactoryWrapper(
(ComponentDefinitionsFactory)factory );
- } // end if
- return (DefinitionsFactory)factory;
- }
- catch( ClassCastException ex )
- { // Bad classname
- throw new DefinitionsFactoryException( "Error - createDefinitionsFactory :
Factory class '"
- + classname +" must implement
'TilesDefinitionsFactory'.", ex );
- }
- catch( ClassNotFoundException ex )
- { // Bad classname
- throw new DefinitionsFactoryException( "Error - createDefinitionsFactory : Bad
class name '"
- + classname +"'.", ex );
- }
- catch( InstantiationException ex )
- { // Bad constructor or error
- throw new DefinitionsFactoryException( ex );
- }
- catch( IllegalAccessException ex )
- { //
- throw new DefinitionsFactoryException( ex );
- }
- }
- /**
- * Make definition factory accessible to Tags.
- * Factory is stored in servlet context.
- * @param factory Factory to be made accessible.
- * @param servletContext Current servlet context.
- */
- protected void makeDefinitionsFactoryAccessible(DefinitionsFactory factory,
ServletContext servletContext)
- {
- servletContext.setAttribute(DEFINITIONS_FACTORY, factory);
- }
+ public DefinitionsFactory createDefinitionsFactory(
+ ServletContext servletContext,
+ DefinitionsFactoryConfig factoryConfig)
+ throws DefinitionsFactoryException {
+
+ // Create configurable factory
+ DefinitionsFactory factory =
+ createDefinitionFactoryInstance(factoryConfig.getFactoryClassname());
+
+ factory.init(factoryConfig, servletContext);
+
+ // Make factory accessible from jsp tags (push it in appropriate context)
+ makeDefinitionsFactoryAccessible(factory, servletContext);
+ return factory;
+ }
/**
- * Return the <code>Class</code> object for the specified fully qualified
- * class name from the underlying class loader.
- *
- * @param className Fully qualified class name to be loaded.
- * @return Class object.
- * @exception ClassNotFoundException if the class cannot be found
- * @deprecated Use RequestUtils.applicationClass() instead.
- */
- public Class applicationClass(String className) throws ClassNotFoundException
- {
- return RequestUtils.applicationClass(className);
- }
+ * Create Definition factory of specified classname.
+ * Factory class must extend the [EMAIL PROTECTED] DefinitionsFactory} class.
+ * The factory is wrapped appropriately with [EMAIL PROTECTED]
ComponentDefinitionsFactoryWrapper}
+ * if it is an instance of the deprecated ComponentDefinitionsFactory class.
+ * @param classname Class name of the factory to create.
+ * @return newly created factory.
+ * @throws DefinitionsFactoryException If an error occur while initializing
factory
+ */
+ protected DefinitionsFactory createDefinitionFactoryInstance(String classname)
+ throws DefinitionsFactoryException {
+
+ try {
+ Class factoryClass = RequestUtils.applicationClass(classname);
+ Object factory = factoryClass.newInstance();
+
+ // Backward compatibility : if factory classes implements old interface,
+ // provide appropriate wrapper
+ if (factory instanceof ComponentDefinitionsFactory) {
+ factory =
+ new ComponentDefinitionsFactoryWrapper(
+ (ComponentDefinitionsFactory) factory);
+ }
+ return (DefinitionsFactory) factory;
+
+ } catch (ClassCastException ex) { // Bad classname
+ throw new DefinitionsFactoryException(
+ "Error - createDefinitionsFactory : Factory class '"
+ + classname
+ + " must implement 'TilesDefinitionsFactory'.",
+ ex);
+
+ } catch (ClassNotFoundException ex) { // Bad classname
+ throw new DefinitionsFactoryException(
+ "Error - createDefinitionsFactory : Bad class name '"
+ + classname
+ + "'.",
+ ex);
+
+ } catch (InstantiationException ex) { // Bad constructor or error
+ throw new DefinitionsFactoryException(ex);
+
+ } catch (IllegalAccessException ex) {
+ throw new DefinitionsFactoryException(ex);
+ }
+ }
+
+ /**
+ * Make definition factory accessible to Tags.
+ * Factory is stored in servlet context.
+ * @param factory Factory to be made accessible.
+ * @param servletContext Current servlet context.
+ */
+ protected void makeDefinitionsFactoryAccessible(
+ DefinitionsFactory factory,
+ ServletContext servletContext) {
+
+ servletContext.setAttribute(DEFINITIONS_FACTORY, factory);
+ }
}
1.5 +16 -30
jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilStrutsImpl.java
Index: TilesUtilStrutsImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilStrutsImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TilesUtilStrutsImpl.java 17 Apr 2003 03:51:12 -0000 1.4
+++ TilesUtilStrutsImpl.java 9 Jul 2003 00:14:00 -0000 1.5
@@ -63,30 +63,15 @@
import javax.servlet.ServletContext;
-import org.apache.struts.util.RequestUtils;
import org.apache.struts.config.ModuleConfig;
- /**
- * TilesUtil implementation for Struts 1.1 with one single factory.
- * This class contains default implementation of utilities. This implementation
- * is intended to be used with Struts 1.1.
- * This class is used as the base class for all Struts 1.1 implementations of
TilesUtil.
- */
-public class TilesUtilStrutsImpl extends TilesUtilImpl
-{
-
- /**
- * Return the <code>Class</code> object for the specified fully qualified
- * class name from the Struts class loader.
- *
- * @param className Fully qualified class name to be loaded.
- * @return Class object.
- * @exception ClassNotFoundException if the class cannot be found
- * @deprecated Use RequestUtils.applicationClass() instead.
- */
- public Class applicationClass(String className) throws ClassNotFoundException {
- return RequestUtils.applicationClass(className);
- }
+/**
+ * TilesUtil implementation for Struts 1.1 with one single factory.
+ * This class contains default implementation of utilities. This implementation
+ * is intended to be used with Struts 1.1.
+ * This class is used as the base class for all Struts 1.1 implementations of
TilesUtil.
+ */
+public class TilesUtilStrutsImpl extends TilesUtilImpl {
/**
* Get definition factory for the module attached to the specified moduleConfig.
@@ -94,10 +79,11 @@
* @param moduleConfig Module config of the module for which the factory is
requested.
* @return Definitions factory or null if not found.
*/
- public DefinitionsFactory getDefinitionsFactory(ServletContext servletContext,
ModuleConfig moduleConfig)
- {
- return (DefinitionsFactory)servletContext.getAttribute(DEFINITIONS_FACTORY);
- }
-
+ public DefinitionsFactory getDefinitionsFactory(
+ ServletContext servletContext,
+ ModuleConfig moduleConfig) {
+
+ return (DefinitionsFactory)
servletContext.getAttribute(DEFINITIONS_FACTORY);
+ }
}
1.9 +90 -99 jakarta-struts/src/share/org/apache/struts/tiles/TilesUtil.java
Index: TilesUtil.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesUtil.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TilesUtil.java 22 Apr 2003 02:28:52 -0000 1.8
+++ TilesUtil.java 9 Jul 2003 00:14:00 -0000 1.9
@@ -73,33 +73,32 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
- /**
- * Class containing utility methods for Tiles.
- * Methods of this class are static and thereby accessible from anywhere.
- * The underlying implementation can be changed with
- * [EMAIL PROTECTED] #setTilesUtil(TilesUtilImpl)}.
- * <br>
- * Real implementation classes should derive from the [EMAIL PROTECTED]
TilesUtilImpl} class.
- * <br>
- * Some methods are specified to throw the
<code>UnsupportedOperationException</code>
- * if the underlying implementation doesn't support the operation.
- */
-public class TilesUtil
-{
- /** Commons Logging instance.*/
- protected static Log log = LogFactory.getLog(TilesUtil.class);
+/**
+ * Class containing utility methods for Tiles.
+ * Methods of this class are static and thereby accessible from anywhere.
+ * The underlying implementation can be changed with
+ * [EMAIL PROTECTED] #setTilesUtil(TilesUtilImpl)}.
+ * <br>
+ * Real implementation classes should derive from the [EMAIL PROTECTED]
TilesUtilImpl} class.
+ * <br>
+ * Some methods are specified to throw the
<code>UnsupportedOperationException</code>
+ * if the underlying implementation doesn't support the operation.
+ */
+public class TilesUtil {
+
+ /** Commons Logging instance.*/
+ protected static Log log = LogFactory.getLog(TilesUtil.class);
/** The implementation of tilesUtilImpl */
- protected static TilesUtilImpl tilesUtilImpl = new TilesUtilImpl();
+ protected static TilesUtilImpl tilesUtilImpl = new TilesUtilImpl();
/**
* Get the real implementation.
* @return The underlying implementation object.
*/
- static public TilesUtilImpl getTilesUtil()
- {
- return tilesUtilImpl;
- }
+ static public TilesUtilImpl getTilesUtil() {
+ return tilesUtilImpl;
+ }
/**
* Set the real implementation.
@@ -107,27 +106,25 @@
* Successive calls have no effect.
* @param tilesUtil The implementaion.
*/
- static public void setTilesUtil(TilesUtilImpl tilesUtil)
- {
- if( implAlreadySet)
- return;
- tilesUtilImpl = tilesUtil;
- implAlreadySet = true;
- }
+ static public void setTilesUtil(TilesUtilImpl tilesUtil) {
+ if (implAlreadySet) {
+ return;
+ }
+ tilesUtilImpl = tilesUtil;
+ implAlreadySet = true;
+ }
/**
* Getter to know if the underlying implementation is already set to another
* value than the default value.
* @return <code>true</code> if [EMAIL PROTECTED] #setTilesUtil} has already
been called.
*/
- static boolean isTilesUtilImplSet()
- {
- return implAlreadySet;
- }
-
+ static boolean isTilesUtilImplSet() {
+ return implAlreadySet;
+ }
/** Flag to know if internal implementation has been set by the setter method */
- private static boolean implAlreadySet=false;
+ private static boolean implAlreadySet = false;
/**
* Do a forward using request dispatcher.
@@ -138,12 +135,15 @@
* @param response Current page response.
* @param servletContext Current servlet context.
*/
- public static void doForward(String uri, HttpServletRequest request,
HttpServletResponse response,
- ServletContext servletContext)
- throws IOException, ServletException
- {
- tilesUtilImpl.doForward(uri, request, response, servletContext);
- }
+ public static void doForward(
+ String uri,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ ServletContext servletContext)
+ throws IOException, ServletException {
+
+ tilesUtilImpl.doForward(uri, request, response, servletContext);
+ }
/**
* Do an include using request dispatcher.
@@ -155,12 +155,15 @@
* @param response Current page response.
* @param servletContext Current servlet context.
*/
- public static void doInclude(String uri, HttpServletRequest request,
HttpServletResponse response,
- ServletContext servletContext)
- throws IOException, ServletException
- {
- tilesUtilImpl.doInclude(uri, request, response, servletContext);
- }
+ public static void doInclude(
+ String uri,
+ HttpServletRequest request,
+ HttpServletResponse response,
+ ServletContext servletContext)
+ throws IOException, ServletException {
+
+ tilesUtilImpl.doInclude(uri, request, response, servletContext);
+ }
/**
* Do an include using PageContext.include().
@@ -181,10 +184,11 @@
* Get definition factory from appropriate servlet context.
* @return Definitions factory or <code>null</code> if not found.
*/
- static public DefinitionsFactory getDefinitionsFactory(ServletRequest request,
ServletContext servletContext)
- {
- return tilesUtilImpl.getDefinitionsFactory(request, servletContext);
- }
+ public static DefinitionsFactory getDefinitionsFactory(
+ ServletRequest request,
+ ServletContext servletContext) {
+ return tilesUtilImpl.getDefinitionsFactory(request, servletContext);
+ }
/**
* Create Definition factory from specified configuration object.
@@ -199,61 +203,48 @@
* @return newly created factory of type ConfigurableDefinitionsFactory.
* @throws DefinitionsFactoryException If an error occur while initializing
factory
*/
- public static DefinitionsFactory createDefinitionsFactory(ServletContext
servletContext, DefinitionsFactoryConfig factoryConfig)
- throws DefinitionsFactoryException
- {
- return tilesUtilImpl.createDefinitionsFactory(servletContext, factoryConfig);
- }
-
- /**
- * 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 definitionName Name of requested definition.
- * @param request Current servelet request.
- * @param servletContext current servlet context.
- * @throws FactoryNotFoundException Can't find definition factory.
- * @throws DefinitionsFactoryException General error in factory while getting
definition.
- * @throws NoSuchDefinitionException No definition found for specified name
- */
- static public ComponentDefinition getDefinition(String definitionName,
ServletRequest request, ServletContext servletContext)
- throws FactoryNotFoundException, DefinitionsFactoryException
- {
- try
- {
- return getDefinitionsFactory(request,
servletContext).getDefinition(definitionName,
- (HttpServletRequest)request,
- servletContext);
- }
- catch( NullPointerException ex )
- { // Factory not found in context
- throw new FactoryNotFoundException( "Can't get definitions factory from
context." );
+ public static DefinitionsFactory createDefinitionsFactory(
+ ServletContext servletContext,
+ DefinitionsFactoryConfig factoryConfig)
+ throws DefinitionsFactoryException {
+ return tilesUtilImpl.createDefinitionsFactory(servletContext,
factoryConfig);
}
- }
/**
- * Return the <code>Class</code> object for the specified fully qualified
- * class name from the underlying class loader.
- *
- * @param className Fully qualified class name to be loaded.
- * @return Class object.
- * @exception ClassNotFoundException if the class cannot be found
- * @deprecated Use RequestUtils.applicationClass() instead.
- */
- public static Class applicationClass(String className)
- throws ClassNotFoundException {
- return tilesUtilImpl.applicationClass(className);
+ * 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 definitionName Name of requested definition.
+ * @param request Current servelet request.
+ * @param servletContext current servlet context.
+ * @throws FactoryNotFoundException Can't find definition factory.
+ * @throws DefinitionsFactoryException General error in factory while getting
definition.
+ * @throws NoSuchDefinitionException No definition found for specified name
+ */
+ public static ComponentDefinition getDefinition(
+ String definitionName,
+ ServletRequest request,
+ ServletContext servletContext)
+ throws FactoryNotFoundException, DefinitionsFactoryException {
+
+ try {
+ return getDefinitionsFactory(request, servletContext).getDefinition(
+ definitionName,
+ (HttpServletRequest) request,
+ servletContext);
+
+ } catch (NullPointerException ex) { // Factory not found in context
+ throw new FactoryNotFoundException("Can't get definitions factory from
context.");
+ }
}
-
/**
* Reset internal state.
* This method is used by test suites to reset the class to its original state.
*/
- protected static void testReset()
- {
- implAlreadySet = false;
- tilesUtilImpl = new TilesUtilImpl();
- }
+ protected static void testReset() {
+ implAlreadySet = false;
+ tilesUtilImpl = new TilesUtilImpl();
+ }
}
1.8 +6 -5
jakarta-struts/src/share/org/apache/struts/tiles/definition/ReloadableDefinitionsFactory.java
Index: ReloadableDefinitionsFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/definition/ReloadableDefinitionsFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ReloadableDefinitionsFactory.java 4 Jul 2003 20:53:42 -0000 1.7
+++ ReloadableDefinitionsFactory.java 9 Jul 2003 00:14:01 -0000 1.8
@@ -76,6 +76,7 @@
import org.apache.struts.tiles.FactoryNotFoundException;
import org.apache.struts.tiles.xmlDefinition.I18nFactorySet;
import org.apache.struts.tiles.TilesUtil;
+import org.apache.struts.util.RequestUtils;
/**
* A reloadable factory.
@@ -160,7 +161,7 @@
// Try to create from classname
try {
- Class factoryClass = TilesUtil.applicationClass(classname);
+ Class factoryClass = RequestUtils.applicationClass(classname);
ComponentDefinitionsFactory factory =
(ComponentDefinitionsFactory) factoryClass.newInstance();
factory.initFactory(servletContext, properties);
1.8 +5 -4
jakarta-struts/src/share/org/apache/struts/tiles/definition/ComponentDefinitionsFactoryWrapper.java
Index: ComponentDefinitionsFactoryWrapper.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/definition/ComponentDefinitionsFactoryWrapper.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ComponentDefinitionsFactoryWrapper.java 9 Jul 2003 00:05:17 -0000 1.7
+++ ComponentDefinitionsFactoryWrapper.java 9 Jul 2003 00:14:01 -0000 1.8
@@ -74,6 +74,7 @@
import org.apache.struts.tiles.DefinitionsFactoryException;
import org.apache.struts.tiles.NoSuchDefinitionException;
import org.apache.struts.tiles.TilesUtil;
+import org.apache.struts.util.RequestUtils;
/**
* Wrapper from new definition factory interface to old interface.
@@ -198,7 +199,7 @@
throws DefinitionsFactoryException {
try {
- Class factoryClass = TilesUtil.applicationClass(classname);
+ Class factoryClass = RequestUtils.applicationClass(classname);
Object factory = factoryClass.newInstance();
return (ComponentDefinitionsFactory) factory;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]