users@jersey.java.net

Re: [Jersey] PROPERTY_DEFAULT_RESOURCE_COMPONENT_PROVIDER_FACTORY_CLASS

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 13 Aug 2009 09:50:44 +0200

Hi Craig,

That property is only used for when Jersey life-cycle support is
utilized to specify the default life-cycle.

   https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/core/ResourceConfig.html
#PROPERTY_DEFAULT_RESOURCE_COMPONENT_PROVIDER_FACTORY_CLASS

and it specifies that the class should be of
ResourceComponentProviderFactory:

   https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/server/spi/component/ResourceComponentProviderFactory.html


Do you want to use the Grizzly servlet support or the lower-level
Grizzly adapter support?

For servlet support you can register an instance of the
GuiceComponentProviderFactory in the singletons of the ResourceConfig,
you can use DefaultResourceConfig if all your resource/provider
classes are Guice managed. But i think it would be better to extend
the GuiceContainer and use that instead because that means the request
life-cycle can be supported.

For lower-level Grizzly support you can:

1) register an instance of the GuiceComponentProviderFactory in the
singletons of the ResourceConfig, you can use
      DefaultResourceConfig if all your resource/provider classes are
Guice managed; or

1) use ContainerFactory directly and call:

   https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/container/ContainerFactory.html
#createContainer%28java.lang.Class,
%20com.sun.jersey.api.core.ResourceConfig,
%20com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory%29

    and also use DefaultResourceConfig.

      DefaultResourceConfig rc = ...
      GuiceComponentProviderFactory f = ...
      Adapter a = ContainerFactory.createContainer(Adapter.class, rc,
factory);

   and then you will need to wire up the Adapter to Grizzly yourself.

Paul.



On Aug 12, 2009, at 11:47 PM, Craig McClanahan wrote:

> As part of an experiment, I am trying to integrate Jersey and Guice,
> but in a standalone Java SE application using Grizzly, rather than
> in a webapp. The question becomes, how does one tell Jersey about
> the GuiceComponentProviderFactory class from jersey-guice? The
> documentation on this ResourceConfig property is that the value must
> be a Java *class* that implements IoCComponentProviderFactory ...
> but what I need to pass is an *instance* of this class (there is no
> no-args constructor ... you have to pass in the ResourceConfig and
> the Guice injector).
>
> How do I get this thing configured in a Java SE standalone scenario?
>
> Craig
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>