[seam-commits] Seam SVN: r10174 - trunk/src/resteasy/org/jboss/seam/resteasy.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Mar 16 18:51:42 EDT 2009


Author: christian.bauer at jboss.com
Date: 2009-03-16 18:51:42 -0400 (Mon, 16 Mar 2009)
New Revision: 10174

Modified:
   trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyBootstrap.java
   trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyDispatcher.java
Log:
JBSEAM-3965, JBSEAM-4020, registering of Resteasy providers

Modified: trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyBootstrap.java
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyBootstrap.java	2009-03-16 21:26:30 UTC (rev 10173)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyBootstrap.java	2009-03-16 22:51:42 UTC (rev 10174)
@@ -101,25 +101,25 @@
                 if (!seamComponent.getScope().equals(ScopeType.APPLICATION) &&
                         !seamComponent.getScope().equals(ScopeType.STATELESS))
                 {
-                    log.warn("not registering as  provider Seam component, must be APPLICATION or STATELESS scoped: "
-                            + seamComponent.getName());
+                    log.warn("can't add provider Seam component, not APPLICATION or STATELESS scope: " + seamComponent.getName());
+                    log.warn("this provider class will be registered without Seam injection or lifecycle!");
                     seamComponent = null;
                 }
             }
             if (seamComponent != null)
             {
-                log.debug("registering provider Seam component: " + seamComponent.getName());
+                log.debug("adding provider Seam component: " + seamComponent.getName());
             }
             else
             {
-                log.debug("registering provider class: " + providerClass.getName());
+                log.debug("adding provider class: " + providerClass.getName());
             }
             application.addProviderClass(providerClass, seamComponent);
         }
         if (application.getProviderClasses().size() == 0 &&
                 !application.isUseBuiltinProviders())
         {
-            log.info("no RESTEasy provider classes registered");
+            log.info("no RESTEasy provider classes added");
         }
     }
 
@@ -148,11 +148,11 @@
             if (seamComponents.containsKey(resourceClass))
             {
                 seamComponent = seamComponents.get(resourceClass);
-                log.debug("registering resource Seam component: " + seamComponent.getName());
+                log.debug("adding resource Seam component: " + seamComponent.getName());
             }
             else
             {
-                log.debug("registering resource class with JAX-RS default lifecycle: " + resourceClass.getName());
+                log.debug("adding resource class with JAX-RS default lifecycle: " + resourceClass.getName());
             }
             application.addResourceClass(resourceClass, seamComponent);
         }

Modified: trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyDispatcher.java
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyDispatcher.java	2009-03-16 21:26:30 UTC (rev 10173)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyDispatcher.java	2009-03-16 22:51:42 UTC (rev 10174)
@@ -15,14 +15,12 @@
 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
 import org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory;
 import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
-import org.jboss.resteasy.spi.HttpRequest;
-import org.jboss.resteasy.spi.HttpResponse;
-import org.jboss.resteasy.spi.InjectorFactory;
-import org.jboss.resteasy.spi.PropertyInjector;
-import org.jboss.resteasy.spi.Registry;
-import org.jboss.resteasy.spi.ResourceFactory;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.jboss.resteasy.spi.*;
+import org.jboss.resteasy.util.Types;
 
+import java.lang.reflect.Type;
+import java.lang.reflect.ParameterizedType;
+
 /**
  * An extended version of the RESTEasy dispatcher, configured on Seam application
  * startup with a custom JAX RS <tt>Application</tt> instance. Registers custom resource
@@ -47,7 +45,7 @@
     @Create
     public void onStartup()
     {
-        log.debug("assigning registered RESTEasy resources and providers");
+        log.debug("registering RESTEasy and JAX RS resources and providers");
 
         ResteasyProviderFactory providerFactory = new ResteasyProviderFactory();
         ResteasyProviderFactory.setInstance(providerFactory); // This is really necessary
@@ -56,6 +54,56 @@
         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())
+        {
+            log.debug("registering JAX RS provider class: " + providerClass.getName());
+            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());
+                    boolean isStringConverter = false;
+                    for (Class componentIface : seamComponent.getBusinessInterfaces())
+                    {
+                        if (StringConverter.class.isAssignableFrom(componentIface)) {
+                            isStringConverter = true;
+                            break;
+                        }
+                    }
+                    if (isStringConverter) {
+                        log.error("can't register Seam component as RESTEasy StringConverter, see: https://jira.jboss.org/jira/browse/JBSEAM-4020");
+                        //log.debug("registering Seam component as custom RESTEasy string converter provider: " + seamComponent.getName());
+                        //providerFactory.addStringConverter((StringConverter)providerInstance);
+                    } else {
+                        providerFactory.registerProviderInstance(providerInstance);
+                    }
+                }
+            }
+            else
+            {
+                // Just plain RESTEasy, no Seam component lookup or lifecycle
+                if (StringConverter.class.isAssignableFrom(providerClass)) {
+                    log.debug("registering as custom RESTEasy string converter provider class: " + providerClass);
+                    providerFactory.addStringConverter(providerClass);
+                } else {
+                    providerFactory.registerProvider(providerClass);
+                }
+            }
+        }
+
         // Resource registration
         Registry registry = getDispatcher().getRegistry();
         for (final Class resourceClass : application.getClasses())
@@ -104,35 +152,5 @@
             }
         }
 
-        // 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);
-            }
-        }
-
     }
 }




More information about the seam-commits mailing list