Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 46954 invoked from network); 26 Jul 2007 00:17:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jul 2007 00:17:23 -0000 Received: (qmail 30529 invoked by uid 500); 26 Jul 2007 00:17:23 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 30510 invoked by uid 500); 26 Jul 2007 00:17:23 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 30499 invoked by uid 99); 26 Jul 2007 00:17:23 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jul 2007 17:17:23 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jul 2007 17:17:21 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 5854C1A981A; Wed, 25 Jul 2007 17:17:01 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r559657 - in /geronimo/server/trunk/modules: geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyManagerImpl.java geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/WebManager.java Date: Thu, 26 Jul 2007 00:17:01 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070726001701.5854C1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djencks Date: Wed Jul 25 17:17:00 2007 New Revision: 559657 URL: http://svn.apache.org/viewvc?view=rev&rev=559657 Log: GERONIMO-3350 second steps, more jetty implementation Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyManagerImpl.java geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/WebManager.java Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyManagerImpl.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyManagerImpl.java?view=diff&rev=559657&r1=559656&r2=559657 ============================================================================== --- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyManagerImpl.java (original) +++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyManagerImpl.java Wed Jul 25 17:17:00 2007 @@ -17,12 +17,12 @@ package org.apache.geronimo.jetty6; import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.Iterator; import java.util.List; -import java.util.Set; -import java.util.Arrays; import java.util.Map; -import java.util.HashMap; +import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,12 +34,12 @@ import org.apache.geronimo.gbean.ReferencePatterns; import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; import org.apache.geronimo.jetty6.connector.AJP13Connector; -import org.apache.geronimo.jetty6.connector.HTTPSocketConnector; +import org.apache.geronimo.jetty6.connector.HTTPBlockingConnector; +import org.apache.geronimo.jetty6.connector.HTTPSSelectChannelConnector; import org.apache.geronimo.jetty6.connector.HTTPSSocketConnector; -import org.apache.geronimo.jetty6.connector.JettyConnector; import org.apache.geronimo.jetty6.connector.HTTPSelectChannelConnector; -import org.apache.geronimo.jetty6.connector.HTTPSSelectChannelConnector; -import org.apache.geronimo.jetty6.connector.HTTPBlockingConnector; +import org.apache.geronimo.jetty6.connector.HTTPSocketConnector; +import org.apache.geronimo.jetty6.connector.JettyConnector; import org.apache.geronimo.jetty6.requestlog.JettyLogManager; import org.apache.geronimo.kernel.GBeanNotFoundException; import org.apache.geronimo.kernel.Kernel; @@ -79,23 +79,79 @@ ); private static Map> CONNECTOR_ATTRIBUTES = new HashMap>(); + //"host", "port", "minThreads", "maxThreads", "bufferSizeBytes", "acceptQueueSize", "lingerMillis", "protocol", "redirectPort", "connectUrl", "maxIdleTimeMs" static { - CONNECTOR_ATTRIBUTES.put(HTTP_NIO, Arrays.asList( - new ConnectorAttribute("host", "0.0.0.0", "Host"), - new ConnectorAttribute("port", "8080", "Port"), -// new ConnectorAttribute("minThreads", "0.0.0.0", "Host"), - new ConnectorAttribute("maxThreads", "10", "Maximum number of acceptors"), - new ConnectorAttribute("bufferSizeBytes", "8096", "Buffer size"), - new ConnectorAttribute("acceptQueueSize", "10", "acceptQueueSize"), - new ConnectorAttribute("lingerMillis", "30000", "lingerMillis"), - new ConnectorAttribute("redirectPort", "8443", "redirectPort"), - new ConnectorAttribute("maxIdleTimeMs", "30000", "maxIdleTimeMs") -// new ConnectorAttribute("connectURL", "0.0.0.0", "connectURL") - )); + List connectorAttributes = new ArrayList(); + connectorAttributes.add(new ConnectorAttribute("host", "0.0.0.0", "Host", String.class)); + connectorAttributes.add(new ConnectorAttribute("port", 8080, "Port", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxThreads", 10, "Maximum number of acceptors", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("bufferSizeBytes", 8096, "Buffer size", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("acceptQueueSize", 10, "acceptQueueSize", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("lingerMillis", 30000, "lingerMillis", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("redirectPort", 8443, "redirectPort", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxIdleTimeMs", 30000, "maxIdleTimeMs", Integer.class)); + CONNECTOR_ATTRIBUTES.put(HTTP_NIO, connectorAttributes); + + connectorAttributes = new ArrayList(); + connectorAttributes.add(new ConnectorAttribute("host", "0.0.0.0", "Host", String.class)); + connectorAttributes.add(new ConnectorAttribute("port", 8443, "Port", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxThreads", 10, "Maximum number of acceptors", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("bufferSizeBytes", 8096, "Buffer size", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("acceptQueueSize", 10, "acceptQueueSize", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("lingerMillis", 30000, "lingerMillis", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("redirectPort", 8443, "redirectPort", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxIdleTimeMs", 30000, "maxIdleTimeMs", Integer.class)); + CONNECTOR_ATTRIBUTES.put(HTTPS_NIO, connectorAttributes); + + connectorAttributes = new ArrayList(); + connectorAttributes.add(new ConnectorAttribute("host", "0.0.0.0", "Host", String.class)); + connectorAttributes.add(new ConnectorAttribute("port", 8080, "Port", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxThreads", 10, "Maximum number of acceptors", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("bufferSizeBytes", 8096, "Buffer size", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("acceptQueueSize", 10, "acceptQueueSize", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("lingerMillis", 30000, "lingerMillis", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("redirectPort", 8443, "redirectPort", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxIdleTimeMs", 30000, "maxIdleTimeMs", Integer.class)); + CONNECTOR_ATTRIBUTES.put(HTTP_BIO, connectorAttributes); + + connectorAttributes = new ArrayList(); + connectorAttributes.add(new ConnectorAttribute("host", "0.0.0.0", "Host", String.class)); + connectorAttributes.add(new ConnectorAttribute("port", 8443, "Port", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxThreads", 10, "Maximum number of acceptors", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("bufferSizeBytes", 8096, "Buffer size", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("acceptQueueSize", 10, "acceptQueueSize", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("lingerMillis", 30000, "lingerMillis", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("redirectPort", 8443, "redirectPort", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxIdleTimeMs", 30000, "maxIdleTimeMs", Integer.class)); + CONNECTOR_ATTRIBUTES.put(HTTPS_BIO, connectorAttributes); + + connectorAttributes = new ArrayList(); + connectorAttributes.add(new ConnectorAttribute("host", "0.0.0.0", "Host", String.class)); + connectorAttributes.add(new ConnectorAttribute("port", 8080, "Port", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxThreads", 10, "Maximum number of acceptors", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("bufferSizeBytes", 8096, "Buffer size", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("acceptQueueSize", 10, "acceptQueueSize", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("lingerMillis", 30000, "lingerMillis", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("redirectPort", 8443, "redirectPort", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxIdleTimeMs", 30000, "maxIdleTimeMs", Integer.class)); + CONNECTOR_ATTRIBUTES.put(HTTP_BLOCKING_NIO, connectorAttributes); + + connectorAttributes = new ArrayList(); + connectorAttributes.add(new ConnectorAttribute("host", "0.0.0.0", "Host", String.class)); + connectorAttributes.add(new ConnectorAttribute("port", 8009, "Port", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxThreads", 10, "Maximum number of acceptors", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("bufferSizeBytes", 8096, "Buffer size", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("acceptQueueSize", 10, "acceptQueueSize", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("lingerMillis", 30000, "lingerMillis", Integer.class)); +// connectorAttributes.add(new ConnectorAttribute("redirectPort", 8443, "redirectPort", Integer.class)); + connectorAttributes.add(new ConnectorAttribute("maxIdleTimeMs", 30000, "maxIdleTimeMs", Integer.class)); + CONNECTOR_ATTRIBUTES.put(AJP_NIO, connectorAttributes); + } private static Map CONNECTOR_GBEAN_INFOS = new HashMap(); + static { CONNECTOR_GBEAN_INFOS.put(HTTP_NIO, HTTPSelectChannelConnector.GBEAN_INFO); CONNECTOR_GBEAN_INFOS.put(HTTPS_NIO, HTTPSSelectChannelConnector.GBEAN_INFO); @@ -133,8 +189,7 @@ //todo: default HTTPS settings } else if (protocol.equals(PROTOCOL_AJP)) { connector = new GBeanData(name, AJP13Connector.GBEAN_INFO); - } - else { + } else { throw new IllegalArgumentException("Invalid protocol '" + protocol + "'"); } connector.setAttribute("host", host); @@ -144,7 +199,7 @@ connector.setAttribute("maxThreads", new Integer(50)); connector.setReferencePattern(JettyConnector.CONNECTOR_CONTAINER_REFERENCE, containerName); EditableConfigurationManager mgr = ConfigurationUtil.getEditableConfigurationManager(kernel); - if(mgr != null) { + if (mgr != null) { try { mgr.addGBeanToConfiguration(containerName.getArtifact(), connector, false); return (WebConnector) kernel.getProxyManager().createProxy(name, JettyWebConnector.class.getClassLoader()); @@ -168,7 +223,7 @@ AbstractNameQuery query = new AbstractNameQuery(JettyContainer.class.getName()); Set names = kernel.listGBeans(query); JettyContainer[] results = new JettyContainer[names.size()]; - int i=0; + int i = 0; for (Iterator it = names.iterator(); it.hasNext(); i++) { AbstractName name = (AbstractName) it.next(); results[i] = (JettyContainer) proxyManager.createProxy(name, JettyContainer.class.getClassLoader()); @@ -188,6 +243,7 @@ * Removes a connector. This shuts it down if necessary, and removes it * from the server environment. It must be a connector that this container * is responsible for. + * * @param connectorName */ public void removeConnector(AbstractName connectorName) { @@ -205,7 +261,7 @@ throw new GBeanNotFoundException(connectorName); } EditableConfigurationManager mgr = ConfigurationUtil.getEditableConfigurationManager(kernel); - if(mgr != null) { + if (mgr != null) { try { mgr.removeGBeanFromConfiguration(connectorName.getArtifact(), connectorName); } catch (InvalidConfigException e) { @@ -230,7 +286,7 @@ * @param protocol A protocol as returned by getSupportedProtocols */ public NetworkConnector[] getConnectors(String protocol) { - if(protocol == null) { + if (protocol == null) { return getConnectors(); } List result = new ArrayList(); @@ -253,12 +309,12 @@ public WebAccessLog getAccessLog(WebContainer container) { AbstractNameQuery query = new AbstractNameQuery(JettyLogManager.class.getName()); Set names = kernel.listGBeans(query); - if(names.size() == 0) { + if (names.size() == 0) { return null; - } else if(names.size() > 1) { + } else if (names.size() > 1) { throw new IllegalStateException("Should not be more than one Jetty access log manager"); } - return (WebAccessLog) kernel.getProxyManager().createProxy((AbstractName)names.iterator().next(), JettyLogManager.class.getClassLoader()); + return (WebAccessLog) kernel.getProxyManager().createProxy((AbstractName) names.iterator().next(), JettyLogManager.class.getClassLoader()); } public List getConnectorTypes() { @@ -275,11 +331,11 @@ AbstractName name = kernel.getNaming().createSiblingName(containerName, uniqueName, NameFactory.GERONIMO_SERVICE); GBeanData gbeanData = new GBeanData(name, gbeanInfo); gbeanData.setReferencePattern(JettyConnector.CONNECTOR_CONTAINER_REFERENCE, containerName); - for (ConnectorAttribute connectorAttribute: connectorAttributes) { + for (ConnectorAttribute connectorAttribute : connectorAttributes) { gbeanData.setAttribute(connectorAttribute.getAttributeName(), connectorAttribute.getStringValue()); } EditableConfigurationManager mgr = ConfigurationUtil.getEditableConfigurationManager(kernel); - if(mgr != null) { + if (mgr != null) { try { mgr.addGBeanToConfiguration(containerName.getArtifact(), gbeanData, false); } catch (InvalidConfigException e) { @@ -303,7 +359,7 @@ AbstractNameQuery query = new AbstractNameQuery(JettyWebConnector.class.getName()); Set names = kernel.listGBeans(query); JettyWebConnector[] results = new JettyWebConnector[names.size()]; - int i=0; + int i = 0; for (Iterator it = names.iterator(); it.hasNext(); i++) { AbstractName name = (AbstractName) it.next(); results[i] = (JettyWebConnector) proxyManager.createProxy(name, JettyWebConnector.class.getClassLoader()); @@ -312,7 +368,7 @@ } public NetworkConnector[] getConnectorsForContainer(Object container, String protocol) { - if(protocol == null) { + if (protocol == null) { return getConnectorsForContainer(container); } AbstractName containerName = kernel.getAbstractNameFor(container); @@ -325,21 +381,21 @@ AbstractName name = (AbstractName) it.next(); // a single Jetty connector GBeanData data = kernel.getGBeanData(name); ReferencePatterns refs = data.getReferencePatterns(JettyConnector.CONNECTOR_CONTAINER_REFERENCE); - if(containerName.equals(refs.getAbstractName())) { + if (containerName.equals(refs.getAbstractName())) { try { String testProtocol = (String) kernel.getAttribute(name, "protocol"); - if(testProtocol != null && testProtocol.equals(protocol)) { + if (testProtocol != null && testProtocol.equals(protocol)) { results.add(mgr.createProxy(name, JettyWebConnector.class.getClassLoader())); } } catch (Exception e) { - log.error("Unable to look up protocol for connector '"+name+"'",e); + log.error("Unable to look up protocol for connector '" + name + "'", e); } break; } } return (JettyWebConnector[]) results.toArray(new JettyWebConnector[results.size()]); } catch (Exception e) { - throw (IllegalArgumentException)new IllegalArgumentException("Unable to look up connectors for Jetty container '"+containerName +"': ").initCause(e); + throw (IllegalArgumentException) new IllegalArgumentException("Unable to look up connectors for Jetty container '" + containerName + "': ").initCause(e); } } @@ -360,7 +416,7 @@ } return (JettyWebConnector[]) results.toArray(new JettyWebConnector[results.size()]); } catch (Exception e) { - throw (IllegalArgumentException) new IllegalArgumentException("Unable to look up connectors for Jetty container '"+containerName+"'").initCause(e); + throw (IllegalArgumentException) new IllegalArgumentException("Unable to look up connectors for Jetty container '" + containerName + "'").initCause(e); } } @@ -370,7 +426,7 @@ GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Jetty Web Manager", JettyManagerImpl.class); infoFactory.addAttribute("kernel", Kernel.class, false); infoFactory.addInterface(WebManager.class); - infoFactory.setConstructor(new String[] {"kernel"}); + infoFactory.setConstructor(new String[]{"kernel"}); GBEAN_INFO = infoFactory.getBeanInfo(); } Modified: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/WebManager.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/WebManager.java?view=diff&rev=559657&r1=559656&r2=559657 ============================================================================== --- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/WebManager.java (original) +++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/WebManager.java Wed Jul 25 17:17:00 2007 @@ -18,8 +18,10 @@ import java.util.List; import java.util.ArrayList; +import java.beans.PropertyEditor; import org.apache.geronimo.gbean.AbstractName; +import org.apache.geronimo.common.propertyeditor.PropertyEditors; /** * Specialization of NetworkManager for web containers. @@ -80,31 +82,47 @@ public class ConnectorAttribute { private final String attributeName; private String stringValue; + private final Class clazz; + private T value; private final String description; - public ConnectorAttribute(String attributeName, String value, String description) { + public ConnectorAttribute(String attributeName, T value, String description, Class clazz) { this.attributeName = attributeName; - this.stringValue = value; + this.value = value; this.description = description; + this.clazz = clazz; } - public ConnectorAttribute(ConnectorAttribute connectorAttribute) { + public ConnectorAttribute(ConnectorAttribute connectorAttribute) { this.attributeName = connectorAttribute.attributeName; this.stringValue = connectorAttribute.stringValue; this.description = connectorAttribute.description; + this.clazz = connectorAttribute.clazz; } - public String getAttributeName() { return attributeName; } public String getStringValue() { - return stringValue; +// Class clazz = getClass().getTypeParameters(); + PropertyEditor propertyEditor = PropertyEditors.getEditor(clazz); + propertyEditor.setValue(value); + return propertyEditor.getAsText(); } public void setStringValue(String stringValue) { - this.stringValue = stringValue; + PropertyEditor propertyEditor = PropertyEditors.getEditor(clazz); + propertyEditor.setAsText(stringValue); + this.value = (T) propertyEditor.getValue(); + } + + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = value; } public String getDescription() {