Author: germuska Date: Wed Apr 27 18:52:39 2005 New Revision: 165083 URL: http://svn.apache.org/viewcvs?rev=165083&view=rev Log: Some simple refactorings to better enable use of a CatalogFactory initialized by some means other than the static digester based parsing which is built in to commons-chain.
Modified: struts/core/trunk/src/share/org/apache/struts/chain/ComposableRequestProcessor.java Modified: struts/core/trunk/src/share/org/apache/struts/chain/ComposableRequestProcessor.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/ComposableRequestProcessor.java?rev=165083&r1=165082&r2=165083&view=diff ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/ComposableRequestProcessor.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/ComposableRequestProcessor.java Wed Apr 27 18:52:39 2005 @@ -64,6 +64,13 @@ /** + * <p>The [EMAIL PROTECTED] CatalogFactory} from which catalog containing the the + * base request-processing [EMAIL PROTECTED] Command} will be retrieved.</p> + */ + protected CatalogFactory catalogFactory = null; + + + /** * <p>The [EMAIL PROTECTED] Catalog} containing all of the available command chains * for this module. */ @@ -92,6 +99,7 @@ public void destroy() { super.destroy(); + catalogFactory = null; catalog = null; command = null; @@ -114,10 +122,12 @@ + moduleConfig.getPrefix() + "'"); super.init(servlet, moduleConfig); + initCatalogFactory(servlet, moduleConfig); + ControllerConfig controllerConfig = moduleConfig.getControllerConfig(); String catalogName = controllerConfig.getCatalog(); - catalog = CatalogFactory.getInstance().getCatalog(catalogName); + catalog = this.catalogFactory.getCatalog(catalogName); if (catalog == null) { throw new ServletException("Cannot find catalog '" + catalogName + "'"); @@ -134,6 +144,22 @@ /** + * <p>Establish the <code>CatalogFactory</code> which will be used to look up + * the catalog which has the request processing command.</p> + * <p>The base implementation simply calls <code>CatalogFactory.getInstance()</code>, + * unless the <code>catalogFactory</code> property of this object has already been set, + * in which case it is not changed.</p> + * @param servlet + * @param moduleConfig + */ + protected void initCatalogFactory(ActionServlet servlet, ModuleConfig moduleConfig) { + if (this.catalogFactory != null) return; + this.catalogFactory = CatalogFactory.getInstance(); + + } + + + /** * <p>Process an <code>HttpServletRequest</code> and create the * corresponding <code>HttpServletResponse</code>.</p> * @@ -199,7 +225,16 @@ } - + /** + * <p>Set the <code>CatalogFactory</code> instance which should be used to find + * the request-processing command. In the base implementation, if this value is not + * already set, then it will be initialized when [EMAIL PROTECTED] initCatalogFactory} is called. + * </p> + * @param catalogFactory + */ + public void setCatalogFactory(CatalogFactory catalogFactory) { + this.catalogFactory = catalogFactory; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]