View | Details | Raw Unified | Return to bug 51418
Collapse All | Expand All

(-)java/org/apache/catalina/startup/Tomcat.java (+55 lines)
Lines 83-88 Link Here
83
 * use if you have a webapp with a web.xml file, but it is 
83
 * use if you have a webapp with a web.xml file, but it is 
84
 * optional - you can use your own servlets.
84
 * optional - you can use your own servlets.
85
 * 
85
 * 
86
 * There are a variety of 'add' methods to configure servlets and webapps. These methods, by default,
87
 * create a simple in-memory security realm and apply it. If you need more complex security processing, 
88
 * you can define a subclass of this class.
89
 * 
90
 * This class provides a set of convenience methods for configuring webapp contexts, all overloads
91
 * of the method <pre>addWebapp</pre>. These methods create a webapp context, configure it,
92
 * and then add it to a {@link Host}. They do not use a global default web.xml; rather, they add a 
93
 * lifecycle listener that adds the standard DefaultServlet, JSP processing, and welcome files.
94
 * 
95
 * In complex cases, you may prefer to use the ordinary Tomcat
96
 * API to create webapp contexts; for example, you might need to install a custom Loader before
97
 * the call to {@link Host#addChild(Container)}. To replicate the basic behavior of the <pre>addWebapp</pre>
98
 * methods, you may want to call three methods of this class: {@link #getDefaultRealm()}, 
99
 * {@link #noDefaultWebXmlPath()}, and {@link #getDefaultWebXmlListener()}. 
100
 * 
101
 * {@link #getDefaultRealm()} returns the simple security realm.
102
 * 
103
 * {@link #getDefaultWebXmlListener()} returns a {@link LifecycleListener} that adds the standard
104
 * DefaultServlet, JSP processing, and welcome files. If you add this listener, you must prevent
105
 * Tomcat from applying any standard global web.xml with ...
106
 * 
107
 * {@link #noDefaultWebXmlPath()} returns a dummy pathname to configure to prevent {@link ContextConfig}
108
 * from trying to apply a global web.xml file. 
109
 * 
86
 * This class provides a main() and few simple CLI arguments,
110
 * This class provides a main() and few simple CLI arguments,
87
 * see setters for doc. It can be used for simple tests and
111
 * see setters for doc. It can be used for simple tests and
88
 * demo.
112
 * demo.
Lines 511-516 Link Here
511
535
512
        return ctx;
536
        return ctx;
513
    }
537
    }
538
    
539
    /**
540
     * Return a listener that provides the required configuration items for JSP processing.
541
     * from the standard Tomcat global web.xml. Pass this to {@link Context#addLifecycleListener(LifecycleListener)}
542
     * and then pass the result of {@link #noDefaultWebXmlPath()} to 
543
     * {@link ContextConfig#setDefaultWebXml(String)}. 
544
     * @return a listener object that configures default JSP processing.
545
     */
546
    public LifecycleListener getDefaultWebXmlListener() {
547
    	return new DefaultWebXmlListener();
548
    }
549
    
550
    /**
551
     * @return a pathname to pass to {@link ContextConfig#setDefaultWebXml(String)} when using
552
     * {@link #getDefaultWebXmlListener()}.
553
     */
554
    public String noDefaultWebXmlPath() {
555
    	return "org/apache/catalin/startup/NO_DEFAULT_XML";
556
    }
557
    
558
    /**
559
     * For complex configurations, this accessor allows callers of this class
560
     * to obtain the simple realm created by default.
561
     * @return the simple in-memory realm created by default.
562
     */
563
    public Realm getDefaultRealm() {
564
        if (defaultRealm == null) {
565
            initSimpleAuth();
566
        }
567
    	return defaultRealm;
568
    }
514
569
515
570
516
    // ---------- Helper methods and classes -------------------
571
    // ---------- Helper methods and classes -------------------

Return to bug 51418