Details
-
Wish
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
4.0-alpha6
-
None
-
Java 5. Dev platform is OS X Leopard but I doubt that's relevant.
Description
It appears that for developing a server application using NIO, you can't easily define a replacement HttpRequestFactory. It's hardcoded to create a new DefaultHttpRequestFactory in DefaultServerIOEventDispatch, in a method that can't be overridden because the subclass method also references a private data member (the allocator) of DefaultServerIOEventDispatch. It could be done by also instantiating and supplying an external ByteBufferAllocator in the overridden method, which "wastes" the instance created in the constructor. (I notice the constructor that lets you supply an allocator in 4.0-alpha6 is gone from later versions - but I'm not even interested in replacing the allocator, I just want to replace the request factory.)
The way I am doing it is by actually copying the current source of DefaultServerIOEventDispatch to my project (with a rename) to make my own modified version to implement IOEventDispatch - which seems excessive for the small change I actually want. The change I made was simply to have a constructor that allows me to supply an already-instantiated HttpRequestFactory, in a similar fashion to the constructor of BufferingHttpServiceHandler takes an instantiated HttpResponseFactory.
This also stops this IOEventDispatch from creating a new instance of the factory for each hit, which it seems to be doing at the moment...