geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r561370 - /geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
Date Tue, 31 Jul 2007 16:05:20 GMT
Author: jgenender
Date: Tue Jul 31 09:05:19 2007
New Revision: 561370

URL: http://svn.apache.org/viewvc?view=rev&rev=561370
Log:
Checkpoint save for the Tomcat Manager

Modified:
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java?view=diff&rev=561370&r1=561369&r2=561370
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
Tue Jul 31 09:05:19 2007
@@ -17,9 +17,15 @@
 package org.apache.geronimo.tomcat;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.net.ssl.KeyManagerFactory;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -43,10 +49,13 @@
 import org.apache.geronimo.management.geronimo.WebManager;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.tomcat.connector.AJP13ConnectorGBean;
-import org.apache.geronimo.tomcat.connector.CommonProtocol;
 import org.apache.geronimo.tomcat.connector.ConnectorGBean;
+import org.apache.geronimo.tomcat.connector.Http11APRConnectorGBean;
 import org.apache.geronimo.tomcat.connector.Http11ConnectorGBean;
+import org.apache.geronimo.tomcat.connector.Http11NIOConnectorGBean;
+import org.apache.geronimo.tomcat.connector.Https11APRConnectorGBean;
 import org.apache.geronimo.tomcat.connector.Https11ConnectorGBean;
+import org.apache.geronimo.tomcat.connector.Https11NIOConnectorGBean;
 import org.apache.geronimo.tomcat.connector.TomcatWebConnector;
 
 /**
@@ -58,7 +67,147 @@
 public class TomcatManagerImpl implements WebManager {
     private final static Log log = LogFactory.getLog(TomcatManagerImpl.class);
     private final Kernel kernel;
+    
+    private static final ConnectorType HTTP_APR = new ConnectorType("Tomcat APR HTTP Connector");
+    private static final ConnectorType HTTPS_APR = new ConnectorType("Tomcat APR HTTPS Connector");
+    private static final ConnectorType HTTP_NIO = new ConnectorType("Tomcat NIO HTTP Connector");
+    private static final ConnectorType HTTPS_NIO = new ConnectorType("Tomcat NIO HTTPS Connector");
+    private static final ConnectorType HTTP_BIO = new ConnectorType("Tomcat BIO HTTP Connector");
+    private static final ConnectorType HTTPS_BIO = new ConnectorType("Tomcat BIO HTTPS Connector");
+    private static final ConnectorType AJP = new ConnectorType("Tomcat AJP Connector");
+    private static List<ConnectorType> CONNECTOR_TYPES = Arrays.asList(
+            HTTP_BIO,
+            HTTPS_BIO,
+            HTTP_NIO,
+            HTTPS_NIO,
+            HTTP_APR,
+            HTTPS_APR,
+            AJP
+    );
+    
+    private static Map<ConnectorType, List<ConnectorAttribute>> CONNECTOR_ATTRIBUTES
= new HashMap<ConnectorType, List<ConnectorAttribute>>();
+
+    static {
+        List<ConnectorAttribute> connectorAttributes = new ArrayList<ConnectorAttribute>();
+        //HTTP Attributes
+        connectorAttributes.add(new ConnectorAttribute<String>("host", "0.0.0.0", "Host",
String.class), true);
+        connectorAttributes.add(new ConnectorAttribute<Integer>("port", 8080, "Port",
Integer.class), true);
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxThreads", 40, "Maximum
number of threads", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("minSpareThreads",
10, "Minimum spare threads", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxSpareThreads",
100, "Maximum spare threads", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("bufferSize", 2048,
"Buffer size", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("acceptCount", 10,
"acceptCount", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("connectionLinger",
-1, "connectionLinger", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("tcpNoDelay", true,
"tcpNoDelay", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("compressableMimeType",
"text/html,text/xml,text/plain", "compressableMimeType", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("compression", "off",
"compression", String.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("connectionTimeout",
60000, "Connection timeout in milliseconds", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("keepAliveTimeout",
60000, "Keep alive timeout in milliseconds", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("disableUploadTimeout",
true, "disableUploadTimeout", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxHttpHeaderSize",
4096, "Maximum HTTP header size in bytes", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxKeepAliveRequests",
100, "Maximum keep alive requests", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("noCompressionUserAgents",
"", "Comma separated list of regular expressions matching user-agents for which compression
should not be used", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("restrictedUserAgents",
"", "Comma separated list of regular expressions matching user-agents for which which HTTP/1.1
or HTTP/1.0 keep alive should not be used", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("restrictedUserAgents",
"", "Comma separated list of regular expressions matching user-agents for which which HTTP/1.1
or HTTP/1.0 keep alive should not be used", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("server", "", "The Server
header for the http response.", String.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("socketBuffer", 9000,
"The size (in bytes) of the buffer to be provided for socket output buffering", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("threadPriority", Thread.NORM_PRIORITY,
"The priority of the request processing threads within the JVM", Integer.class));
+        //Common attributes
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("allowTrace", false,
"Used to enable or disable the TRACE HTTP method.", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("emptySessionPath",
false, "emptySessionPath", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("enableLookups", true,
"enableLookups", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxPostSize", 2097152,
"maxPostSize", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxSavePostSize",
4096, "maxSavePostSize", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("proxyName", "", "proxyName",
String.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("proxyPort", 0, "proxyPort",
Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("redirectPort", 8443,
"redirectPort", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("uriEncoding", "ISO-8859-1",
"uriEncoding", String.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("useBodyEncodingForURI",
false, "useBodyEncodingForURI", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("useIPVHosts", false,
"useIPVHosts", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("xpoweredBy", false,
"xpoweredBy", Boolean.class));
+
+        CONNECTOR_ATTRIBUTES.put(HTTP_BIO, connectorAttributes);
+        
+        connectorAttributes = new ArrayList<ConnectorAttribute>();
+        
+        connectorAttributes.add(new ConnectorAttribute<String>("algorithm", KeyManagerFactory.getDefaultAlgorithm(),
"Algorithm", String.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("clientAuth", false,
"clientAuth", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("keystoreFile", "",
"keystoreFile", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("keystorePass", "",
"keystorePass", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("keystoreType", "JKS",
"keystoreType", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("sslProtocol", "TLS",
"sslProtocol", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("ciphers", "", "Ciphers",
String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("keyAlias", "", "keyAlias",
String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("truststoreFile", "",
"truststoreFile", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("truststorePass", "",
"truststorePass", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("truststoreType", "",
"truststoreType", String.class));
+        //HTTP Attributes
+        connectorAttributes.add(new ConnectorAttribute<String>("host", "0.0.0.0", "Host",
String.class), true);
+        connectorAttributes.add(new ConnectorAttribute<Integer>("port", 8443, "Port",
Integer.class), true);
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxThreads", 40, "Maximum
number of threads", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("minSpareThreads",
10, "Minimum spare threads", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxSpareThreads",
100, "Maximum spare threads", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("bufferSize", 2048,
"Buffer size", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("acceptCount", 10,
"acceptCount", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("connectionLinger",
-1, "connectionLinger", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("tcpNoDelay", true,
"tcpNoDelay", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("compressableMimeType",
"text/html,text/xml,text/plain", "compressableMimeType", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("compression", "off",
"compression", String.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("connectionTimeout",
60000, "Connection timeout in milliseconds", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("keepAliveTimeout",
60000, "Keep alive timeout in milliseconds", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("disableUploadTimeout",
true, "disableUploadTimeout", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxHttpHeaderSize",
4096, "Maximum HTTP header size in bytes", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxKeepAliveRequests",
100, "Maximum keep alive requests", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("noCompressionUserAgents",
"", "Comma separated list of regular expressions matching user-agents for which compression
should not be used", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("restrictedUserAgents",
"", "Comma separated list of regular expressions matching user-agents for which which HTTP/1.1
or HTTP/1.0 keep alive should not be used", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("restrictedUserAgents",
"", "Comma separated list of regular expressions matching user-agents for which which HTTP/1.1
or HTTP/1.0 keep alive should not be used", String.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("server", "", "The Server
header for the http response.", String.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("socketBuffer", 9000,
"The size (in bytes) of the buffer to be provided for socket output buffering", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("threadPriority", Thread.NORM_PRIORITY,
"The priority of the request processing threads within the JVM", Integer.class));
+        //Common attributes
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("allowTrace", false,
"Used to enable or disable the TRACE HTTP method.", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("emptySessionPath",
false, "emptySessionPath", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("enableLookups", true,
"enableLookups", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxPostSize", 2097152,
"maxPostSize", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("maxSavePostSize",
4096, "maxSavePostSize", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("proxyName", "", "proxyName",
String.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("proxyPort", 0, "proxyPort",
Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<Integer>("redirectPort", 8443,
"redirectPort", Integer.class));
+        connectorAttributes.add(new ConnectorAttribute<String>("uriEncoding", "ISO-8859-1",
"uriEncoding", String.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("useBodyEncodingForURI",
false, "useBodyEncodingForURI", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("useIPVHosts", false,
"useIPVHosts", Boolean.class));
+        connectorAttributes.add(new ConnectorAttribute<Boolean>("xpoweredBy", false,
"xpoweredBy", Boolean.class));
+
+        CONNECTOR_ATTRIBUTES.put(HTTPS_BIO, connectorAttributes);
+        
+        connectorAttributes = new ArrayList<ConnectorAttribute>();
+        CONNECTOR_ATTRIBUTES.put(HTTP_NIO, connectorAttributes);
+        
+        connectorAttributes = new ArrayList<ConnectorAttribute>();
+        CONNECTOR_ATTRIBUTES.put(HTTPS_NIO, connectorAttributes);
+        
+        connectorAttributes = new ArrayList<ConnectorAttribute>();
+        CONNECTOR_ATTRIBUTES.put(HTTP_APR, connectorAttributes);
+        
+        connectorAttributes = new ArrayList<ConnectorAttribute>();
+        CONNECTOR_ATTRIBUTES.put(HTTPS_APR, connectorAttributes);
+        
+        connectorAttributes = new ArrayList<ConnectorAttribute>();
+        CONNECTOR_ATTRIBUTES.put(AJP, connectorAttributes);
+    }
+    
+    private static Map<ConnectorType, GBeanInfo> CONNECTOR_GBEAN_INFOS = new HashMap<ConnectorType,
GBeanInfo>();
 
+    static {
+        CONNECTOR_GBEAN_INFOS.put(HTTP_BIO, Http11ConnectorGBean.GBEAN_INFO);
+        CONNECTOR_GBEAN_INFOS.put(HTTPS_BIO, Https11ConnectorGBean.GBEAN_INFO);
+        CONNECTOR_GBEAN_INFOS.put(HTTP_NIO, Http11NIOConnectorGBean.GBEAN_INFO);
+        CONNECTOR_GBEAN_INFOS.put(HTTPS_NIO, Https11NIOConnectorGBean.GBEAN_INFO);
+        CONNECTOR_GBEAN_INFOS.put(HTTP_APR, Http11APRConnectorGBean.GBEAN_INFO);
+        CONNECTOR_GBEAN_INFOS.put(HTTPS_APR, Https11APRConnectorGBean.GBEAN_INFO);
+        CONNECTOR_GBEAN_INFOS.put(AJP, AJP13ConnectorGBean.GBEAN_INFO);
+    }
+    
     public TomcatManagerImpl(Kernel kernel) {
         this.kernel = kernel;
     }
@@ -227,11 +376,33 @@
     }
 
     public List<ConnectorAttribute> getConnectorAttributes(ConnectorType connectorType)
{
-        return null;
+        return ConnectorAttribute.copy(CONNECTOR_ATTRIBUTES.get(connectorType));
     }
 
     public AbstractName getConnectorConfiguration(ConnectorType connectorType, List<ConnectorAttribute>
connectorAttributes, WebContainer container, String uniqueName) {
-        return null;
+        GBeanInfo gbeanInfo = CONNECTOR_GBEAN_INFOS.get(connectorType);
+        AbstractName containerName = kernel.getAbstractNameFor(container);
+        AbstractName name = kernel.getNaming().createSiblingName(containerName, uniqueName,
NameFactory.GERONIMO_SERVICE);
+        GBeanData gbeanData = new GBeanData(name, gbeanInfo);
+        gbeanData.setReferencePattern(ConnectorGBean.CONNECTOR_CONTAINER_REFERENCE, containerName);
+        for (ConnectorAttribute connectorAttribute : connectorAttributes) {
+            gbeanData.setAttribute(connectorAttribute.getAttributeName(), connectorAttribute.getStringValue());
+        }
+        EditableConfigurationManager mgr = ConfigurationUtil.getEditableConfigurationManager(kernel);
+        if (mgr != null) {
+            try {
+                mgr.addGBeanToConfiguration(containerName.getArtifact(), gbeanData, false);
+            } catch (InvalidConfigException e) {
+                log.error("Unable to add GBean", e);
+                return null;
+            } finally {
+                ConfigurationUtil.releaseConfigurationManager(kernel, mgr);
+            }
+        } else {
+            log.warn("The ConfigurationManager in the kernel does not allow editing");
+            return null;
+        }
+        return name;
     }
 
     /**
@@ -326,7 +497,33 @@
     }
 
     public ConnectorType getConnectorType(AbstractName connectorName) {
-        // TODO Auto-generated method stub
-        return null;
+        ConnectorType connectorType = null; 
+        try {
+            GBeanInfo info = kernel.getGBeanInfo(connectorName);
+            boolean found = false;
+            Set intfs = info.getInterfaces();
+            for (Iterator it = intfs.iterator(); it.hasNext() && !found;) {
+                String intf = (String) it.next();
+                if (intf.equals(TomcatWebConnector.class.getName())) {
+                    found = true;
+                }
+            }
+            if (!found) {
+                throw new GBeanNotFoundException(connectorName);
+            }
+            String searchingFor = info.getName();
+            for (Entry<ConnectorType, GBeanInfo> entry : CONNECTOR_GBEAN_INFOS.entrySet()
) {
+                String candidate = entry.getValue().getName();
+                if (candidate.equals(searchingFor)) {
+                    return entry.getKey();
+                }
+            }
+        } catch (GBeanNotFoundException e) {
+            log.warn("No such GBean '" + connectorName + "'");
+        } catch (Exception e) {
+            log.error(e);
+        }
+            
+        return connectorType;
     }
 }



Mime
View raw message