Hi Gili,
Unfortunately it is too late to get the Guice support into the 1.0.2
release. Still too many unknowns. As soon as we switch the trunk over
to the 1.0.3.SNAPSHOT i will include the guice module based on your
patch. Let's work together to get this into the 1.0.3 release.
Paul.
On Feb 3, 2009, at 5:32 PM, Paul Sandoz wrote:
> Hi Gili,
>
> Thanks for the attachment in the issue. I find it easier to have the
> discussion on the mailing list rather than in the issue tracker.
>
> It appears that the Guice integration is not working properly. There
> is something wrong with the logic in the
> GuiceComponentProviderFactory.register method.
>
> private void register(ResourceConfig config, Injector injector)
> {
> for (Key<?> key: injector.getBindings().keySet())
> {
> Type abstractType = key.getTypeLiteral().getType();
> Class<?> type;
> if (abstractType instanceof ParameterizedType) <---- IS THIS
> CORRECT?
> {
> ParameterizedType parameterized = (ParameterizedType)
> abstractType;
> type = (Class<?>) parameterized.getRawType();
> }
> else
> {
> // do nothing
> return; <---- IS THIS CORRECT?
> }
> if (ResourceConfig.isProviderClass(type))
> {
> config.getClasses().add(type);
> }
> else if (ResourceConfig.isRootResourceClass(type))
> {
> config.getClasses().add(type);
> }
> }
> }
>
>
> No classes get added to ResourceConfig. I think this is because the
> abstractType is of the expected type.
>
> Thus the code falls back onto the default class scanning to register
> the root resource classes. We need to support the default case where
> no Jersey specific registration occurs, as with Spring. The Guice
> servlet needs to be modified to provide a default resource config
> instance as follows (if using the latest source from the trunk):
>
> @Override
> protected ResourceConfig getDefaultResourceConfig(Map<String,
> Object> props,
> WebConfig webConfig) throws ServletException {
> DefaultResourceConfig rc = new DefaultResourceConfig();
> rc.setPropertiesAndFeatures(props);
> return rc;
> }
>
>
>
> Then the example classes (ConstructorInjection,
> DefaultConstructorInjection) use the
> GuiceInstantiatedComponentProvider when i would expect then to use
> the GuiceManagedComponentProvider, although i am guessing i do not
> understand what needs to be done in this respect.
>
> Paul..
>
> On Feb 2, 2009, at 3:00 PM, Paul Sandoz wrote:
>
>> Hi Gili,
>>
>> I have attached a sample Guice module (my second attachment [1]) to
>> the Guice-related issue:
>>
>> https://jersey.dev.java.net/issues/show_bug.cgi?id=163
>>
>> I need some help if you want this to be part of the 1.0.2 release
>> as i cannot include this in a stable release without the following:
>>
>> 1) examples of the web.xml in the JavaDoc; and
>>
>> 2) unit tests to exercise resource classes that are scoped to
>> singleton and per-request.
>>
>> and time is short.
>>
>> If you can provide some simple examples with the latest maven
>> module [1] attached to the issue i can then use the web.xml and the
>> resource classes for unit tests.
>>
>> Thanks,
>> Paul.
>>
>> [1] https://jersey.dev.java.net/nonav/issues/showattachment.cgi/25/jersey-guice.zip
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>