luehe       2005/04/19 11:30:21

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardContext.java
  Log:
  No longer ignore the wrapper class passed to Context.setWrapperClass().
  
  I think the original intent of this method was to pass a class that
  implements the Wrapper interface. However, there are too many
  dependencies in the code right now that assume the children of
  StandardContext to be instances of StandardWrapper (instead of
  Wrapper), which means the class passed to StandardContext.setWrapperClass()
  really must be a subclass of StandardWrapper.
  
  Revision  Changes    Path
  1.174     +32 -8     
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.173
  retrieving revision 1.174
  diff -u -r1.173 -r1.174
  --- StandardContext.java      25 Mar 2005 18:12:48 -0000      1.173
  +++ StandardContext.java      19 Apr 2005 18:30:21 -0000      1.174
  @@ -549,7 +549,8 @@
       /**
        * Java class name of the Wrapper class implementation we use.
        */
  -    private String wrapperClass = "org.apache.catalina.core.StandardWrapper";
  +    private String wrapperClassName = StandardWrapper.class.getName();
  +    private Class wrapperClass = null;
   
   
       /**
  @@ -1647,7 +1648,7 @@
        */
       public String getWrapperClass() {
   
  -        return (this.wrapperClass);
  +        return (this.wrapperClassName);
   
       }
   
  @@ -1656,12 +1657,25 @@
        * Set the Java class name of the Wrapper implementation used
        * for servlets registered in this Context.
        *
  -     * @param wrapperClass The new wrapper class
  +     * @param wrapperClassName The new wrapper class name
  +     *
  +     * @throws IllegalArgumentException if the specified wrapper class
  +     * cannot be found or is not a subclass of StandardWrapper
        */
  -    public void setWrapperClass(String wrapperClass) {
  +    public void setWrapperClass(String wrapperClassName) {
   
  -        this.wrapperClass = wrapperClass;
  +        this.wrapperClassName = wrapperClassName;
   
  +        try {
  +            wrapperClass = Class.forName(wrapperClassName);         
  +            if (!StandardWrapper.class.isAssignableFrom(wrapperClass)) {
  +                throw new IllegalArgumentException(
  +                    sm.getString("standardContext.invalidWrapperClass",
  +                                 wrapperClassName));
  +            }
  +        } catch (ClassNotFoundException cnfe) {
  +            throw new IllegalArgumentException(cnfe.getMessage());
  +        }
       }
   
   
  @@ -2372,8 +2386,18 @@
        * will have been called, but no properties will have been set.
        */
       public Wrapper createWrapper() {
  -        //log.info( "Create wrapper" );
  -        Wrapper wrapper = new StandardWrapper();
  +
  +        Wrapper wrapper = null;
  +        if (wrapperClass != null) {
  +            try {
  +                wrapper = (Wrapper) wrapperClass.newInstance();
  +            } catch (Throwable t) {
  +                log.error("createWrapper", t);
  +                return (null);
  +            }
  +        } else {
  +            wrapper = new StandardWrapper();
  +        }
   
           synchronized (instanceListeners) {
               for (int i = 0; i < instanceListeners.length; i++) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to