remm 2002/06/05 23:29:17 Modified: catalina/src/share/org/apache/catalina/startup Embedded.java Log: - Embedded will now use Coyote. - Add support for AJP (using a new createConnector method). Revision Changes Path 1.15 +58 -39 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Embedded.java Index: Embedded.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Embedded.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- Embedded.java 9 Nov 2001 19:40:44 -0000 1.14 +++ Embedded.java 6 Jun 2002 06:29:17 -0000 1.15 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Embedded.java,v 1.14 2001/11/09 19:40:44 remm Exp $ - * $Revision: 1.14 $ - * $Date: 2001/11/09 19:40:44 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/Embedded.java,v 1.15 2002/06/06 06:29:17 remm Exp $ + * $Revision: 1.15 $ + * $Date: 2002/06/06 06:29:17 $ * * ==================================================================== * @@ -70,6 +70,9 @@ import java.net.InetAddress; import java.util.Enumeration; import java.util.Properties; + +import org.apache.tomcat.util.IntrospectionUtils; + import org.apache.catalina.Connector; import org.apache.catalina.Container; import org.apache.catalina.Context; @@ -82,7 +85,6 @@ import org.apache.catalina.Loader; import org.apache.catalina.Logger; import org.apache.catalina.Realm; -import org.apache.catalina.connector.http.HttpConnector; import org.apache.catalina.core.StandardContext; import org.apache.catalina.core.StandardEngine; import org.apache.catalina.core.StandardHost; @@ -149,7 +151,7 @@ * </pre> * * @author Craig R. McClanahan - * @version $Revision: 1.14 $ $Date: 2001/11/09 19:40:44 $ + * @version $Revision: 1.15 $ $Date: 2002/06/06 06:29:17 $ */ public class Embedded implements Lifecycle { @@ -406,14 +408,7 @@ public synchronized void addConnector(Connector connector) { if (debug >= 1) { - if (connector instanceof HttpConnector) { - HttpConnector hc = (HttpConnector) connector; - logger.log("Adding connector for address '" + - ((hc.getAddress() == null) ? "ALL" : hc.getAddress()) - + "' port='" + hc.getPort() + "'"); - } else { - logger.log("Adding connector (" + connector.getInfo() + ")"); - } + logger.log("Adding connector (" + connector.getInfo() + ")"); } // Make sure we have a Container to send requests to @@ -504,27 +499,58 @@ ((address == null) ? "ALL" : address.getHostAddress()) + "' port='" + port + "' secure='" + secure + "'"); - HttpConnector connector = new HttpConnector(); - - if (address != null) - connector.setAddress(address.getHostAddress()); - connector.setDebug(debug); - connector.setPort(port); + String protocol = "http"; if (secure) { - connector.setScheme("https"); - connector.setSecure(true); - try { - Class serverSocketFactoryClass = Class.forName - ("org.apache.catalina.net.SSLServerSocketFactory"); - ServerSocketFactory factory = - (ServerSocketFactory) - serverSocketFactoryClass.newInstance(); - connector.setFactory(factory); - } catch (Exception e) { - logger.log("Couldn't load SSL server socket factory."); - } + protocol = "https"; } + return createConnector(address, port, protocol); + + } + + + public Connector createConnector(InetAddress address, int port, + String protocol) { + + Connector connector = null; + + try { + + Class clazz = + Class.forName("org.apache.coyote.tomcat4.CoyoteConnector"); + connector = (Connector) clazz.newInstance(); + + if (address != null) { + IntrospectionUtils.setProperty(connector, "address", + "" + address); + } + IntrospectionUtils.setProperty(connector, "port", "" + port); + IntrospectionUtils.setProperty(connector, "useURIValidationHack", + "" + false); + + if (protocol.equals("ajp")) { + IntrospectionUtils.setProperty + (connector, "protocolHandlerClassName", + "org.apache.jk.server.JkCoyoteHandler"); + } else if (protocol.equals("https")) { + connector.setScheme("https"); + connector.setSecure(true); + try { + Class serverSocketFactoryClass = Class.forName + ("org.apache.coyote.tomcat4.CoyoteServerSocketFactory"); + ServerSocketFactory factory = + (ServerSocketFactory) + serverSocketFactoryClass.newInstance(); + connector.setFactory(factory); + } catch (Exception e) { + logger.log("Couldn't load SSL server socket factory."); + } + } + + } catch (Exception e) { + logger.log("Couldn't create connector."); + } + return (connector); } @@ -678,14 +704,7 @@ public synchronized void removeConnector(Connector connector) { if (debug >= 1) { - if (connector instanceof HttpConnector) { - HttpConnector hc = (HttpConnector) connector; - logger.log("Removing connector for address '" + - ((hc.getAddress() == null) ? "ALL" : hc.getAddress()) - + "' port='" + hc.getPort() + "'"); - } else { - logger.log("Removing connector (" + connector.getInfo() + ")"); - } + logger.log("Removing connector (" + connector.getInfo() + ")"); } // Is the specified Connector actually defined?
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>