billbarker    2002/11/21 20:44:10

  Modified:    catalina/src/share/org/apache/catalina/mbeans
                        MBeanUtils.java
  Log:
  Relaxing the restrictions on creating Valve MBeans.
  
  There is no functional change for Catalina Valves.  For custom Valves, they only 
need to implement 'Contained', not extend ValveBase.  At the very least, throwing a 
checked-exception is much better then throwing the non-checked "ClassCastException".
  
  Revision  Changes    Path
  1.46      +13 -6     
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java
  
  Index: MBeanUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- MBeanUtils.java   8 Nov 2002 11:49:29 -0000       1.45
  +++ MBeanUtils.java   22 Nov 2002 04:44:10 -0000      1.46
  @@ -105,7 +105,6 @@
   import org.apache.catalina.deploy.ContextResourceLink;
   import org.apache.catalina.deploy.NamingResources;
   import org.apache.catalina.deploy.ResourceParams;
  -import org.apache.catalina.valves.ValveBase;
   import org.apache.commons.beanutils.PropertyUtils;
   import org.apache.commons.modeler.ManagedBean;
   import org.apache.commons.modeler.Registry;
  @@ -1571,7 +1570,15 @@
           throws MalformedObjectNameException {
   
           ObjectName name = null;
  -        Container container = ((ValveBase)valve).getContainer();
  +        Container container = null;
  +        if( valve instanceof Contained ) {
  +            container = ((Contained)valve).getContainer();
  +        }
  +        if( container == null ) {
  +            throw new MalformedObjectNameException(
  +                               "Cannot create mbean for non-contained valve " +
  +                               valve);
  +        }
   
           if (container instanceof Engine) {
               Service service = ((Engine)container).getService();
  
  
  

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

Reply via email to