Author: craigmcc Date: Sun Apr 3 14:37:32 2005 New Revision: 159967 URL: http://svn.apache.org/viewcvs?view=rev&rev=159967 Log: Support "init" and "destroy" commands (in the "shale" catalog) so that application startup and shutdown processing can be extensibe.
Modified: struts/shale/trunk/core-library/build.xml struts/shale/trunk/core-library/src/java/org/apache/shale/Bundle.properties struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java struts/shale/trunk/core-library/src/java/org/apache/shale/faces/shale-config.xml Modified: struts/shale/trunk/core-library/build.xml URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/build.xml?view=diff&r1=159966&r2=159967 ============================================================================== --- struts/shale/trunk/core-library/build.xml (original) +++ struts/shale/trunk/core-library/build.xml Sun Apr 3 14:37:32 2005 @@ -140,10 +140,10 @@ <!-- Conditional Processing Flags --> <available property="jsfri.present" classname="com.sun.faces.RIConstants" - classpathref="compile.classpath"/> + classpath="${jsf-impl.jar}"/> <available property="myfaces.present" - classname="net.sourceforge.myfaces.config.MyfacesConfig" - classpathref="compile.classpath"/> + classname="org.apache.myfaces.config.MyfacesConfig" + classpath="${jsf-impl.jar}"/> <condition property="spring.present"> <and> <available classname="org.springframework.core.Constants" Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/Bundle.properties URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/Bundle.properties?view=diff&r1=159966&r2=159967 ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/Bundle.properties (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/Bundle.properties Sun Apr 3 14:37:32 2005 @@ -18,7 +18,9 @@ # org.apache.shale.application.ShaleApplicationFilter filter.creatingCatalog=Creating catalog {0} +filter.destroyException=Exception during init command filter.finalizing=Finalizing Shale Application Filter +filter.initException=Exception occurred during init command filter.initializing=Initializing Shale Application Filter filter.parsingResource=Parsing default resource {0} filter.vcmAccess=ViewControllerMapper class {0} does not have a public no-args constructor Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java?view=diff&r1=159966&r2=159967 ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleApplicationFilter.java Sun Apr 3 14:37:32 2005 @@ -37,6 +37,8 @@ import org.apache.commons.chain.Command; import org.apache.commons.chain.config.ConfigParser; import org.apache.commons.chain.impl.CatalogBase; +import org.apache.commons.chain.web.WebContext; +import org.apache.commons.chain.web.servlet.ServletWebContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.shale.ViewControllerMapper; @@ -106,6 +108,20 @@ /** + * <p>The name of the <code>Command</code> to execute during + * application shutdown.</p> + */ + public static final String COMMAND_DESTROY = "destroy"; + + + /** + * <p>The name of the <code>Command</code> to execute during + * application startup.</p> + */ + public static final String COMMAND_INIT = "init"; + + + /** * <p>The name of the <code>Command</code> (in the <code>Catalog</code> * named by <code>CATALOG_NAME</code>) that performs the standard * application scope request processing.</p> @@ -186,6 +202,16 @@ log.info(messages.getMessage("filter.finalizing")); + // Execute the "destroy" command in the "shale" catalog (if any) + Command command = catalog.getCommand(COMMAND_DESTROY); + if (command != null) { + WebContext webContext = new ServletWebContext(context, null, null); + try { + command.execute(webContext); + } catch (Exception e) { + log.error(messages.getMessage("filter.destroyException"), e); + } + } // Clean up JavaServer Faces integration linkages if (phaseListener != null) { @@ -255,11 +281,23 @@ // Look up the "shale" catalog and ensure "standard" is defined try { - this.catalog = getCatalog(); + catalog = getCatalog(); } catch (ServletException e) { throw e; } catch (Exception e) { throw new ServletException(e); + } + + // Execute the "init" command in the "shale" catalog (if any) + Command command = catalog.getCommand(COMMAND_INIT); + if (command != null) { + WebContext webContext = new ServletWebContext(context, null, null); + try { + command.execute(webContext); + } catch (Exception e) { + log.error(messages.getMessage("filter.initException"), e); + throw new ServletException(e); + } } } Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/faces/shale-config.xml URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/faces/shale-config.xml?view=diff&r1=159966&r2=159967 ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/faces/shale-config.xml (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/faces/shale-config.xml Sun Apr 3 14:37:32 2005 @@ -34,6 +34,18 @@ <catalog name="shale"> + <!-- ================== Application Shutdown ============================= --> + + <chain name="destroy"> + + </chain> + + <!-- ====================== Appication Startup =========================== --> + + <chain name="init"> + + </chain> + <!-- ===================== Remote Requests =============================== --> <chain name="remote"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]