Mohan K R wrote:
> Kohsuke,
>
> Thanks for the reply.
>
> I was trying to draw the analogy from Spring MVC, in that scenario a IoC
> Container heirarchy is created with the root
> being the bean factory (ApplicationContext) initialized by the Spring
> Context Loader Listener. Then, the dispatcher
> servlet (in this case WSSpringServlet) would create its own
> ApplicationContext and tag itself as child of the "root"
> context created by the ContextLoaderListener. Now, it is debatable the
> benefits of creating an IoC Hierarchy!
OK. I see. So the idea is that by creating a hierarchy, you can avoid
name collisions among beans. Is that right? I guess that makes sense.
Now, my question is how do I/users create a child IoC context?
> About the other question, yes wac is the WebApplicationContext, which is the
> IoC container, so it is like a Chicken
> and egg thing, I cannot inject it into the SEI. I need to access the IoC so
> that I can retrieve the beans needed to initialize
> the SEI properly. Currently the way to get the "wac" (that I know of) is
> using the ServletContext. But, in JAX-WS 2.0
> I cannot seem to figure out how to get the ServletContext in a @PostContruct
> annotated Method.
I see.
Since your SEI is now a Spring-configured bean, you can get all kinds of
dependencies injected into your SEI bean by Spring, without writing any
explicit code to access WebApplicationContext. Is that not enough? Do
you still need to get access to WebApplicationContext?
And more importantly, when Spring injects dependencies into your SEI, I
thought it should be able to inject the WebApplicationContext itself to
your SEI, maybe by using a reserved bean name or something --- I'm just
talking what I would have done if I were implementing Spring, so I don't
know if it's actually capable of doing that, but don't you think it should?
If we can programmatically export a bean to the namespace of Spring, I
can have WSSpringServlet inject ServletContext as a bean, but it doesn't
look like there's a way to do that.
In a sense this seems to be a generic problem in Spring, not a JAX-WS
problem. Essentially the problem seems to me that you want Spring to
inject ServletContext into places where you need it, yet it doesn't seem
to be able to do. Shouldn't this be fixed in Spring? Or am I making a
wrong assumption somewhere?
> I can get the
> servletcontext by @Resource injection trick but it only works for @WebMethod
> methods. I would like to get a
> reference to the IoC only once at SEI *initialization* phase (preferably in
> @PostContstruct) but I don't know how to do
> this in JAX-WS 2.0? I have seen some posts where the suggestion was to use
> the JAX-RPC Lifecycle methods for SEI,
> but I don;t know whether it is OK to use that if I am migrating to JAX-WS
> 2.0.
>
> Thanks
> Mohan
>
>
>
> On 12/12/06, Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_sun.com> wrote:
>>
>> Mohan K R wrote:
>> > Koshuke,
>> > Thanks for the reply and great work with with updating the maven repo.
>> >
>> > Yes, I did look at the documentation. It appears that uses Spring IoC
>> and
>> > xml
>> > schema extension capability to replace sun-jaxws.xml, which I definitely
>> > like.
>>
>> Good.
>>
>> > My question was really how do I get access to the wac in the SEI? I
>> guess I
>> > could
>> > get it in a roundabout way by using @Resource -> webServiceContext.
>>
>> Pardon my ignorance, but what is 'wac'?
>> org.springframework.web.context.WebApplicationContext?
>>
>> I'm no Spring expert, but since now your SEI is configured by Spring,
>> shouldn't it be able to inject WebApplicationContext for you?
>>
>>
>> > It would be nice if the WSSpringServlet supported it's own IoC which
>> would
>> > be a child
>> > of wac (from the contextLoader Listener) and the jax-ws.http bean be
>> > retrieved from it.
>>
>> I'm new to Spring and therefore I don't quite understand what you are
>> saying. Any pointer to the Spring documentation would be appreciated.
>>
>>
>> --
>> Kohsuke Kawaguchi
>> Sun Microsystems kohsuke.kawaguchi_at_sun.com
>>
>>
>>
>
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com