Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-3965

@Providers not working - ResteasyDispatcher registers components and providers in wrong order

    Details

      Description

      While using the latest nightly build (from 2009.02.19) I found that my @Provider annotated class is not used by Seam+RESTEasy. It seemed to be loaded but not used by injection mechanism. By debugging the code I found out that it is not used because org.jboss.seam.resteasy.ResteasyDispatcher#onStartup() first registers the resources and after that the providers. However, as part of the resource registration the injection mechanism including the converters are set up, however at this point the converters (providers) have not been loaded.

      It seems to first load the providers and then the resources.

      This is my patch that worked in my setup:

      > diff -c ResteasyDispatcher.java ResteasyDispatcher_orig.java

          • ResteasyDispatcher.java 2009-02-20 11:10:35.000000000 +0100
          • ResteasyDispatcher_orig.java 2009-02-19 00:18:26.000000000 +0100
          • 56,91 ****
            getDispatcher().setLanguageMappings(application.getLanguageMappings());
            getDispatcher().setMediaTypeMappings(application.getMediaTypeMappings());
      • // Provider registration
      • if (application.isUseBuiltinProviders())
      • { - log.info("registering built-in RESTEasy providers"); - RegisterBuiltin.register(providerFactory); - }
      • for (Class providerClass : application.getProviderClasses())
      • {
      • Component seamComponent = application.getProviderClassComponent(providerClass);
      • if (seamComponent != null)
      • {
      • if (ScopeType.STATELESS.equals(seamComponent.getScope()))
      • { - throw new RuntimeException( - "Registration of STATELESS Seam components as RESTEasy providers not implemented!" - ); - }
      • else if (ScopeType.APPLICATION.equals(seamComponent.getScope()))
      • { - Object providerInstance = Component.getInstance(seamComponent.getName()); - providerFactory.registerProviderInstance(providerInstance); - }
      • }
      • else
      • { - // Just plain RESTEasy, no Seam component lookup or lifecycle - providerFactory.registerProvider(providerClass); - }
      • }
      • // Resource registration
        Registry registry = getDispatcher().getRegistry();
        for (final Class resourceClass : application.getClasses())

          • 56,61 ----
          • 133,137 ****
          • 103,138 ----
            registry.addResourceFactory(new POJOResourceFactory(resourceClass));
            }
            }
            +
            + // Provider registration
            + if (application.isUseBuiltinProviders())
            + { + log.info("registering built-in RESTEasy providers"); + RegisterBuiltin.register(providerFactory); + }

            + for (Class providerClass : application.getProviderClasses())
            + {
            + Component seamComponent = application.getProviderClassComponent(providerClass);
            + if (seamComponent != null)
            +

            Unknown macro: {+ if (ScopeType.STATELESS.equals(seamComponent.getScope()))+ { + throw new RuntimeException( + "Registration of STATELESS Seam components as RESTEasy providers not implemented!" + ); + }+ else if (ScopeType.APPLICATION.equals(seamComponent.getScope()))+ { + Object providerInstance = Component.getInstance(seamComponent.getName()); + providerFactory.registerProviderInstance(providerInstance); + }+ }

            + else
            +

            { + // Just plain RESTEasy, no Seam component lookup or lifecycle + providerFactory.registerProvider(providerClass); + }

            + }
            +
            }
            }

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  christian.bauer Christian Bauer
                  Reporter:
                  beepbeep Balazs Pataki
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: