geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r805692 - in /geronimo/server/branches/2.2/plugins: console/console-base-portlets/src/main/java/org/apache/geronimo/console/logmanager/ tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/ tomcat/tomcat6/ tomcat/tomcat6/src/mai...
Date Wed, 19 Aug 2009 08:02:00 GMT
Author: xuhaihong
Date: Wed Aug 19 08:01:59 2009
New Revision: 805692

URL: http://svn.apache.org/viewvc?rev=805692&view=rev
Log:
GERONIMO-4803 ClassCastExeption after disabling access log valve for web container

Modified:
    geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
    geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLogManagerImpl.java
    geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java
    geronimo/server/branches/2.2/plugins/tomcat/tomcat6/pom.xml
    geronimo/server/branches/2.2/plugins/tomcat/tomcat6/src/main/plan/plan.xml

Modified: geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java?rev=805692&r1=805691&r2=805692&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
(original)
+++ geronimo/server/branches/2.2/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/logmanager/WebAccessLogViewerPortlet.java
Wed Aug 19 08:01:59 2009
@@ -116,7 +116,11 @@
 //      Temporarily disable container and log parameters.  
 //      We don't current enable this in the portlet anyway and at the moment it is just unnecessary
data traveling back and forth.
 //      renderRequest.setAttribute("webContainers", products);
-        final String[] logNames = chosenLog.getLogNames();
+        String[] logNames = chosenLog.getLogNames();
+        if (logNames.length == 0) {
+            searchView.include(renderRequest, renderRespose);
+            return;
+        }
 //      renderRequest.setAttribute("webLogs", logNames);
         String logToSearch = null;
 //      String logToSearch = renderRequest.getParameter("selectedLog");

Modified: geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLogManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLogManagerImpl.java?rev=805692&r1=805691&r2=805692&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLogManagerImpl.java
(original)
+++ geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLogManagerImpl.java
Wed Aug 19 08:01:59 2009
@@ -16,36 +16,41 @@
  */
 package org.apache.geronimo.tomcat;
 
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.catalina.valves.AccessLogValve;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.text.SimpleDateFormat;
 import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.Server;
+import org.apache.catalina.Service;
+import org.apache.catalina.Valve;
+import org.apache.catalina.valves.AccessLogValve;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Tomcat implementation of the WebAccessLog management interface.
  *
  * @version $Rev$ $Date$
  */
-public class TomcatLogManagerImpl implements TomcatLogManager {
+public class TomcatLogManagerImpl implements TomcatLogManager, GBeanLifecycle {
+
     private static final Logger log = LoggerFactory.getLogger(TomcatLogManagerImpl.class);
 
     // Pattern that matches the date in the logfile name
@@ -72,12 +77,13 @@
     private final static int GROUP_RESPONSE_LENGTH = 8;
     private final static String ACCESS_LOG_DATE_FORMAT = "dd/MMM/yyyy:HH:mm:ss ZZZZ";
     private final static String LOG_FILE_NAME_FORMAT = "yyyy-MM-dd";
-    private final Collection<ValveGBean> logGbeans;
+    private List<AccessLogValve> accessLogValves;
     private final ServerInfo serverInfo;
+    private TomcatServerGBean tomcatServer;    
 
-    public TomcatLogManagerImpl(ServerInfo serverInfo, Collection<ValveGBean> logGbeans)
{
+    public TomcatLogManagerImpl(ServerInfo serverInfo, TomcatServerGBean tomcatServer) {
         this.serverInfo = serverInfo;
-        this.logGbeans = logGbeans;
+        this.tomcatServer = tomcatServer;        
     }
 
     /**
@@ -89,12 +95,8 @@
      */
     public String[] getLogNames() {
         List<String> logNames = new ArrayList<String>();
-        for (Iterator<ValveGBean> it = logGbeans.iterator(); it.hasNext();) {
-            ValveGBean logGBean = (ValveGBean) it.next();
-            AccessLogValve logFile = (AccessLogValve) logGBean.getInternalObject();
-            if(logFile != null) {
-                logNames.add( "var/catalina/logs/"+logFile.getPrefix()+LOG_FILE_NAME_FORMAT+logFile.getSuffix());
   
-            }
+        for (AccessLogValve accessLogValve : accessLogValves) {
+            logNames.add("var/catalina/logs/" + accessLogValve.getPrefix() + LOG_FILE_NAME_FORMAT
+ accessLogValve.getSuffix());
         }
         return (String[]) logNames.toArray(new String[logNames.size()]);
     }
@@ -270,12 +272,11 @@
     public static final GBeanInfo GBEAN_INFO;
 
     static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Tomcat Log Manager",
TomcatLogManagerImpl.class);
-        infoFactory.addReference("LogGBeans", ValveGBean.class);
-        infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Tomcat Log Manager",
TomcatLogManagerImpl.class);        
+        infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");       
+        infoFactory.addReference("Server", TomcatServerGBean.class);
         infoFactory.addInterface(TomcatLogManager.class);
-
-        infoFactory.setConstructor(new String[]{"ServerInfo","LogGBeans"});
+        infoFactory.setConstructor(new String[] { "ServerInfo", "Server" });
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 
@@ -304,6 +305,45 @@
             return pattern.matcher(fileName).matches();
         }
     }
+    
+    public void doFail() {       
+    }
+
+    public void doStart() throws Exception {        
+        //Find all the access log valves and add them to the list
+        //Valve could be added on Engine/Host/Context
+        Server server = tomcatServer.getServer();
+        accessLogValves = new LinkedList<AccessLogValve>();
+        for(Service service : server.findServices()) {
+            Container container = service.getContainer();
+            searchAccessLogValves(container);
+        }
+    }
+
+    private void searchAccessLogValves(Container container) {
+        Pipeline pipeline = container.getPipeline();
+        if (pipeline == null) {
+            return;
+        }
+        Valve[] valves = pipeline.getValves();
+        if (valves == null || valves.length == 0) {
+            return;
+        }
+        for (Valve valve : valves) {
+            if (valve instanceof AccessLogValve) {
+                accessLogValves.add((AccessLogValve) valve);
+            }
+        }
+        Container[] subContainers = container.findChildren();
+        if (subContainers != null && subContainers.length > 0) {
+            for (Container subContainer : subContainers) {
+                searchAccessLogValves(subContainer);
+            }
+        }
+    }
+
+    public void doStop() throws Exception {        
+    }
 
 /*
     public static void main(String[] args) {

Modified: geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java?rev=805692&r1=805691&r2=805692&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java
(original)
+++ geronimo/server/branches/2.2/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java
Wed Aug 19 08:01:59 2009
@@ -161,4 +161,8 @@
         }
         return service;
     }
+
+    public Server getServer() {
+        return server;
+    }
 }

Modified: geronimo/server/branches/2.2/plugins/tomcat/tomcat6/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/tomcat/tomcat6/pom.xml?rev=805692&r1=805691&r2=805692&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/tomcat/tomcat6/pom.xml (original)
+++ geronimo/server/branches/2.2/plugins/tomcat/tomcat6/pom.xml Wed Aug 19 08:01:59 2009
@@ -121,15 +121,6 @@
                         <plugin-artifact>
                             <copy-file relative-to="server" dest-dir="var/catalina">tomcat-base/</copy-file>
                             <config-xml-content>
-                                <gbean name="AccessLogValve">
-                                    <attribute name="containerName">${ServerHostname}</attribute>
-                                </gbean>
-                                <!-- To disable accesslogging uncomment the following
lines
-                                <gbean name="TomcatEngine">
-                                    <reference name="TomcatValveChain" />
-                                </gbean>
-                                <gbean name="AccessLogValve" load="false"></gbean>
-                                -->
                                 <!--
                                 <gbean name="TomcatWebConnector">
                                     <attribute name="host">${ServerHostname}</attribute>

Modified: geronimo/server/branches/2.2/plugins/tomcat/tomcat6/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/tomcat/tomcat6/src/main/plan/plan.xml?rev=805692&r1=805691&r2=805692&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/tomcat/tomcat6/src/main/plan/plan.xml (original)
+++ geronimo/server/branches/2.2/plugins/tomcat/tomcat6/src/main/plan/plan.xml Wed Aug 19
08:01:59 2009
@@ -78,20 +78,10 @@
         <reference name="ServerInfo">
             <name>ServerInfo</name>
         </reference>
-        <references name="LogGBeans">
-            <pattern>
-                <name>AccessLogValve</name>
-            </pattern>
-        </references>
-    </gbean>
-
-    <gbean name="AccessLogValve" class="org.apache.geronimo.tomcat.ValveGBean">
         <reference name="Server">
             <name>TomcatServer</name>
         </reference>
-        <attribute name="seq">0</attribute>
-        <attribute name="containerName">${PlanServerHostname}</attribute>
-    </gbean>
+    </gbean>    
 
     <!--
     <gbean name="AprLifecycleListener" class="org.apache.geronimo.tomcat.LifecycleListenerGBean">



Mime
View raw message