jfclere 02/01/16 07:38:29 Modified: jk/java/org/apache/jk/common ChannelJni.java ChannelSocket.java ChannelUn.java ChannelUnixSocket.java jk/java/org/apache/jk/core Channel.java jk/java/org/apache/jk/server JkMain.java jk/java/org/apache/jk/server/tomcat40 JkConnector.java Added: jk/java/org/apache/jk/core JkChannel.java Log: Allow to load different Channel class via configuration of the server.xml file. Revision Changes Path 1.2 +1 -1 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelJni.java Index: ChannelJni.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelJni.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ChannelJni.java 12 Jan 2002 04:03:42 -0000 1.1 +++ ChannelJni.java 16 Jan 2002 15:38:29 -0000 1.2 @@ -77,7 +77,7 @@ * * @author Costin Manolache */ -public class ChannelJni extends Channel { +public class ChannelJni extends JkChannel implements Channel { /* ==================== ==================== */ 1.2 +1 -2 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelSocket.java Index: ChannelSocket.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelSocket.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ChannelSocket.java 31 Dec 2001 19:02:01 -0000 1.1 +++ ChannelSocket.java 16 Jan 2002 15:38:29 -0000 1.2 @@ -94,7 +94,7 @@ * * @author Costin Manolache */ -public class ChannelSocket extends Channel { +public class ChannelSocket extends JkChannel implements Channel { int port; InetAddress inet; @@ -152,7 +152,6 @@ public void setSoTimeout( int i ) { socketTimeout=i; } - /* ==================== ==================== */ ServerSocket sSocket; 1.4 +2 -2 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelUn.java Index: ChannelUn.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelUn.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ChannelUn.java 14 Jan 2002 09:36:13 -0000 1.3 +++ ChannelUn.java 16 Jan 2002 15:38:29 -0000 1.4 @@ -77,7 +77,7 @@ * * @author Costin Manolache */ -public class ChannelUn extends Channel { +public class ChannelUn extends JkChannel implements Channel { String file; Worker worker; @@ -233,7 +233,7 @@ */ void acceptConnections() { if( dL>0 ) - d("Accepting ajp connections"); + d("Accepting ajp connections on " + file); while( running ) { try { Endpoint ep=this.createEndpoint(); 1.3 +1 -1 jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelUnixSocket.java Index: ChannelUnixSocket.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/common/ChannelUnixSocket.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ChannelUnixSocket.java 6 Jan 2002 09:14:07 -0000 1.2 +++ ChannelUnixSocket.java 16 Jan 2002 15:38:29 -0000 1.3 @@ -96,7 +96,7 @@ * @author Costin Manolache * @author Jean-Frederic Clere (Well, I have copied Costin's code and ideas). */ -public class ChannelUnixSocket extends Channel { +public class ChannelUnixSocket extends JkChannel implements Channel { /* XXX do not have port/Address */ // int port; 1.2 +15 -13 jakarta-tomcat-connectors/jk/java/org/apache/jk/core/Channel.java Index: Channel.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/core/Channel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Channel.java 31 Dec 2001 19:03:53 -0000 1.1 +++ Channel.java 16 Jan 2002 15:38:29 -0000 1.2 @@ -81,21 +81,23 @@ * @author Kevin Seguin * @author Costin Manolache */ -public abstract class Channel { - protected WorkerEnv we; +public interface Channel { - public void setWorkerEnv( WorkerEnv we ) { - this.we=we; - } + public void setWorkerEnv( WorkerEnv we ); - public void init() throws IOException { - } - + public void init() throws IOException; - public void write( Endpoint ep, byte[] b, int offset, int len) throws IOException { - } + public void write( Endpoint ep, byte[] b, int offset, int len) + throws IOException; - public int read( Endpoint ep, byte[] b, int offset, int len) throws IOException { - return -1; - } + public int read( Endpoint ep, byte[] b, int offset, int len) + throws IOException; + + public void setJkHome(String home); + + public void setWorker(Worker wo); + + public void setFile(String file); + + public void setPort(int port); } 1.1 jakarta-tomcat-connectors/jk/java/org/apache/jk/core/JkChannel.java Index: JkChannel.java =================================================================== /* * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * [Additional notices, if required by prior licensing conditions] * */ package org.apache.jk.core; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.util.Enumeration; import java.security.*; import org.apache.tomcat.util.http.MimeHeaders; import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.HttpMessages; import org.apache.tomcat.util.buf.HexUtils; /** * A communication channel - socket, pipes, doors, jni, etc. * * @author Henri Gomez [[EMAIL PROTECTED]] * @author Dan Milstein [[EMAIL PROTECTED]] * @author Keith Wannamaker [[EMAIL PROTECTED]] * @author Kevin Seguin * @author Costin Manolache */ public abstract class JkChannel { protected WorkerEnv we; public void setWorkerEnv( WorkerEnv we ) { this.we=we; } public void init() throws IOException { } public void write( Endpoint ep, byte[] b, int offset, int len) throws IOException { } public int read( Endpoint ep, byte[] b, int offset, int len) throws IOException { return -1; } public void setJkHome(String path) { } public void setFile(String path) { } public void setWorker(Worker wo) { } public void setPort(int port) { } } 1.5 +21 -9 jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkMain.java Index: JkMain.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/JkMain.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JkMain.java 12 Jan 2002 04:25:14 -0000 1.4 +++ JkMain.java 16 Jan 2002 15:38:29 -0000 1.5 @@ -84,6 +84,8 @@ Worker defaultWorker; String jkHome; + Class channelclass; + public JkMain() { } @@ -109,20 +111,30 @@ public void setJkHome( String s ) { jkHome=s; } + + public void setChannelClass( Class c ) { + channelclass = c; + } public void start() throws IOException { - ChannelUn csocket=new ChannelUn(); -// if( jkHome==null ) + Channel csocket=null; + try { + csocket=(Channel)channelclass.newInstance(); + } catch (Exception ex) { + ex.printStackTrace(); + throw new IOException("Cannot create channel class"); + } + + // Set file. + if( jkHome==null ) csocket.setFile( "/tmp/tomcatUnixSocket" ); -// else -// csocket.setFile( jkHome + "/WEB-INF/tomcatUnixSocket" ); + else + csocket.setFile( jkHome + "/WEB-INF/tomcatUnixSocket" ); csocket.setJkHome( jkHome ); - /* ChannelSocket csocket=new ChannelSocket(); + + // Set port number. csocket.setPort( 8009 ); - */ - /* - ChannelUnixSocket csocket=new ChannelUnixSocket(); // JFC tests - */ + wEnv.addChannel( csocket ); if( defaultWorker == null ) 1.2 +18 -0 jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat40/JkConnector.java Index: JkConnector.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/server/tomcat40/JkConnector.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JkConnector.java 12 Jan 2002 04:10:14 -0000 1.1 +++ JkConnector.java 16 Jan 2002 15:38:29 -0000 1.2 @@ -135,6 +135,14 @@ this.service = service; } + String channelclassname = "org.apache.jk.common.ChannelSocket"; + /** + * Set the <code>channelClassName</code> that will used to connect to httpd. + */ + public void setChannelClassName(String name) { + channelclassname = name; // Could have stored it in properties? + } + // --------------------------------------------------------- Public Methods /** @@ -199,6 +207,16 @@ JkMain jkMain=new JkMain(); jkMain.setProperties( props ); jkMain.setDefaultWorker( worker ); + + // Get the Class that will be used to make the connection. + try { + Class channelclass = Class.forName(channelclassname); + // ct.getParentClassLoader().loadClass(channelclassname); + jkMain.setChannelClass( channelclass ); + } catch( Exception ex ) { + ex.printStackTrace(); + throw new LifecycleException("Cannot find " + channelclassname); + } String catalinaHome=System.getProperty("catalina.home"); File f=new File( catalinaHome );
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>