[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-4020) Custom RESTEasy StringConverter provider classes need special registration

Christian Bauer (JIRA) jira-events at lists.jboss.org
Mon Mar 16 18:49:22 EDT 2009

    [ https://jira.jboss.org/jira/browse/JBSEAM-4020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12457562#action_12457562 ] 

Christian Bauer commented on JBSEAM-4020:

This works OK if the StringProvider instance is a POJO but it can not be a Seam component. 

The ResteasyProviderFactory SPI only offers two methods to register a StringConverter, one takes a class and calls newInstance() and the other one expects an instance. 

However, the version that expects an instance then inspects the interfaces to find the generic type arguments, so that it can register the converter properly for that target type:

   public void addStringConverter(StringConverter provider)
      providers.put(provider.getClass(), provider);
      PropertyInjectorImpl injector = new PropertyInjectorImpl(provider.getClass(), this);
      Type[] intfs = provider.getClass().getGenericInterfaces();

This doesn't work if the provider instance is a Seam component, hence a Javassist proxy:

GENERIC INTERFACES: interface org.jboss.seam.Instance
GENERIC INTERFACES: interface org.jboss.seam.intercept.Proxy
GENERIC INTERFACES: interface javax.servlet.http.HttpSessionActivationListener
GENERIC INTERFACES: interface org.jboss.seam.core.Mutable
GENERIC INTERFACES: interface javassist.util.proxy.ProxyObject

The knowledge of the real generic interface and the target type of a StringConverter is only available outside of Resteasy, to Seam when we inspect the component metadata. So the ResteasyProviderFactory SPI needs an additional method:

   public void addStringConverter(StringConverter provider, Class convertedType)
        stringConverters.put(convertedType, provider);

> Custom RESTEasy StringConverter provider classes need special registration
> --------------------------------------------------------------------------
>                 Key: JBSEAM-4020
>                 URL: https://jira.jboss.org/jira/browse/JBSEAM-4020
>             Project: Seam
>          Issue Type: Task
>          Components: WS
>            Reporter: Christian Bauer
>            Assignee: Christian Bauer
> RESTEasy offers a custom StringConverter provider extension. Unlike normal providers, the SPI in RESTEasy for registration of these providers is different:
>                 if (StringConverter.class.isAssignableFrom(providerClass)) {
>                     providerFactory.addStringConverter(providerClass);
>                 } else {
>                     providerFactory.registerProvider(providerClass);
>                 }
> This needs to be fixed in RestEasyDispatcher.java

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the seam-issues mailing list