users@grizzly.java.net

Re: Follow up on ServletAdapter

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Tue, 07 Apr 2009 17:15:49 -0400

Salut,

Bhakti Mehta wrote:
> JFA,
> Please read inline sorry for the delay in replying
>
> Jeanfrancois Arcand wrote:
>> Salut,
>>
>> Hubert Iwaniuk wrote:
>>> Hi,
>>>
>>> Let's see if I can help you on this.
>>>
>>> 1. You should maintain one GWS and when you are registering endpoint
>>> just register new GrizzlyAdapter within onw GWS,
>>
>> The situation is difference for Bhakti as it needs to run inside
>> GlassFish and the GrizzlyAdapterChain is not available.
>>
>> Bhaki, you need to invoke
>> kernel/src/main/java/com/sun/enterprise/v3/services/impl/GrizzlyProxy.registerEndpoint()
>>
>
>
> EjbWebServiceAdapter ejbWSAdapter = new
> EjbWebServiceAdapter(ctxtRoot);
>
> HttpService httpService =
> Globals.getDefaultHabitat().getComponent(HttpService.class);
>
> HttpListener listener =
> httpService.getHttpListener().get(0);
> GrizzlyService grizzlyService =
> Globals.getDefaultHabitat().getComponent(GrizzlyService.class);
> GrizzlyProxy proxy = new GrizzlyProxy(grizzlyService
> ,listener,httpService);
> Collection<String> vs = new ArrayList<String> () ;
> vs.add(listener.getDefaultVirtualServer()) ;
>
> proxy.registerEndpoint(ctxtRoot,
> vs,(Adapter)ejbWSAdapter,new DummyApplication());
>
>
> where EjbWebServiceAdapter extends ServletAdapter implements
> org.glassfish.api.container.Adapter
> Is the above snippet ok?

Not sure. The GrizzpyProxy instance must have been created already by
the v3 kernel so I would think you need to grab that instance instead of
creating a new one. That way you don't need to handle the vs stuff (just
  pass null).


I am unsure about the vs information to pass so
> just created new ArrayList with defaultVirtualServer but I cannot get
> the service method of my adapter invoked.
> I get 404
> In the debugger I see the mapper of ContainerMapper is V3Mapper and
> StaticResourcesAdapter's service method is called and resource is
> expected to be <my
> installation>/domains/domain1/docroot/HelloImplService/HelloImpl line
> 177 of StaticResourceAdapter and then I get 404
>
> Please can you let me know if I am doing something terribly wrong.

No this is all new so nothing is wrong :-) If you end s up in
StaticResourcesAdapter it means the ContainerMapper wasn't able to map
the request to your Adapter.

Hope that help. Ping me for any questions.

A+

-- Jeanfrancois



> Thanks,
> Bhakti
>
>>
>>
>>> 2. service method of Servlet is called when all your configured
>>> filter has been successfully processed (invoked chain.doFilter()),
>>
>> And when a request maps to your Adapter. In GlassFish, the mapping
>> happens inside the ContainerMapper class (under the same package than
>> GrizzlyProxy)/
>>
>>
>>> 3. ServletAdapter has "protected ServletContextImpl getServletCtx()".
>>
>> Right. Bhaki, is it an issue? File an issue here:
>>
>> https://grizzly.dev.java.net/issues/
>>
>> and next version I will change the scope.
>>
>> Thanks
>>
>> -- Jeanfrancois
>>
>>
>>>
>>> HTH,
>>> Hubert
>>>
>>>
>>> On Wed, Apr 1, 2009 at 6:26 PM, Bhakti Mehta <Bhakti.Mehta_at_sun.com
>>> <mailto:Bhakti.Mehta_at_sun.com>> wrote:
>>>
>>> Hi,
>>> I did some experiments yesterday in a branch so wanted some feedback
>>> from you folks
>>>
>>> I use dispatcher to register the servlet adapter with the context
>>> root as shown here. This is done whenever the
>>> StatelessSessionContainer calls the WebservicesEjbEndpointRegistery
>>> to register an ejb endpoint
>>>
>>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/branches/bhakti/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServiceEjbEndpointRegistry.java?view=diff&rev=25777&p1=branches/bhakti/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServiceEjbEndpointRegistry.java&p2=branches/bhakti/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServiceEjbEndpointRegistry.java&r1=25776&r2=25777
>>>
>>>
>>> <https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/branches/bhakti/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServiceEjbEndpointRegistry.java?view=diff&rev=25777&p1=branches/bhakti/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServiceEjbEndpointRegistry.java&p2=branches/bhakti/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServiceEjbEndpointRegistry.java&r1=25776&r2=25777>
>>>
>>>
>>>
>>> This is the code for my ServletAdapter
>>>
>>> https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/branches/bhakti/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/EjbWebServiceAdapter.java?view=auto&rev=25777
>>>
>>>
>>> <https://glassfish-svn.dev.java.net/source/browse/glassfish-svn/branches/bhakti/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/EjbWebServiceAdapter.java?view=auto&rev=25777>
>>>
>>>
>>> I could see the service method invoked of the EjbWebservicesAdapter,
>>> so far so good.
>>>
>>> I had 2 questions
>>> 1. The GrizzlyWebserver should be started earlier and just once and
>>> stopped at the end. I keep getting Address 8080 already in used if I
>>> start and stop at the WebservicesEjbEndpointRegistry level every
>>> time I register and unregister an ejb endpoint (I even tried in
>>> static initializer but ran into errors and do not think that is
>>> right)
>>>
>>>
>>> 2.If I have a servletInstance set on ServletAdapter when does it's
>>> service method be invoked ? Maybe I missed it I could not figure
>>> that.
>>>
>>> 3.From the ServletAdapter if I want to get the ServletContext how do
>>> I get that.
>>>
>>> Please let me know Sorry if these are very obvious
>>>
>>> Thanks,
>>> Bhakti
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>> <mailto:users-help_at_grizzly.dev.java.net>
>>>
>>>