"Daniela Piacenti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello everybody, > > I read a lot about the coyote connector and that it is possible to write > own connectors for Tomcat. But I did not find anything in the whole web, > how to do this. Now I am reading the source code of the coyote connector > and have some questions about it. > > My problem is: > I am writing an application, which acts as an adapter for another > application to provide its functionality via Web Services to external > client applications. Therefore I am using Tomcat5 in embedded mode as > servlet engine and Apache Axis as framework for the web services. > Now I also have to connect legacy client systems to my new application if > possible. They communicate with the old external client interface directly > over sockets with streams via TCP/IP using proprietary message protocols. > > The alternative way would be to write an own SocketServer before Tomcat to > make HTTP-Requests and to forward them to the Servlet Engine. Backwards > the other way. But this would not be a smart and practicable way for this > task, I guess. So I decided to have a look to the connector and maybe > write my own connector for this. > > Generally I have the question, if it is possible and if yes, how. Do I > have to write a whole connector, which implements this interface? Or is it > possible to use the coyote connector with an own implemenation of an > handlerclass, protocolclass and processclass? And how can I embed this > connector in Tomcat? > > Hope someone may help me. Thanks a lot in advance, >
The best way is to use the Coyote Connector, but implement your own ProtocolHandler: http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/coyote/ProtocolHandler.html. The ProtocolHandler is responsible for setting up the ServerSocket, handling the accepted requests, parsing the data it recieves and setting the appropriate fields in the Request/Response (that it is also responsible for creating :), creating a Thread to process the request, and passing it off to the Adapter that the Connector will have handed you, and finally sending the result back to the client in the format that it expects to recieve it. You'll likely need to implement ActionHook as well to get the best results (e.g. handling client-flush properly). The MemoryProtocolHandler that ships with Tomcat is probably the simplest, and so likely a good place to start to base your ProtocolHandler on. Since you are using Embedded, in your code you would do something like: Connector myConn = new Connector("com.myfirm.mypackage.MyProtocolHandler"); myConn.setProperty("port", myPort); // Additional calls to setProperty here, which will be passed JavaBean style to // your ProtocolHandler (alternatively, use setAttribute if you know the Java class already) embedded.addConnector(myConn); > Regards, > Daniela > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]