manveen     02/04/11 00:44:22

  Modified:    webapps/admin/WEB-INF/classes/org/apache/webapp/admin
                        TomcatTreeBuilder.java Lists.java
  Log:
  Added valve nodes to the tree control.
  
  Revision  Changes    Path
  1.26      +39 -6     
jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java
  
  Index: TomcatTreeBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TomcatTreeBuilder.java    4 Apr 2002 21:52:25 -0000       1.25
  +++ TomcatTreeBuilder.java    11 Apr 2002 07:44:22 -0000      1.26
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v
 1.25 2002/04/04 21:52:25 manveen Exp $
  - * $Revision: 1.25 $
  - * $Date: 2002/04/04 21:52:25 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v
 1.26 2002/04/11 07:44:22 manveen Exp $
  + * $Revision: 1.26 $
  + * $Date: 2002/04/11 07:44:22 $
    *
    * ====================================================================
    *
  @@ -93,7 +93,7 @@
    *
    * @author Jazmin Jonson
    * @author Manveen Kaur
  - * @version $Revision: 1.25 $ $Date: 2002/04/04 21:52:25 $
  + * @version $Revision: 1.26 $ $Date: 2002/04/11 07:44:22 $
    */
   
   
  @@ -210,6 +210,7 @@
               getHosts(serviceNode, serviceName);
               getLoggers(serviceNode, serviceName);
               getRealms(serviceNode, serviceName);
  +            getValves(serviceNode, serviceName);
           }
   
       }
  @@ -280,6 +281,7 @@
               getContexts(hostNode, hostName);            
               getLoggers(hostNode, hostName);
               getRealms(hostNode, hostName);
  +            getValves(hostNode, hostName);
           }
   
       }    
  @@ -315,8 +317,8 @@
               hostNode.addChild(contextNode);
               getLoggers(contextNode, contextName);
               getRealms(contextNode, contextName);
  +            getValves(contextNode, contextName);
           }
  -
       }
       
       
  @@ -382,6 +384,37 @@
                                       false);
               containerNode.addChild(realmNode);
           }
  +        
  +    }   
  +        
  +   /**
  +     * Append nodes for any defined valves for the specified container.
  +     *
  +     * @param containerNode Container node for the tree control
  +     * @param containerName Object name of the parent container
  +     *
  +     * @exception Exception if an exception occurs building the tree
  +     */
  +    public void getValves(TreeControlNode containerNode,
  +                          String containerName) throws Exception {
   
  -    }    
  +        Iterator valveNames =
  +                Lists.getValves(mBServer, containerName).iterator();        
  +        while (valveNames.hasNext()) {
  +            String valveName = (String) valveNames.next();
  +            ObjectName objectName = new ObjectName(valveName);
  +            String nodeLabel = "Valve for " + containerNode.getLabel();
  +            TreeControlNode valveNode =
  +                new TreeControlNode(valveName,
  +                                    "folder_16_pad.gif",
  +                                    nodeLabel,
  +                                    "EditValve.do?select=" +
  +                                    URLEncoder.encode(valveName) +
  +                                    "&nodeLabel=" +
  +                                    URLEncoder.encode(nodeLabel),
  +                                    "content",
  +                                    false);
  +            containerNode.addChild(valveNode);
  +        }
  +    }
   }
  
  
  
  1.7       +99 -4     
jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java
  
  Index: Lists.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Lists.java        3 Apr 2002 00:27:30 -0000       1.6
  +++ Lists.java        11 Apr 2002 07:44:22 -0000      1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java,v
 1.6 2002/04/03 00:27:30 manveen Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/04/03 00:27:30 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/Lists.java,v
 1.7 2002/04/11 07:44:22 manveen Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/04/11 07:44:22 $
    *
    * ====================================================================
    *
  @@ -77,7 +77,7 @@
    * is returned.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2002/04/03 00:27:30 $
  + * @version $Revision: 1.7 $ $Date: 2002/04/11 07:44:22 $
    */
   
   public class Lists {
  @@ -136,6 +136,7 @@
               booleanValues.add(new LabelValueBean("False", "false"));
       }
       
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -436,6 +437,100 @@
           throws Exception {
   
           return (getRealms(mbserver, new ObjectName(container)));
  +
  +    }
  +
  +    /**
  +     * Return a list of <code>Valve</code> object name strings
  +     * for the specified container (service, host, or context) object name.
  +     *
  +     * @param mbserver MBeanServer from which to retrieve the list
  +     * @param container Object name of the container for which to select
  +     *                  Valves
  +     *
  +     * @exception Exception if thrown while retrieving the list
  +     */
  +    public static List getValves(MBeanServer mbserver, ObjectName container)
  +        throws Exception {
  +
  +        StringBuffer sb = new StringBuffer(container.getDomain());
  +        sb.append(":type=Valve");
  +        String type = container.getKeyProperty("type");
  +        sb.append(TomcatTreeBuilder.WILDCARD);
  +        
  +        String service = container.getKeyProperty("service");
  +        String host = container.getKeyProperty("host");
  +        String path = container.getKeyProperty("path");
  +        
  +        if ("Service".equals(type)) {
  +            service = container.getKeyProperty("name");
  +        }
  +        if (service != null) {
  +            sb.append(",service=");
  +            sb.append(service);
  +        }
  +        
  +        ObjectName search = new ObjectName(sb.toString());        
  +        ArrayList valves = new ArrayList();
  +        Iterator names = mbserver.queryNames(search, null).iterator();
  +        while (names.hasNext()) {
  +            ObjectName valve = (ObjectName) names.next();
  +            String vpath = valve.getKeyProperty("path");            
  +            String vhost = valve.getKeyProperty("host");
  +            
  +            String valveType = null;
  +            String className = (String) 
  +                    mbserver.getAttribute(valve, "className");
  +            int period = className.lastIndexOf(".");
  +            if (period >= 0)
  +                valveType = className.substring(period + 1);
  +
  +           // Return only user-configurable valves.
  +           if ("AccessLogValve".equalsIgnoreCase(valveType) ||
  +               "RemoteAddrValve".equalsIgnoreCase(valveType) ||
  +               "RemoteHostValve".equalsIgnoreCase(valveType) || 
  +               "RequestDumperValve".equalsIgnoreCase(valveType) ||
  +               "SingleSignOn".equalsIgnoreCase(valveType)) {
  +            // if service is the container, then the valve name
  +            // should not contain path or host                   
  +            if ("Service".equalsIgnoreCase(type)) {
  +                if ((vpath == null) && (vhost == null)) {
  +                    valves.add(valve.toString());
  +                }
  +            } 
  +            
  +            if ("Host".equalsIgnoreCase(type)) {
  +                if ((vpath == null) && (host.equalsIgnoreCase(vhost))) { 
  +                    valves.add(valve.toString());      
  +                }
  +            }
  +            
  +            if ("Context".equalsIgnoreCase(type)) {
  +                if ((path.equalsIgnoreCase(vpath)) && 
(host.equalsIgnoreCase(vhost))) {
  +                    valves.add(valve.toString());      
  +                }
  +            }
  +           }
  +        }        
  +        Collections.sort(valves);
  +        return (valves);
  +    }
  +
  +    
  +    /**
  +     * Return a list of <code>Valve</code> object name strings
  +     * for the specified container (service, host, or context) object name.
  +     *
  +     * @param mbserver MBeanServer from which to retrieve the list
  +     * @param container Object name of the container for which to select
  +     *                  valves
  +     *
  +     * @exception Exception if thrown while retrieving the list
  +     */
  +    public static List getValves(MBeanServer mbserver, String container)
  +        throws Exception {
  +
  +        return (getValves(mbserver, new ObjectName(container)));
   
       }
       
  
  
  

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

Reply via email to