Example #1
0
 /** Create the digester which will be used to parse context config files. */
 protected static Digester createDigester() {
   Digester digester = new Digester();
   digester.setValidating(false);
   // Add object creation rule
   digester.addObjectCreate("Context", "org.apache.catalina.core.StandardContext", "className");
   // Set the properties on that object (it doesn't matter if extra
   // properties are set)
   digester.addSetProperties("Context");
   return (digester);
 }
  /** Create and configure the Digester we will be using for shutdown. */
  protected Digester createStopDigester() {

    // Initialize the digester
    Digester digester = new Digester();

    // Configure the rules we need for shutting down
    digester.addObjectCreate("Server", "org.apache.catalina.core.StandardServer", "className");
    digester.addSetProperties("Server");
    digester.addSetNext("Server", "setServer", "org.apache.catalina.Server");

    return (digester);
  }
Example #3
0
  /** Create and configure the Digester we will be using for startup. */
  protected Digester createStartDigester() {
    long t1 = System.currentTimeMillis();
    // Initialize the digester
    Digester digester = new Digester();
    digester.setValidating(false);
    digester.setRulesValidation(true);
    HashMap<Class<?>, List<String>> fakeAttributes = new HashMap<Class<?>, List<String>>();
    ArrayList<String> attrs = new ArrayList<String>();
    attrs.add("className");
    fakeAttributes.put(Object.class, attrs);
    digester.setFakeAttributes(fakeAttributes);
    digester.setUseContextClassLoader(true);

    // Configure the actions we will be using
    digester.addObjectCreate("Server", "org.apache.catalina.core.StandardServer", "className");
    digester.addSetProperties("Server");
    digester.addSetNext("Server", "setServer", "org.apache.catalina.Server");

    digester.addObjectCreate(
        "Server/GlobalNamingResources", "org.apache.catalina.deploy.NamingResources");
    digester.addSetProperties("Server/GlobalNamingResources");
    digester.addSetNext(
        "Server/GlobalNamingResources",
        "setGlobalNamingResources",
        "org.apache.catalina.deploy.NamingResources");

    digester.addObjectCreate(
        "Server/Listener",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties("Server/Listener");
    digester.addSetNext(
        "Server/Listener", "addLifecycleListener", "org.apache.catalina.LifecycleListener");

    digester.addObjectCreate(
        "Server/Service", "org.apache.catalina.core.StandardService", "className");
    digester.addSetProperties("Server/Service");
    digester.addSetNext("Server/Service", "addService", "org.apache.catalina.Service");

    digester.addObjectCreate(
        "Server/Service/Listener",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties("Server/Service/Listener");
    digester.addSetNext(
        "Server/Service/Listener", "addLifecycleListener", "org.apache.catalina.LifecycleListener");

    // Executor
    digester.addObjectCreate(
        "Server/Service/Executor", "org.apache.catalina.core.StandardThreadExecutor", "className");
    digester.addSetProperties("Server/Service/Executor");

    digester.addSetNext("Server/Service/Executor", "addExecutor", "org.apache.catalina.Executor");

    digester.addRule("Server/Service/Connector", new ConnectorCreateRule());
    digester.addRule(
        "Server/Service/Connector", new SetAllPropertiesRule(new String[] {"executor"}));
    digester.addSetNext(
        "Server/Service/Connector", "addConnector", "org.apache.catalina.connector.Connector");

    digester.addObjectCreate(
        "Server/Service/Connector/Listener",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties("Server/Service/Connector/Listener");
    digester.addSetNext(
        "Server/Service/Connector/Listener",
        "addLifecycleListener",
        "org.apache.catalina.LifecycleListener");

    // Add RuleSets for nested elements
    digester.addRuleSet(new NamingRuleSet("Server/GlobalNamingResources/"));
    digester.addRuleSet(new EngineRuleSet("Server/Service/"));
    digester.addRuleSet(new HostRuleSet("Server/Service/Engine/"));
    digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/"));
    addClusterRuleSet(digester, "Server/Service/Engine/Host/Cluster/");
    digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/Context/"));

    // When the 'engine' is found, set the parentClassLoader.
    digester.addRule("Server/Service/Engine", new SetParentClassLoaderRule(parentClassLoader));
    addClusterRuleSet(digester, "Server/Service/Engine/Cluster/");

    long t2 = System.currentTimeMillis();
    if (log.isDebugEnabled()) {
      log.debug("Digester for server.xml created " + (t2 - t1));
    }
    return (digester);
  }
Example #4
0
  /**
   * Add the set of Rule instances defined in this RuleSet to the specified <code>Digester</code>
   * 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.
   */
  @Override
  public void addRuleInstances(Digester digester) {
    // Cluster configuration start
    digester.addObjectCreate(
        prefix + "Manager",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(prefix + "Manager");
    digester.addSetNext(
        prefix + "Manager", "setManagerTemplate", "org.apache.catalina.ha.ClusterManager");

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

    String channelPrefix = prefix + "Channel/";

    // channel properties
    digester.addObjectCreate(
        channelPrefix + "Membership",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(channelPrefix + "Membership");
    digester.addSetNext(
        channelPrefix + "Membership",
        "setMembershipService",
        "org.apache.catalina.tribes.MembershipService");

    digester.addObjectCreate(
        channelPrefix + "Sender",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(channelPrefix + "Sender");
    digester.addSetNext(
        channelPrefix + "Sender", "setChannelSender", "org.apache.catalina.tribes.ChannelSender");

    digester.addObjectCreate(
        channelPrefix + "Sender/Transport",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(channelPrefix + "Sender/Transport");
    digester.addSetNext(
        channelPrefix + "Sender/Transport",
        "setTransport",
        "org.apache.catalina.tribes.transport.MultiPointSender");

    digester.addObjectCreate(
        channelPrefix + "Receiver",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(channelPrefix + "Receiver");
    digester.addSetNext(
        channelPrefix + "Receiver",
        "setChannelReceiver",
        "org.apache.catalina.tribes.ChannelReceiver");

    digester.addObjectCreate(
        channelPrefix + "Interceptor",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(channelPrefix + "Interceptor");
    digester.addSetNext(
        channelPrefix + "Interceptor",
        "addInterceptor",
        "org.apache.catalina.tribes.ChannelInterceptor");

    digester.addObjectCreate(
        channelPrefix + "Interceptor/Member",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(channelPrefix + "Interceptor/Member");
    digester.addSetNext(
        channelPrefix + "Interceptor/Member",
        "addStaticMember",
        "org.apache.catalina.tribes.Member");

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

    digester.addObjectCreate(
        prefix + "Deployer",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(prefix + "Deployer");
    digester.addSetNext(
        prefix + "Deployer", "setClusterDeployer", "org.apache.catalina.ha.ClusterDeployer");

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

    digester.addObjectCreate(
        prefix + "ClusterListener",
        null, // MUST be specified in the element
        "className");
    digester.addSetProperties(prefix + "ClusterListener");
    digester.addSetNext(
        prefix + "ClusterListener", "addClusterListener", "org.apache.catalina.ha.ClusterListener");
    // Cluster configuration end
  }