On Apr 29, 2009, at 10:31 PM, Richard Wallace wrote:
> On Wed, Apr 29, 2009 at 1:10 AM, Paul Sandoz <Paul.Sandoz_at_sun.com>
> wrote:
>>
>> On Apr 28, 2009, at 6:33 PM, Richard Wallace wrote:
>>
>>> Hey Paul,
>>>
>>> The context listener looks ok for the general approach, but still
>>> doesn't solve the problem when running in OSGi because there isn't
>>> really a concept of servlet listeners there (sure you can use Pax
>>> Web
>>> and their extensions, but as of right now there is no standard way
>>> of
>>> registering context listeners).
>>>
>>
>> Oh, i think i misunderstood, i thought a servlet container would
>> still be
>> used? if not then how would HTTP requests be dispatched?
>>
>> I guess i am not understanding the big picture of how things are
>> glued
>> together. When an instance of ServletContainer is obtained what
>> happens
>> next? would the ServletContainer be initialized by calling
>> Servlet.init(ServletConfig ) ?
>>
>
> There is a servlet container, but it's not used by deploying war
> files. Instead, bundles register Servlets with the HttpService
> <http://www.osgi.org/javadoc/r4v41/org/osgi/service/http/HttpService.html
> >.
> The servlet container behind the HttpService then handles initializing
> the Servlet after it's been registered.
>
OK.
>>
>>> For the OSGi use-case, it really would be nice if we had an
>>> additional
>>> constructor that takes a ResourceConfig (to be used as the default
>>> ResourceConfig) and an IoCComponentProviderFactory. This
>>> constructor
>>> could even be restricted to package-only access if the
>>> implementation
>>> of ServletContainerFactory I suggested lived in the
>>> com.sun.jersey.spi.container.servlet package.
>>>
>>
>> OK.
>>
>> One problem is that the ServletContainer does require access to the
>> ServletConfig/ServletContext or FilterConfig/ServletContext, which is
>> obtained when a servlet container calls the init(ServletConfig ) or
>> init(FilterConfig respectively).
>>
>
> Yup, that is done. The problem is, if you look at that HttpService
> interface, there is no way to register context listeners like you were
> talking about. Meaning that we couldn't use them to do the
> initialization of the ResourceConfig, etc.
>
OK, got it now!
>> Perhaps it would be best if the servlet factory returned instance of
>> Servlet?
>>
>
> That's fine, ServletContainer is already an instance of Servlet,
> isn't it?
>
Yes. So we can hide that we are using, or not, ServletContainer.
After being a little slow, i think understand and know what to do now!
After the 1.1.0-ea release i will work on this factory mechanism.
Paul.