tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <>
Subject Re: Tomcat Custom Connector
Date Sat, 14 Jun 2008 02:51:35 GMT
The Adapter is set in the initialize method  of the Connector 

You can pretty much just trust that Tomcat will give you an Adapter instance 
before the first request comes through, since that is the contract.  Yes, 
the current implementation only will give you an instance of CoyoteAdapter, 
but programming your ProtocolHandler around this is dangerous, since the 
contract only promises an instance of Adapter.

The Adapter is the bridge between your ProtocolHandler and the Tomcat 
Servlet Container.  Once you hand off your Request and Response objects to 
the Adapter, you can trust that Tomcat will handle all of the Servlet-Spec 
parts by itself, including finding the Servlet to send the request to.  At 
that point, you are only responsible for communicating with the client over 
the wire via the InputBuffer and OutputBuffer interfaces.  For example, the 
various AJP/1.3 Connectors 
convert the message into AJP/1.3 format before sending it over the wire to 
Apache httpd.

Once you have figured out how to initialize the Request and Response objects 
to look enough like the wire protocol was HTTP, the rest is really pretty 
easy :).  For non-HTTP protocols (e.g. trying to make Tomcat look like an 
FTP server), this is the hard part.

"Simon Aquilina" <> wrote in message 


I have checked the code in Tomcat again, and although it is very confusing I 
feel I did understand something here and there :)

However I have a question - where is the adapter being set? No Adapter is 
being initialized in the 'JIoEndPoint', 'Http11Protocol' and 
'Http11Processor'. I also checked the 'server.xml' file and this is not 
being set! From the API documentation I found out the 'CoyoteAdapter'; so is 
this the default being used for Tomcat? Is it the CoyoteAdapter which is 
responsible to find the servlet for which the request is? or?

Thanks for any comments,
Simon J.
> To:> From:> Subject: Re: 
> Tomcat Custom Connector> Date: Tue, 3 Jun 2008 19:17:03 -0700> > AFAIK, 
> there isn't a lot of documentation. But there isn't that much too > it. 
> You need to implement a ProtocolHandler > 
> (

>  > This class is responsible for managing the transport (e.g. ServerSocket) 
> and > request threads (but the various EndPoint classes in > 
> may simplify this aspect for you). For best > 
> results, this class may implement ActionHook as well > 
> (>

>  > When a new request comes in, it is the ProtocolHandler's job to 
> initialize a > Request > 
> ( 
>  > and a Response > 
> ( 
>  > objects for it, making certain that they get valid InputBuffer > 
> ( 
>  > and OutputBuffer > 
> ( 
>  > instances to comunicate with the client. Then within the thread, you 
> hand > the Request and Response off to the service method of the Adapter > 
> ( 
>  > that Tomcat will give to the ProtocolHandler. And that is pretty much it 
>  > :).> > Using the standard server.xml (as opposed to Embedding), you 
> would configure > Tomcat to use your Connector with an element like:> 
> <Connector protocol="com.myfirm.mypackage.MyProtocolHandler" ... />> Any 
> other attributes in the <Connector /> tag will be passed JavaBean style > 
> to the ProtocolHandler to handle init options.> > For the simplest 
> example, look at > org.apache.coyote.memory.MemoryProtocolHandler (but 
> this one is mostly > useful for unit testing).> > "Simon Aquilina" 
> <> wrote in message > 
> news:BAY118-W43259A10E2A48EC3FC853F85BA0@phx.gbl...> > Hi,> I am 
> interested in building a custom connector for Tomcat. I have checked > the 
> Tomcat source code and found the source code for the ‘http11’ and ‘ajp’ > 
> connectors. I thought of trying to understand the code of these two > 
> connectors and then try to implement mine based on these. However I am no 
>  > expert and was wondering if there is any good documentation/tutorial on 
> how > a connector can be developed for Tomcat (I would later use this 
> connector > with Geronimo).> Just to give you some insight; what I want to 
> achieve is to build a custom > connector so that Tomcat can understand 
> requests made from a 3rd party > clients who cannot communicate using the 
> Http protocol and nor do they > expect data in html format. Additionally 
> some of the clients could > communicate on Bluetooth!> I do not know if 
> the above is even possible but I am willing to try :)> Thanks for any 
> replies,> Regards,Sim085> 
> _________________________________________________________________> News, 
> entertainment and everything you care about at Get it now!> 
> > > > > 
>  > ---------------------------------------------------------------------> 
> To start a new topic, e-mail:> To unsubscribe, 
> e-mail:> For additional commands, 
> e-mail:>
News, entertainment and everything you care about at Get it now! 

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message