1 /* 2 * Copyright 1999-2001,2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18 package org.apache.commons.workflow.web; 19 20 21 import org.apache.commons.digester.Digester; 22 import org.apache.commons.workflow.base.BaseRuleSet; 23 24 25 /** 26 * <p><strong>RuleSet</strong> for the Step definitions supported by the 27 * <em>web</em> library. This library is normally associated with the 28 * following namespace URI:</p> 29 * <pre> 30 * http://commons.apache.org/workflow/web 31 * </pre> 32 * 33 * @author Craig R. McClanahan 34 * @version $Revision: 561366 $ $Date: 2007-07-31 16:58:29 +0100 (Tue, 31 Jul 2007) $ 35 */ 36 37 public class WebRuleSet extends BaseRuleSet { 38 39 40 // ------------------------------------------------------------ Constructor 41 42 43 /** 44 * Construct a default instance of the <code>RuleSet</code>. 45 */ 46 public WebRuleSet() { 47 48 super(); 49 setNamespaceURI("http://commons.apache.org/workflow/web"); 50 51 } 52 53 54 // --------------------------------------------------------- Public Methods 55 56 57 /** 58 * <p>Add the set of Rule instances defined in this RuleSet to the 59 * specified <code>Digester</code> instance, associating them with 60 * our namespace URI (if any). This method should only be called 61 * by a Digester instance.</p> 62 * 63 * @param digester Digester instance to which the new Rule instances 64 * should be added. 65 */ 66 public void addRuleInstances(Digester digester) { 67 68 // Add rules for each Step defined in this package 69 addStandardStep(digester, "forward", 70 "org.apache.commons.workflow.web.ForwardStep"); 71 addStandardStep(digester, "goto", 72 "org.apache.commons.workflow.web.GotoStep"); 73 if (isServlet23()) { 74 addStandardStep(digester, "include", 75 "org.apache.commons.workflow.web.IncludeStep23"); 76 } 77 addStandardStep(digester, "populate", 78 "org.apache.commons.workflow.web.PopulateStep"); 79 80 // Add rules for all variations on descriptors being matched 81 addStandardDescriptor(digester, "descriptor"); // Standard version 82 83 } 84 85 86 // ------------------------------------------------------ Protected Methods 87 88 89 /** 90 * Are we executing in a Servlet 2.3 (or later) environment? 91 */ 92 protected boolean isServlet23() { 93 94 try { 95 Class.forName("javax.servlet.Filter"); // 2.3-or-later class 96 return (true); 97 } catch (ClassNotFoundException e) { 98 return (false); 99 } 100 101 } 102 103 104 }