You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Sen, Anurag" <as...@ptc.com> on 2018/03/07 09:03:59 UTC

[Tomcat Custom Connector]Private Fields in NIOEndpoint class

Dear Tomcat users/dev team,

I am working on porting an enterprise application from Tomcat 4.x to Tomcat 8.5.x.

Probably you can throw some light on the problem I am facing.
The application that I am porting has a custom protocol(inheriting HTTP11NIOProtocol) and custom endpoint(inheriting NIOEndpoint) written, in order to provide a 'multi-protocol' implementation(BEEP + HTTP) on a unified port.

To this end, the custom endpoint is overriding some functionality from NIOEndpoint class, particularly a custom selector and a custom poller. In Tomcat 4.x, the application was overriding the fields 'selector','poller' & 'nioChannels', which were 'protected' and these were made private in Tomcat 7.x.(I guess), rendering any custom connector unable to access/set such fields, to override functionality.   Commit: https://svn.apache.org/viewvc?view=revision&revision=1425512

From a quick web search, I found a relevant discussion that says that Tomcat connector architecture is HTTP-centric (http://grokbase.com/t/tomcat/users/116xpzc2pz/how-to-create-custom-tomcat-6-connector-to-do-port-sharing)
Is there any recommendation from the Tomcat team for writing custom connectors in 8.5.x. Is it true that Tomcat doesn't encourage non-HTTP connectors/endpoints (seeing the private fields in NIOEndpoint class).

Thanks in advance for your support.

Regards,
Anurag.


Re: [Tomcat Custom Connector]Private Fields in NIOEndpoint class

Posted by Mark Thomas <ma...@apache.org>.
On 07/03/18 12:02, Sen, Anurag wrote:
> 
> 
>> -----Original Message-----
>> From: Mark Thomas [mailto:markt@apache.org]
>> Sent: 07 March 2018 17:17
>> To: users@tomcat.apache.org
>> Subject: Re: [Tomcat Custom Connector]Private Fields in NIOEndpoint class
>>
>> On 07/03/2018 11:05, Sen, Anurag wrote:
>>> Agreed, that Endpoint is protocol agnostic. My query was more in concern
>> with the endpoint implementations being so encapsulated, that it leaves very
>> little scope to extend tomcat endpoints(without actually copy-pasting the code
>> into the custom endpoint).
>>>
>>> I had a look at ALPN usage and I don't see how BEEP using ALPN upgrade can
>> function. Will continue digging.
>>
>> If some refactoring and/or making methods protected and/or adding acessors
>> would help we'd certainly be open to that.
>>
>> The original aim was to reduce the 'public' API to give us greater freedom to
>> refactor. If we know where folks need to extend we can make sure those
>> extension points work as intended.
>>
>> Mark
>>
> 
> Thanks! It will help us tremendously (and other custom connector implementations), if the 'public' API is a bit relaxed, as prior to Tomcat 7.0. I can certainly contribute a patch, if you can point me to how to.

Great.

https://github.com/apache/tomcat/blob/trunk/CONTRIBUTING.md

Mark

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


RE: [Tomcat Custom Connector]Private Fields in NIOEndpoint class

Posted by "Sen, Anurag" <as...@ptc.com>.

> -----Original Message-----
> From: Mark Thomas [mailto:markt@apache.org]
> Sent: 07 March 2018 17:17
> To: users@tomcat.apache.org
> Subject: Re: [Tomcat Custom Connector]Private Fields in NIOEndpoint class
> 
> On 07/03/2018 11:05, Sen, Anurag wrote:
> > Agreed, that Endpoint is protocol agnostic. My query was more in concern
> with the endpoint implementations being so encapsulated, that it leaves very
> little scope to extend tomcat endpoints(without actually copy-pasting the code
> into the custom endpoint).
> >
> > I had a look at ALPN usage and I don't see how BEEP using ALPN upgrade can
> function. Will continue digging.
> 
> If some refactoring and/or making methods protected and/or adding acessors
> would help we'd certainly be open to that.
> 
> The original aim was to reduce the 'public' API to give us greater freedom to
> refactor. If we know where folks need to extend we can make sure those
> extension points work as intended.
> 
> Mark
> 

Thanks! It will help us tremendously (and other custom connector implementations), if the 'public' API is a bit relaxed, as prior to Tomcat 7.0. I can certainly contribute a patch, if you can point me to how to.

Regards,
Anurag. 

Re: [Tomcat Custom Connector]Private Fields in NIOEndpoint class

Posted by Mark Thomas <ma...@apache.org>.
On 07/03/2018 11:05, Sen, Anurag wrote:
> Agreed, that Endpoint is protocol agnostic. My query was more in concern with the endpoint implementations being so encapsulated, that it leaves very little scope to extend tomcat endpoints(without actually copy-pasting the code into the custom endpoint).
> 
> I had a look at ALPN usage and I don't see how BEEP using ALPN upgrade can function. Will continue digging.

If some refactoring and/or making methods protected and/or adding 
acessors would help we'd certainly be open to that.

The original aim was to reduce the 'public' API to give us greater 
freedom to refactor. If we know where folks need to extend we can make 
sure those extension points work as intended.

Mark

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


RE: [Tomcat Custom Connector]Private Fields in NIOEndpoint class

Posted by "Sen, Anurag" <as...@ptc.com>.
> -----Original Message-----
> From: Mark Thomas [mailto:markt@apache.org]
> Sent: 07 March 2018 14:54
> To: Tomcat Users List <us...@tomcat.apache.org>
> Subject: Re: [Tomcat Custom Connector]Private Fields in NIOEndpoint class
> 
> On 07/03/18 09:03, Sen, Anurag wrote:
> > Dear Tomcat users/dev team,
> >
> > I am working on porting an enterprise application from Tomcat 4.x to Tomcat
> 8.5.x.
> >
> > Probably you can throw some light on the problem I am facing.
> > The application that I am porting has a custom protocol(inheriting
> HTTP11NIOProtocol) and custom endpoint(inheriting NIOEndpoint) written, in
> order to provide a 'multi-protocol' implementation(BEEP + HTTP) on a unified
> port.
> >
> > To this end, the custom endpoint is overriding some functionality from
> NIOEndpoint class, particularly a custom selector and a custom poller. In
> Tomcat 4.x, the application was overriding the fields 'selector','poller' &
> 'nioChannels', which were 'protected' and these were made private in Tomcat
> 7.x.(I guess), rendering any custom connector unable to access/set such fields,
> to override functionality.   Commit:
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsvn.apach
> e.org%2Fviewvc%3Fview%3Drevision%26revision%3D1425512&data=02%7C01
> %7Casen%40ptc.com%7C713ac85bc71841507bb408d5840d47ba%7Cb9921086f
> f774d0d828acb3381f678e2%7C0%7C0%7C636560114942155646&sdata=YrFMa
> FlXTOfENvdr7hvfyhBD3toFNkd5KZQ49mNS4bM%3D&reserved=0
> >
> > From a quick web search, I found a relevant discussion that says that
> > Tomcat connector architecture is HTTP-centric
> > (https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgrokb
> > ase.com%2Ft%2Ftomcat%2Fusers%2F116xpzc2pz%2Fhow-to-create-custom-
> tomca
> > t-6-connector-to-do-port-
> sharing&data=02%7C01%7Casen%40ptc.com%7C713ac
> >
> 85bc71841507bb408d5840d47ba%7Cb9921086ff774d0d828acb3381f678e2%7C
> 0%7C0
> >
> %7C636560114942155646&sdata=tdz8kN7WYYdizATZRJkl74cQJ7sn4EGPLfGvxg
> Xxih
> > E%3D&reserved=0) Is there any recommendation from the Tomcat team for
> > writing custom connectors in 8.5.x. Is it true that Tomcat doesn't encourage
> non-HTTP connectors/endpoints (seeing the private fields in NIOEndpoint class).
> >
> > Thanks in advance for your support.
> 
> The Endpoint is protocol agnostic. The current endpoints support HTTP, AJP,
> WebSocket and HTTP/2. Incidently, the HTTP/2 implementation was added
> without requiring a single change to the Endpoint.
> 
> I'd look at a purely custom protocol implementation. If BEEP uses ALPN or HTTP
> upgrade you might find the upgrade handler useful and the HTTP/2
> implementation provides a good example.
> 
> Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

Agreed, that Endpoint is protocol agnostic. My query was more in concern with the endpoint implementations being so encapsulated, that it leaves very little scope to extend tomcat endpoints(without actually copy-pasting the code into the custom endpoint).

I had a look at ALPN usage and I don't see how BEEP using ALPN upgrade can function. Will continue digging.

Thanks,
Anurag.


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


Re: [Tomcat Custom Connector]Private Fields in NIOEndpoint class

Posted by Mark Thomas <ma...@apache.org>.
On 07/03/18 09:03, Sen, Anurag wrote:
> Dear Tomcat users/dev team,
> 
> I am working on porting an enterprise application from Tomcat 4.x to Tomcat 8.5.x.
> 
> Probably you can throw some light on the problem I am facing.
> The application that I am porting has a custom protocol(inheriting HTTP11NIOProtocol) and custom endpoint(inheriting NIOEndpoint) written, in order to provide a 'multi-protocol' implementation(BEEP + HTTP) on a unified port.
> 
> To this end, the custom endpoint is overriding some functionality from NIOEndpoint class, particularly a custom selector and a custom poller. In Tomcat 4.x, the application was overriding the fields 'selector','poller' & 'nioChannels', which were 'protected' and these were made private in Tomcat 7.x.(I guess), rendering any custom connector unable to access/set such fields, to override functionality.   Commit: https://svn.apache.org/viewvc?view=revision&revision=1425512
> 
> From a quick web search, I found a relevant discussion that says that Tomcat connector architecture is HTTP-centric (http://grokbase.com/t/tomcat/users/116xpzc2pz/how-to-create-custom-tomcat-6-connector-to-do-port-sharing)
> Is there any recommendation from the Tomcat team for writing custom connectors in 8.5.x. Is it true that Tomcat doesn't encourage non-HTTP connectors/endpoints (seeing the private fields in NIOEndpoint class).
> 
> Thanks in advance for your support.

The Endpoint is protocol agnostic. The current endpoints support HTTP,
AJP, WebSocket and HTTP/2. Incidently, the HTTP/2 implementation was
added without requiring a single change to the Endpoint.

I'd look at a purely custom protocol implementation. If BEEP uses ALPN
or HTTP upgrade you might find the upgrade handler useful and the HTTP/2
implementation provides a good example.

Mark

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