cedric 2002/12/16 16:57:36
Modified: src/share/org/apache/struts/tiles
ActionComponentServlet.java
ComponentDefinition.java DefaultTilesUtilImpl.java
DefinitionsUtil.java
StrutsModulesTilesUtilImpl.java TilesPlugin.java
TilesUtil.java TilesUtilInterface.java
Log:
Localize calls to RequestUtils in few struts (1.1) dependent classes.
This allows to compile the Tiles package with Struts1.0 or without Struts.
In these two later compilations, struts1.1 dependent classes aren't use.
Revision Changes Path
1.6 +162 -145
jakarta-struts/src/share/org/apache/struts/tiles/ActionComponentServlet.java
Index: ActionComponentServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/ActionComponentServlet.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ActionComponentServlet.java 21 Nov 2002 03:42:21 -0000 1.5
+++ ActionComponentServlet.java 17 Dec 2002 00:57:36 -0000 1.6
@@ -92,51 +92,52 @@
* Compliant to ActionServlet from struts 2001/06/25 00:02:27
*/
public class ActionComponentServlet extends ActionServlet {
- /** Definitions factory */
+ /** Definitions factory */
private DefinitionsFactory definitionsFactory;
/**
* Init method.
* This method is call on any servlet.
*/
- public void init() throws ServletException {
- super.init();
- initComponentDefinitionsMapping();
- }
+ public void init() throws ServletException
+ {
+ super.init();
+ initComponentDefinitionsMapping();
+ }
/**
* Read component instance mapping configuration file.
* This is where we read files properties.
*/
- public void initComponentDefinitionsMapping() throws ServletException //
IOException,
+ public void initComponentDefinitionsMapping() throws ServletException //
IOException,
+ {
+ // Check struts version by checkin PlugIn classes existance.
+ try
{
- // Check struts version by checkin PlugIn classes existance.
- try {
- Class plugInClass = RequestUtils.applicationClass(
- "org.apache.struts.action.PlugIn");
- // Class exist ==> struts 1.1 or greater
- log(
- "Warning - ActionComponentServlet class: This class is to be used
with Struts1.0.x only. "
- + "Please modify web.xml to use regular ActionServlet class
instead in conjugaison "
- + "with appropriate plugin declared in struts-config.xml.");
- //return;
- // Let create factory for backward compatibility
- } catch (ClassNotFoundException ex) { // Not found ==> struts 1.0.x
- }
+ Class plugInClass = TilesUtil.applicationClass(
"org.apache.struts.action.PlugIn");
+ // Class exist ==> struts 1.1 or greater
+ log( "Warning - ActionComponentServlet class: This class is to be used with
Struts1.0.x only. "
+ + "Please modify web.xml to use regular ActionServlet class instead in
conjugaison "
+ + "with appropriate plugin declared in struts-config.xml.");
+ //return;
+ // Let create factory for backward compatibility
+ }
+ catch( ClassNotFoundException ex )
+ { // Not found ==> struts 1.0.x
+ }
- try {
- // create definition factory
- definitionsFactory =
- DefinitionsUtil.createDefinitionsFactory(
- getServletContext(),
- getServletConfig(),
- true);
- } catch (DefinitionsFactoryException ex) {
- log("Fail to load Tiles definition factory from
ActionComponentServlet", ex);
- throw new ServletException(ex.getMessage(), ex);
- }
- log("Tiles definition factory loaded from ActionComponentServlet");
+ try
+ {
+ // create definition factory
+ definitionsFactory =
DefinitionsUtil.createDefinitionsFactory(getServletContext(), getServletConfig(),
true);
+ }
+ catch( DefinitionsFactoryException ex )
+ {
+ log( "Fail to load Tiles definition factory from ActionComponentServlet", ex);
+ throw new ServletException( ex.getMessage(), ex );
}
+ log("Tiles definition factory loaded from ActionComponentServlet");
+ }
/**
* Overload struts1.0 counterpart in order to catch forward calls.
@@ -157,27 +158,31 @@
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
- protected void processActionForward(
- ActionForward forward,
- ActionMapping mapping,
- ActionForm formInstance,
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- if (forward != null) {
- String path = forward.getPath();
- if (forward.getRedirect()) {
- if (path.startsWith("/"))
- path = request.getContextPath() + path;
- response.sendRedirect(response.encodeRedirectURL(path));
- } else {
- doForward(path, request, response);
- }
- }
+ protected void processActionForward( ActionForward forward,
+ ActionMapping mapping,
+ ActionForm formInstance,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws IOException, ServletException
+ {
+ if (forward != null)
+ {
+ String path = forward.getPath();
+ if (forward.getRedirect())
+ {
+ if (path.startsWith("/"))
+ path = request.getContextPath() + path;
+ response.sendRedirect(response.encodeRedirectURL(path));
+ }
+ else
+ {
+ doForward(path, request, response);
+ }
}
+ }
+
/**
* Overload struts1.0 counterpart in order to catch forward calls.
* This is an exact copy, except the call to RequestDispatcher.forward()
@@ -199,10 +204,8 @@
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet exception occurs
*/
- protected boolean processValidate(
- ActionMapping mapping,
- ActionForm formInstance,
- HttpServletRequest request,
+ protected boolean processValidate(ActionMapping mapping,
+ ActionForm formInstance, HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
@@ -224,8 +227,10 @@
return (true);
// Call the validate() method of our ActionForm bean
+ // Use struts1.0 compatible method, as this class is mainly for struts1.0
+ // backward compatibility.
ActionErrors errors = formInstance.validate(mapping, request);
- if ((errors == null) || errors.isEmpty()) {
+ if ((errors == null) || errors.empty()) { //
if (debug >= 1)
log(" No errors detected, accepting input");
return (true);
@@ -280,10 +285,9 @@
* @exception ServletException if the included resource throws an
* exception
*/
- protected boolean processForward(
- ActionMapping mapping,
- HttpServletRequest request,
- HttpServletResponse response)
+ protected boolean processForward(ActionMapping mapping,
+ HttpServletRequest request,
+ HttpServletResponse response)
throws IOException, ServletException {
// Are we going to process this request?
@@ -316,10 +320,9 @@
* @exception ServletException if the included resource throws an
* exception
*/
- protected boolean processInclude(
- ActionMapping mapping,
- HttpServletRequest request,
- HttpServletResponse response)
+ protected boolean processInclude(ActionMapping mapping,
+ HttpServletRequest request,
+ HttpServletResponse response)
throws IOException, ServletException {
// Are we going to process this request?
@@ -341,12 +344,12 @@
* @param response Current page response
* @deprecated use doForward instead
*/
- protected void processForward(
- String uri,
- HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
- doForward(uri, request, response);
+ protected void processForward( String uri,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws IOException, ServletException
+ {
+ doForward(uri, request, response);
}
/**
@@ -358,86 +361,100 @@
* @param request Current page request
* @param response Current page response
*/
- protected void doForward(String uri, HttpServletRequest request,
HttpServletResponse response)
- throws IOException, ServletException {
- // Do we do a forward (original behavior) or an include ?
- boolean doInclude = false;
- // Controller associated to a definition, if any
- Controller controller = null;
- ComponentContext tileContext = null;
-
- try {
- // Get current tile context if any.
- // If context exist, we will do an include
- tileContext = ComponentContext.getContext(request);
- doInclude = (tileContext != null);
- ComponentDefinition definition;
-
- // Process tiles definition names only if a definition factory exist,
- // and definition found.
- if (definitionsFactory != null) {
- // Get definition of tiles/component corresponding to uri.
- definition = definitionsFactory.getDefinition(uri, request,
getServletContext());
- if (definition != null) { // We have a definition.
- // We use it to complete missing attribute in context.
- // We also get uri, controller.
- uri = definition.getPath();
- controller = definition.getOrCreateController();
- if (tileContext == null) {
- tileContext = new
ComponentContext(definition.getAttributes());
- ComponentContext.setContext(tileContext, request);
- } else
- tileContext.addMissing(definition.getAttributes());
- } // end if
+ protected void doForward(String uri, HttpServletRequest request,
HttpServletResponse response)
+ throws IOException, ServletException
+ {
+ // Do we do a forward (original behavior) or an include ?
+ boolean doInclude = false;
+ // Controller associated to a definition, if any
+ Controller controller = null;
+ ComponentContext tileContext = null;
+
+ try
+ {
+ // Get current tile context if any.
+ // If context exist, we will do an include
+ tileContext = ComponentContext.getContext( request );
+ doInclude = (tileContext!=null );
+ ComponentDefinition definition;
+
+ // Process tiles definition names only if a definition factory exist,
+ // and definition found.
+ if( definitionsFactory != null )
+ { // Get definition of tiles/component corresponding to uri.
+ definition = definitionsFactory.getDefinition(uri, request,
getServletContext());
+ if( definition != null )
+ { // We have a definition.
+ // We use it to complete missing attribute in context.
+ // We also get uri, controller.
+ uri = definition.getPath();
+ controller = definition.getOrCreateController();
+ if( tileContext == null )
+ {
+ tileContext = new ComponentContext( definition.getAttributes() );
+ ComponentContext.setContext( tileContext, request);
+ }
+ else
+ tileContext.addMissing( definition.getAttributes() );
} // end if
+ } // end if
- // Process definition set in Action, if any.
- definition = DefinitionsUtil.getActionDefinition(request);
- if (definition != null) { // We have a definition.
- // We use it to complete missing attribute in context.
- // We also overload uri and controller if set in definition.
- if (definition.getPath() != null)
- uri = definition.getPath();
- if (definition.getOrCreateController() != null)
- controller = definition.getOrCreateController();
- if (tileContext == null) {
- tileContext = new ComponentContext(definition.getAttributes());
- ComponentContext.setContext(tileContext, request);
- } else
- tileContext.addMissing(definition.getAttributes());
- } // end if
+ // Process definition set in Action, if any.
+ definition = DefinitionsUtil.getActionDefinition(request);
+ if( definition != null )
+ { // We have a definition.
+ // We use it to complete missing attribute in context.
+ // We also overload uri and controller if set in definition.
+ if(definition.getPath()!=null)
+ uri = definition.getPath();
+ if(definition.getOrCreateController()!=null)
+ controller = definition.getOrCreateController();
+ if( tileContext == null )
+ {
+ tileContext = new ComponentContext( definition.getAttributes() );
+ ComponentContext.setContext( tileContext, request);
+ }
+ else
+ tileContext.addMissing( definition.getAttributes() );
+ } // end if
- } catch (java.lang.InstantiationException ex) {
- throw new ServletException("Can't create associated controller", ex);
- } catch (DefinitionsFactoryException ex) {
- throw new ServletException(ex);
}
-
- // Execute controller associated to definition, if any.
- if (controller != null) {
- controller.perform(tileContext, request, response, getServletContext());
- } // end if
-
- // Do dispatching : search dispatcher, then dispatch
- RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
- if (rd == null) { // error
- response.sendError(
- HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
- internal.getMessage("requestDispatcher", uri));
- return;
- } // end if
-
- // Unwrap the multipart request, if there is one.
- if (request instanceof MultipartRequestWrapper) {
- request = ((MultipartRequestWrapper) request).getRequest();
+ catch( java.lang.InstantiationException ex )
+ {
+ throw new ServletException( "Can't create associated controller", ex );
+ }
+ catch( DefinitionsFactoryException ex )
+ {
+ throw new ServletException( ex );
}
- // If request comes from a previous Tile, do an include.
- // This allows to insert an action in a Tile.
- if (doInclude)
- rd.include(request, response);
- else
- rd.forward(request, response); // original behavior
+ // Execute controller associated to definition, if any.
+ if(controller !=null)
+ {
+ controller.perform( tileContext, request, response, getServletContext());
+ } // end if
+
+ // Do dispatching : search dispatcher, then dispatch
+ RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
+ if (rd == null)
+ { // error
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ internal.getMessage("requestDispatcher", uri));
+ return;
+ } // end if
+
+ // Unwrap the multipart request, if there is one.
+ if (request instanceof MultipartRequestWrapper) {
+ request = ((MultipartRequestWrapper) request).getRequest();
}
+
+ // If request comes from a previous Tile, do an include.
+ // This allows to insert an action in a Tile.
+ if( doInclude )
+ rd.include(request, response);
+ else
+ rd.forward(request, response); // original behavior
+ }
+
}
1.5 +4 -5
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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ComponentDefinition.java 21 Nov 2002 03:42:21 -0000 1.4
+++ ComponentDefinition.java 17 Dec 2002 00:57:36 -0000 1.5
@@ -67,7 +67,6 @@
import java.util.HashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.struts.util.RequestUtils;
/**
* Definition of a template / component attributes.
@@ -572,7 +571,7 @@
{
try
{
- Class requestedClass = RequestUtils.applicationClass(classname);
+ Class requestedClass = TilesUtil.applicationClass(classname);
Object instance = requestedClass.newInstance();
/*
if( instance instanceof org.apache.struts.action.Action )
1.4 +19 -6
jakarta-struts/src/share/org/apache/struts/tiles/DefaultTilesUtilImpl.java
Index: DefaultTilesUtilImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/DefaultTilesUtilImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultTilesUtilImpl.java 21 Nov 2002 03:42:21 -0000 1.3
+++ DefaultTilesUtilImpl.java 17 Dec 2002 00:57:36 -0000 1.4
@@ -62,6 +62,7 @@
package org.apache.struts.tiles;
import java.io.IOException;
+import java.io.Serializable;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -72,14 +73,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper;
-import org.apache.struts.util.RequestUtils;
/**
* Default implementation of TilesUtil.
* This class conatains default implementation of utilities. This implementation
* is intended to be used without Struts
*/
-public class DefaultTilesUtilImpl implements TilesUtilInterface
+public class DefaultTilesUtilImpl implements TilesUtilInterface, Serializable
{
/** Commons Logging instance.*/
protected Log log = LogFactory.getLog(DefaultTilesUtilImpl.class);
@@ -176,7 +176,7 @@
{
try
{
- Class factoryClass = RequestUtils.applicationClass(classname);
+ Class factoryClass = applicationClass(classname);
Object factory = factoryClass.newInstance();
// Backward compatibility : if factory classes implements old interface,
@@ -215,6 +215,19 @@
protected void makeDefinitionsFactoryAccessible(DefinitionsFactory factory,
ServletContext servletContext)
{
servletContext.setAttribute(DEFINITIONS_FACTORY, 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
+ */
+ public Class applicationClass(String className) throws ClassNotFoundException
+ {
+ return Class.forName(className);
}
}
1.8 +7 -5
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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefinitionsUtil.java 21 Nov 2002 03:42:21 -0000 1.7
+++ DefinitionsUtil.java 17 Dec 2002 00:57:36 -0000 1.8
@@ -114,6 +114,7 @@
/**
* Set user debug level. This property control level of errors output.
* @deprecated Use commons-logging package instead.
+ * @param level
*/
public static void setUserDebugLevel( int level )
{
@@ -252,7 +253,8 @@
/**
* Create Definition factory from provided classname.
* Factory class must extends TilesDefinitionsFactory.
- * @deprecated No direct replacement. Use createDefinitionFactory.
+ * @deprecated No direct replacement. Use createDefinitionFactory
+ * {@link createDefinitionsFactory(ServletContext, DefinitionsFactoryConfig)}.
* @param classname Class name of the factory to create.
* @return newly created factory.
* @throws DefinitionsFactoryException If an error occur while initializing
factory
@@ -262,7 +264,7 @@
{
try
{
- Class factoryClass = RequestUtils.applicationClass(classname);
+ Class factoryClass = applicationClass(classname);
Object factory = factoryClass.newInstance();
// Backward compatibility : if factory classes implements old interface,
// provide appropriate wrapper
1.6 +48 -62
jakarta-struts/src/share/org/apache/struts/tiles/StrutsModulesTilesUtilImpl.java
Index: StrutsModulesTilesUtilImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/StrutsModulesTilesUtilImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StrutsModulesTilesUtilImpl.java 28 Nov 2002 07:13:39 -0000 1.5
+++ StrutsModulesTilesUtilImpl.java 17 Dec 2002 00:57:36 -0000 1.6
@@ -83,14 +83,12 @@
* <li>The method getFactory(...) return the factory for the current struts
* module.</li>
* <li>Methods doForward() and doInclude() use their counterparts in the
- * current RequestProcessor.</li>
+ * current RequestProcessor (todo).</li>
* <li>The method createFactory(...) creates a factory for the current module and
* stores it under appropriate property name.</li>
* </ul>
*/
-public class StrutsModulesTilesUtilImpl
- extends DefaultTilesUtilImpl
- implements TilesUtilInterface {
+public class StrutsModulesTilesUtilImpl extends DefaultTilesUtilImpl implements
TilesUtilInterface {
/** Commons Logging instance.*/
protected Log log = LogFactory.getLog(StrutsModulesTilesUtilImpl.class);
@@ -103,13 +101,11 @@
* @param response Current page response
* @param servletContext Current servlet context
*/
- public void doForward(
- String uri,
- HttpServletRequest request,
- HttpServletResponse response,
- ServletContext servletContext)
- throws IOException, ServletException {
- request.getRequestDispatcher(uri).include(request, response);
+ public void doForward( String uri,
+ HttpServletRequest request, HttpServletResponse
response, ServletContext servletContext)
+ throws IOException, ServletException
+ {
+ request.getRequestDispatcher(uri).include(request, response);
}
/**
@@ -121,26 +117,21 @@
* @param response Current page response
* @param servletContext Current servlet context
*/
- public void doInclude(
- String uri,
- HttpServletRequest request,
- HttpServletResponse response,
- ServletContext servletContext)
- throws IOException, ServletException {
- // modify uri
- request.getRequestDispatcher(uri).forward(request, response);
+ public void doInclude(String uri,
+ HttpServletRequest request, HttpServletResponse
response, ServletContext servletContext)
+ throws IOException, ServletException
+ { // modify uri
+ request.getRequestDispatcher(uri).forward(request, response);
}
/**
* Get definition factory from appropriate servlet context.
* @return Definitions factory or null if not found.
*/
- public DefinitionsFactory getDefinitionsFactory(
- ServletRequest request,
- ServletContext servletContext) {
- ModuleConfig moduleConfig = getModuleConfig((HttpServletRequest) request,
servletContext);
- return (DefinitionsFactory) servletContext.getAttribute(
- DEFINITIONS_FACTORY + moduleConfig.getPrefix());
+ public DefinitionsFactory getDefinitionsFactory( ServletRequest request,
ServletContext servletContext)
+ {
+ ModuleConfig moduleConfig = getModuleConfig((HttpServletRequest) request,
servletContext);
+ return (DefinitionsFactory) servletContext.getAttribute( DEFINITIONS_FACTORY +
moduleConfig.getPrefix());
}
/**
@@ -156,17 +147,15 @@
* @return newly created factory of type ConfigurableDefinitionsFactory.
* @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;
+ 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;
}
/**
@@ -175,23 +164,20 @@
* @param factory Factory to make accessible
* @param servletContext Current servlet context
*/
- protected void makeDefinitionsFactoryAccessible(
- DefinitionsFactory factory,
- ServletContext servletContext) {
- String prefix = factory.getConfig().getFactoryName();
- servletContext.setAttribute(DEFINITIONS_FACTORY + prefix, factory);
+ protected void makeDefinitionsFactoryAccessible( DefinitionsFactory factory,
ServletContext servletContext)
+ {
+ String prefix = factory.getConfig().getFactoryName();
+ servletContext.setAttribute(DEFINITIONS_FACTORY + prefix, factory);
}
/**
* Get Tiles request processor associated to the current module.
*/
- protected TilesRequestProcessor getRequestProcessor(
- HttpServletRequest request,
- ServletContext servletContext) {
- ModuleConfig moduleConfig = getModuleConfig(request, servletContext);
- return (TilesRequestProcessor) servletContext.getAttribute(
- Globals.REQUEST_PROCESSOR_KEY + moduleConfig.getPrefix());
- }
+ protected TilesRequestProcessor getRequestProcessor( HttpServletRequest request,
ServletContext servletContext)
+ {
+ ModuleConfig moduleConfig = getModuleConfig(request, servletContext);
+ return (TilesRequestProcessor) servletContext.getAttribute(
Globals.REQUEST_PROCESSOR_KEY + moduleConfig.getPrefix());
+ }
/**
* Get the current ModuleConfig.
@@ -199,17 +185,17 @@
* Lookup in the request, and do selectModule if not found. The side effect
* is that the ModuleConfig object is set in the request if it was not present.
*/
- protected ModuleConfig getModuleConfig(
- HttpServletRequest request,
- ServletContext servletContext) {
- ModuleConfig moduleConfig = RequestUtils.getModuleConfig(request,
servletContext);
- if (moduleConfig == null) {
- // ModuleConfig not found in current request. Select it.
- RequestUtils.selectModule(request, servletContext);
- moduleConfig = RequestUtils.getModuleConfig(request, servletContext);
- }
-
- return moduleConfig;
+ protected ModuleConfig getModuleConfig( HttpServletRequest request,
ServletContext servletContext)
+ {
+ ModuleConfig moduleConfig = RequestUtils.getModuleConfig(request, servletContext);
+ if (moduleConfig == null)
+ {
+ // ModuleConfig not found in current request. Select it.
+ RequestUtils.selectModule(request, servletContext);
+ moduleConfig = RequestUtils.getModuleConfig(request, servletContext);
}
+
+ return moduleConfig;
+ }
}
1.15 +9 -5
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.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- TilesPlugin.java 28 Nov 2002 07:13:39 -0000 1.14
+++ TilesPlugin.java 17 Dec 2002 00:57:36 -0000 1.15
@@ -120,7 +120,7 @@
public boolean isModuleAware() {
return moduleAware;
}
-
+
/**
* Set the module aware flag.
* true: user want a single factory instance
@@ -158,7 +158,11 @@
// Set the module name in the config. This name will be used to compute
// the name under which the factory is stored.
factoryConfig.setFactoryName(config.getPrefix());
- } else { // We want one single shared instance. Check if it already exists
in servlet context.
+ } else {
+
+ // Use appropriate TilesUtil implementation
+ TilesUtil.setTilesUtil(new TilesUtilStrutsSingleFactory());
+ // We want one single shared instance. Check if it already exists in
servlet context.
definitionFactory =
TilesUtil.getDefaultDefinitionsFactory(servlet.getServletContext());
if (definitionFactory != null) {
if (log.isInfoEnabled())
1.3 +16 -4 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TilesUtil.java 16 Nov 2002 06:04:28 -0000 1.2
+++ TilesUtil.java 17 Dec 2002 00:57:36 -0000 1.3
@@ -74,6 +74,7 @@
/**
* Class containing utilities for Tiles.
+ *
*/
public class TilesUtil
{
@@ -219,5 +220,16 @@
}
}
-
+ /**
+ * 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
+ */
+ public static Class applicationClass(String className) throws
ClassNotFoundException
+ {
+ return tilesUtilImpl.applicationClass(className);
+ }
}
1.3 +14 -3
jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilInterface.java
Index: TilesUtilInterface.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesUtilInterface.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TilesUtilInterface.java 16 Nov 2002 06:04:28 -0000 1.2
+++ TilesUtilInterface.java 17 Dec 2002 00:57:36 -0000 1.3
@@ -132,4 +132,15 @@
public DefinitionsFactory createDefinitionsFactory(ServletContext servletContext,
DefinitionsFactoryConfig factoryConfig)
throws DefinitionsFactoryException;
+ /**
+ * 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
+ */
+ public Class applicationClass(String className)
+ throws ClassNotFoundException;
+
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>