FileDocCategorySizeDatePackage
ContextRuleSet.javaAPI DocGlassfish v2 API12038Fri May 04 22:32:28 BST 2007org.apache.catalina.startup

ContextRuleSet

public class ContextRuleSet extends com.sun.org.apache.commons.digester.RuleSetBase

RuleSet for processing the contents of a Context or DefaultContext definition element. To enable parsing of a DefaultContext, be sure to specify a prefix that ends with "/Default".

author
Craig R. McClanahan
version
$Revision: 1.5 $ $Date: 2007/05/05 05:32:28 $

Fields Summary
protected boolean
create
Should the context be created.
protected String
prefix
The matching pattern prefix to use for recognizing our elements.
Constructors Summary
public ContextRuleSet()
Construct an instance of this RuleSet with the default matching pattern prefix.



    // ------------------------------------------------------------ Constructor


                     
      

        this("");

    
public ContextRuleSet(String prefix)
Construct an instance of this RuleSet with the specified matching pattern prefix.

param
prefix Prefix for matching pattern rules (including the trailing slash character)


        super();
        this.namespaceURI = null;
        this.prefix = prefix;

    
public ContextRuleSet(String prefix, boolean create)
Construct an instance of this RuleSet with the specified matching pattern prefix.

param
prefix Prefix for matching pattern rules (including the trailing slash character)


        super();
        this.namespaceURI = null;
        this.prefix = prefix;
        this.create = create;

    
Methods Summary
public voidaddRuleInstances(com.sun.org.apache.commons.digester.Digester digester)

Add the set of Rule instances defined in this RuleSet to the specified Digester instance, associating them with our namespace URI (if any). This method should only be called by a Digester instance.

param
digester Digester instance to which the new Rule instances should be added.

        
        if (create) {            
            digester.addObjectCreate(prefix + "Context",
                    "org.apache.catalina.core.StandardContext", "className");
            digester.addSetProperties(prefix + "Context");
        } else {            
            digester.addRule(prefix + "Context", new SetContextPropertiesRule());
        }
        
        if (create) {            
            digester.addRule(prefix + "Context",
                             new LifecycleListenerRule
                                 (digester,
                                  "org.apache.catalina.startup.ContextConfig",
                                  "configClass"));
            digester.addSetNext(prefix + "Context",
                                "addChild",
                                "org.apache.catalina.Container");
        }                        
        digester.addCallMethod(prefix + "Context/InstanceListener",
                               "addInstanceListener", 0);
                            
        digester.addObjectCreate(prefix + "Context/Listener",
                                 null, // MUST be specified in the element
                                 "className");
        digester.addSetProperties(prefix + "Context/Listener");
        digester.addSetNext(prefix + "Context/Listener",
                            "addLifecycleListener",
                            "org.apache.catalina.LifecycleListener");
                            
        digester.addObjectCreate(prefix + "Context/Loader",
                            "org.apache.catalina.loader.WebappLoader",
                            "className"); 
        digester.addSetProperties(prefix + "Context/Loader");
        digester.addSetNext(prefix + "Context/Loader",
                            "setLoader",
                            "org.apache.catalina.Loader");

        digester.addObjectCreate(prefix + "Context/Manager",
                                 "org.apache.catalina.session.StandardManager",
                                 "className");
        digester.addSetProperties(prefix + "Context/Manager");
        digester.addSetNext(prefix + "Context/Manager",
                            "setManager",
                            "org.apache.catalina.Manager");

        digester.addObjectCreate(prefix + "Context/Manager/Store",
                                 null, // MUST be specified in the element
                                 "className");
        digester.addSetProperties(prefix + "Context/Manager/Store");
        digester.addSetNext(prefix + "Context/Manager/Store",
                            "setStore",
                            "org.apache.catalina.Store");

        digester.addObjectCreate(prefix + "Context/Parameter",
                                 "org.apache.catalina.deploy.ApplicationParameter");
        digester.addSetProperties(prefix + "Context/Parameter");
        digester.addSetNext(prefix + "Context/Parameter",
                            "addApplicationParameter",
                            "org.apache.catalina.deploy.ApplicationParameter");

        digester.addObjectCreate(prefix + "Context/Realm",
                                 null, // MUST be specified in the element
                                 "className");
        digester.addSetProperties(prefix + "Context/Realm");
        digester.addSetNext(prefix + "Context/Realm",
                            "setRealm",
                            "org.apache.catalina.Realm");

        digester.addObjectCreate(prefix + "Context/Resources",
                                 "org.apache.naming.resources.FileDirContext",
                                 "className");
        digester.addSetProperties(prefix + "Context/Resources");
        digester.addSetNext(prefix + "Context/Resources",
                            "setResources",
                            "javax.naming.directory.DirContext");

        digester.addObjectCreate(prefix + "Context/ResourceLink",
                                 "org.apache.catalina.deploy.ContextResourceLink");
        digester.addSetProperties(prefix + "Context/ResourceLink");
        digester.addSetNext(prefix + "Context/ResourceLink",
                            "addResourceLink",
                            "org.apache.catalina.deploy.ContextResourceLink");

        digester.addObjectCreate(prefix + "Context/Valve",
                                 null, // MUST be specified in the element
                                 "className");
        digester.addSetProperties(prefix + "Context/Valve");
        digester.addSetNext(prefix + "Context/Valve",
                            "addValve",
                            "org.apache.catalina.Valve");
        digester.addCallMethod(prefix + "Context/WatchedResource",
                               "addWatchedResource", 0);

        digester.addCallMethod(prefix + "Context/WrapperLifecycle",
                               "addWrapperLifecycle", 0);

        digester.addCallMethod(prefix + "Context/WrapperListener",
                               "addWrapperListener", 0);

    
protected booleanisDefaultContext()
Are we processing a DefaultContext element?


        return (prefix.endsWith("/Default"));