You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Kennard <pe...@livingwork.com> on 2007/03/02 17:34:39 UTC

Writing My Own Connector

I want to write my own "protocol handler" which I can configure as a 
connector. I want it to do something along the lines of AJP - packet 
hits in, servlet hits out.

     <Connector port="x" protocol="com.mydom.mypackage.MyProtocolHandler"
.... />

A - should I be posting this to a "dev" list?

B - I want a good reference on what class I need to subclass, how to
     use it and what are considered this abilities "supported" features.
     What is the best book or doc I should look at for this?

Thanks much!
Peter K.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Writing My Own Connector

Posted by Peter Kennard <pe...@livingwork.com>.
Thanks very much!

The big hope is all the socket connection and thread pool management 
"wheel re-inventing" etc is "done" and I can do it mostly "high 
level" except for the interpreting of the input protocol byte 
streams.  Have it do somehing like:

ProtocolConnectorThread.onListenerConnect(inputStream, outputStream)
{
    try {

        request = mypool.getARequest(inputStream,this);
        response = mypool.getAResponse(outputStream,this);

        for(;;)
        {
            ( parse stuff in protocol header inputStream,
              deal with protocol  };
             request.resetAndSetStuff(inputStream,stuff);
             response.resetAndSetStuff(outputStream,stuff);
              routeToServelet("urlName",request,response);
        }
     }
     catch(ServletOopsException oe)
     {
         Oops, respond to sender "I'm Dead" on output, kill socket
     }
     mypool.reclaim(request);
     mypool.reclaim(response);
}



At 23:03 3/2/2007, you wrote:

>"Peter Kennard" <pe...@livingwork.com> wrote in message
>news:6.2.3.4.1.20070302170711.01cb85e8@pop.gmail.com...
> > would definately be someting to do.
> > one has to wade through a lot of stuff to get to that point :)
> > I have to find out where what defines a connector is, how it is installed
> > and configured ...
> >
>
>Well, the first thing that you need is a ProtocolHandler
>(http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/coyote/ProtocolHandler.html). 
>
>Any attributes that are put into the <Connector /> element will be passed
>JavaBean-style to your ProtocolHandler, so you can take care of
>configuration that way.  It is the job of the ProtocolHandler to accept
>requests, manage threads, and pass the request back off to the Adapter
>(http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/coyote/Adapter.html) 
>
>that Tomcat gives it.  Most of the time, you will also need to implement
>ActionHook
>(http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/coyote/ActionHook.html) 
>
>for best results.
>
>You mentioned something about modifying the AJP Connector.  The JK AJP
>Connector (the one under o.a.jk) has a plugable archatecture that may allow
>you to reuse some of the bits (in particular,
>ChannelSocket/ChannelNioSocket) if your protocol is close enough (or you can
>change it to be :).
>
> > So what people are saying is "get the source and build it" as step #1 ??
> >
> > At 16:38 3/2/2007, you wrote:
> >>Seems to me that looking at the differences in source between two
> >>connectors (e.g. AJP and HTTP) would be the best documentation of
> >>what you'll have to change :-)
> >
>
>As of TC 6, there are 3 supported AJP Connectors, and 3 supported HTTP
>connectors ;-).
>
> >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
>
>
>
>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Writing My Own Connector

Posted by Bill Barker <wb...@wilshire.com>.
"Peter Kennard" <pe...@livingwork.com> wrote in message 
news:6.2.3.4.1.20070302170711.01cb85e8@pop.gmail.com...
> would definately be someting to do.
> one has to wade through a lot of stuff to get to that point :)
> I have to find out where what defines a connector is, how it is installed 
> and configured ...
>

Well, the first thing that you need is a ProtocolHandler 
(http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/coyote/ProtocolHandler.html). 
Any attributes that are put into the <Connector /> element will be passed 
JavaBean-style to your ProtocolHandler, so you can take care of 
configuration that way.  It is the job of the ProtocolHandler to accept 
requests, manage threads, and pass the request back off to the Adapter 
(http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/coyote/Adapter.html) 
that Tomcat gives it.  Most of the time, you will also need to implement 
ActionHook 
(http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/coyote/ActionHook.html) 
for best results.

You mentioned something about modifying the AJP Connector.  The JK AJP 
Connector (the one under o.a.jk) has a plugable archatecture that may allow 
you to reuse some of the bits (in particular, 
ChannelSocket/ChannelNioSocket) if your protocol is close enough (or you can 
change it to be :).

> So what people are saying is "get the source and build it" as step #1 ??
>
> At 16:38 3/2/2007, you wrote:
>>Seems to me that looking at the differences in source between two
>>connectors (e.g. AJP and HTTP) would be the best documentation of
>>what you'll have to change :-)
>

As of TC 6, there are 3 supported AJP Connectors, and 3 supported HTTP 
connectors ;-).

>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Writing My Own Connector

Posted by Peter Kennard <pe...@livingwork.com>.
would definately be someting to do.
one has to wade through a lot of stuff to get to that point :)
I have to find out where what defines a connector is, how it is 
installed and configured ...

So what people are saying is "get the source and build it" as step #1 ??

At 16:38 3/2/2007, you wrote:
>Seems to me that looking at the differences in source between two
>connectors (e.g. AJP and HTTP) would be the best documentation of
>what you'll have to change :-)



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Writing My Own Connector

Posted by Hassan Schroeder <ha...@gmail.com>.
On 3/2/07, Peter Kennard <pe...@livingwork.com> wrote:

> What I would like to do is take an AJP connector,
> redo it's insides to parse another format and
> then pass the requests off to servlets.

Seems to me that looking at the differences in source between two
connectors (e.g. AJP and HTTP) would be the best documentation of
what you'll have to change :-)

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Writing My Own Connector

Posted by Peter Kennard <pe...@livingwork.com>.
>I think the existing connectors in tomcat source could be the only
>existing documentation :)

Not a good sign for them being "officially" supported.
Has anyone here made one?

What I would like to do is take an AJP connector, 
redo it's insides to parse another format and 
then pass the requests off to servlets.

At 15:53 3/2/2007, David Delbecq wrote:
>Peter Kennard a écrit :
> > I want to write my own "protocol handler" which I can configure as a
> > connector. I want it to do something along the lines of AJP - packet
> > hits in, servlet hits out.
> >
> > B - I want a good reference on what class I need to subclass, how to
> >     use it and what are considered this abilities "supported" features.
> >     What is the best book or doc I should look at for this?




>---------------------------------------------------------------------
>To start a new topic, e-mail: users@tomcat.apache.org
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Writing My Own Connector

Posted by David Delbecq <de...@oma.be>.
Peter Kennard a écrit :
> I want to write my own "protocol handler" which I can configure as a
> connector. I want it to do something along the lines of AJP - packet
> hits in, servlet hits out.
>
> B - I want a good reference on what class I need to subclass, how to
>     use it and what are considered this abilities "supported" features.
>     What is the best book or doc I should look at for this?
I think the existing connectors in tomcat source could be the only
existing documentation :)

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org