[seam-commits] Seam SVN: r8458 - in trunk: src/resteasy/org/jboss/seam/resteasy and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Jul 14 08:42:06 EDT 2008


Author: christian.bauer at jboss.com
Date: 2008-07-14 08:42:05 -0400 (Mon, 14 Jul 2008)
New Revision: 8458

Added:
   trunk/src/resteasy/org/jboss/seam/resteasy/ApplicationConfig.java
   trunk/src/resteasy/org/jboss/seam/resteasy/package-info.java
Modified:
   trunk/doc/Seam_Reference_Guide/en-US/Webservices.xml
   trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyBootstrap.java
   trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyDispatcher.java
   trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java
   trunk/src/resteasy/org/jboss/seam/resteasy/reasteasy-2.1.xsd
Log:
Implemented RESTEasy integration XSD, cleanup

Modified: trunk/doc/Seam_Reference_Guide/en-US/Webservices.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Webservices.xml	2008-07-14 11:30:32 UTC (rev 8457)
+++ trunk/doc/Seam_Reference_Guide/en-US/Webservices.xml	2008-07-14 12:42:05 UTC (rev 8458)
@@ -118,18 +118,18 @@
   
   <sect1>
     <title>An example web service</title>
-    
+
     <para>
       Let's walk through an example web service.  The code in this section all comes from the seamBay example
       application in Seam's <literal>/examples</literal> directory, and follows the recommended strategy as
-      described in the previous section.  Let's first take a look at the web service class and one of its web 
+      described in the previous section.  Let's first take a look at the web service class and one of its web
       service methods:
     </para>
-    
+
     <programlisting role="JAVA"><![CDATA[@Stateless
 @WebService(name = "AuctionService", serviceName = "AuctionService")
 public class AuctionService implements AuctionServiceRemote
-{           
+{
    @WebMethod
    public boolean login(String username, String password)
    {
@@ -138,7 +138,7 @@
       Identity.instance().login();
       return Identity.instance().isLoggedIn();
    }
-   
+
    // snip
 }]]></programlisting>
 
@@ -198,5 +198,70 @@
 
   </sect1>
 
+   <sect1>
+     <title>RESTful HTTP webservices with RESTEasy</title>
 
+     <para>
+        Seam integrates the RESTEasy implementation of the JAX-RS specification (JSR 311). You can decided how
+        "deep" the integration into your Seam application is going to be: From simple integration of configuration
+        and bootstrap, serving the requests with the built-in Seam resource servlet, writing resources as
+        Seam components, and integration with conversations and the Seam CRUD Application Framework.
+     </para>
+
+      <sect2>
+         <title>RESTEasy bootstrap and request handling</title>
+
+         <para>
+            First, get the RESTEasy libraries and the <literal>jaxrs-api.jar</literal>, deploy it with the
+            other libraries of your application. Also deploy the integration library, <tt>jboss-seam-resteasy.jar</tt>
+         </para>
+
+         <para>
+            On startup, all classes annotated <literal>@javax.ws.rs.Path</literal> will be discovered automatically
+            and registered as HTTP resources. Seam will serve any HTTP request automatically under the URL basepath
+            you mapped the <literal>SeamResourceServlet</literal> at in <tt>web.xml</tt>. Most of the time and if you
+            follow this documentation, this would be <literal>/seam/resource</literal>.
+            The hardcoded full path of your RESTful resources is therefore <literal>/seam/resource/rest</literal>.
+         </para>
+
+         <para>
+            The following resource would serve a representation under
+            <literal>http://your.hostname/seam/resource/reset/item/123</literal>:
+         </para>
+
+         <programlisting role="JAVA"><![CDATA[@Path("/item")
+public class ItemResource {
+
+    @GET
+    @Path("/item/{itemId}")
+    @ProduceMime("text/plain")
+    public String getItem(@PathParam("itemId") int itemId) {
+         return ...;
+    }
+}]]></programlisting>
+
+         <para>
+            TODO: This is not true, today you need @Path("/seam/resource/rest/item") on the resource class, we need
+            to implement some base-path mapping there.
+         </para>
+
+         <para>
+            You can configure the <literal>/seam/resource</literal> part by specifying a new mapping in web.xml
+            for the <tt>SeamResourceServlet</tt>. Note that this also changes the URI path for all other resources
+            you want to serve with this servlet! You can not change the <literal>/rest</literal> segement of the path,
+            unless you subclass and override the <literal>ResteasyResourceAdapter.getResourcePath()</literal> method.
+         </para>
+
+         <para>
+            TODO: TBC...
+         </para>
+
+      </sect2>
+
+<!--
+     <programlisting role="JAVA"><![CDATA[
+]]></programlisting>
+-->
+   </sect1>
+
 </chapter>

Copied: trunk/src/resteasy/org/jboss/seam/resteasy/ApplicationConfig.java (from rev 8455, trunk/src/resteasy/org/jboss/seam/resteasy/RestApplicationConfig.java)
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/ApplicationConfig.java	                        (rev 0)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/ApplicationConfig.java	2008-07-14 12:42:05 UTC (rev 8458)
@@ -0,0 +1,159 @@
+package org.jboss.seam.resteasy;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.Component;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Install;
+
+import javax.ws.rs.core.MediaType;
+import java.util.*;
+
+/**
+ * Resteasy and JAX-RS configuration, override in components.xml to
+ * customize Resteasy settings.
+ *
+ * @author Christian Bauer
+ */
+ at Name("org.jboss.seam.resteasy.applicationConfig")
+ at Scope(ScopeType.APPLICATION)
+ at Install(precedence = Install.BUILT_IN)
+ at AutoCreate
+public class ApplicationConfig extends javax.ws.rs.core.ApplicationConfig
+{
+
+    private Map<Class<?>, Component> providerClasses = new HashMap<Class<?>, Component>();
+    private Map<Class<?>, Component> resourceClasses = new HashMap<Class<?>, Component>();
+
+    private List<String> providerClassNames = new ArrayList<String>();
+    private List<String> resourceClassNames = new ArrayList<String>();
+
+    private Map<String, String> mediaTypeMappings = new HashMap<String, String>();
+    private Map<String, String> languageMappings = new HashMap<String, String>();
+
+    private boolean scanProviders = true;
+    private boolean scanResources = true;
+    private boolean useBuiltinProviders = true;
+
+    public ApplicationConfig()
+    {
+        super();
+    }
+
+    public Set<Class<?>> getProviderClasses()
+    {
+        return providerClasses.keySet();
+    }
+
+    public Set<Class<?>> getResourceClasses()
+    {
+        return resourceClasses.keySet();
+    }
+
+    public void addProviderClass(Class<?> clazz, Component component)
+    {
+        providerClasses.put(clazz, component);
+    }
+
+    public void removeProviderClass(Class<?> clazz)
+    {
+        providerClasses.remove(clazz);
+    }
+
+    public void addResourceClass(Class<?> clazz, Component component)
+    {
+        resourceClasses.put(clazz, component);
+    }
+
+    public void removeResourceClass(Class<?> clazz)
+    {
+        resourceClasses.remove(clazz);
+    }
+
+    public Component getProviderClassComponent(Class clazz)
+    {
+        return providerClasses.get(clazz) != null ? providerClasses.get(clazz) : null;
+    }
+
+    public Component getResourceClassComponent(Class clazz)
+    {
+        return resourceClasses.get(clazz) != null ? resourceClasses.get(clazz) : null;
+    }
+
+    public Map<String, MediaType> getMediaTypeMappings()
+    {
+        Map<String, MediaType> extMap = new HashMap<String, MediaType>();
+        for (String ext : mediaTypeMappings.keySet())
+        {
+            String value = mediaTypeMappings.get(ext);
+            extMap.put(ext, MediaType.valueOf(value));
+        }
+        return extMap;
+    }
+
+    public void setMediaTypeMappings(Map<String, String> mediaTypeMappings)
+    {
+        this.mediaTypeMappings = mediaTypeMappings;
+    }
+
+    public Map<String, String> getLanguageMappings()
+    {
+        return languageMappings;
+    }
+
+    public void setLanguageMappings(Map<String, String> languageMappings)
+    {
+        this.languageMappings = languageMappings;
+    }
+
+    public List<String> getProviderClassNames()
+    {
+        return providerClassNames;
+    }
+
+    public void setProviderClassNames(List<String> providerClassNames)
+    {
+        this.providerClassNames = providerClassNames;
+    }
+
+    public List<String> getResourceClassNames()
+    {
+        return resourceClassNames;
+    }
+
+    public void setResourceClassNames(List<String> resourceClassNames)
+    {
+        this.resourceClassNames = resourceClassNames;
+    }
+
+    public boolean isScanProviders()
+    {
+        return scanProviders;
+    }
+
+    public void setScanProviders(boolean scanProviders)
+    {
+        this.scanProviders = scanProviders;
+    }
+
+    public boolean isScanResources()
+    {
+        return scanResources;
+    }
+
+    public void setScanResources(boolean scanResources)
+    {
+        this.scanResources = scanResources;
+    }
+
+    public boolean isUseBuiltinProviders()
+    {
+        return useBuiltinProviders;
+    }
+
+    public void setUseBuiltinProviders(boolean useBuiltinProviders)
+    {
+        this.useBuiltinProviders = useBuiltinProviders;
+    }
+}

Modified: trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyBootstrap.java
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyBootstrap.java	2008-07-14 11:30:32 UTC (rev 8457)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyBootstrap.java	2008-07-14 12:42:05 UTC (rev 8458)
@@ -14,8 +14,9 @@
 import java.util.Map;
 import java.util.HashMap;
 
-
 /**
+ * Scans annoated JAX-RS resources and providers, optionally registers them as Seam components.
+ *
  * @author Christian Bauer
  */
 @Name("org.jboss.seam.resteasy.bootstrap")
@@ -23,26 +24,29 @@
 @Startup
 @AutoCreate
 @Install(classDependencies = "org.resteasy.Dispatcher")
-public class ResteasyBootstrap {
+public class ResteasyBootstrap
+{
 
     @Logger
     Log log;
 
     @In
-    protected RestApplicationConfig restApplicationConfig;
+    protected ApplicationConfig applicationConfig;
 
     @Create
-    public void onStartup() {
+    public void onStartup()
+    {
         log.info("deploying Resteasy providers and resources");
 
         Collection<Class<java.lang.Object>> annotatedProviderClasses = null;
         Collection<Class<java.lang.Object>> annotatedResourceClasses = null;
-        if (restApplicationConfig.isScanForProviderClasses() || restApplicationConfig.isScanForResourceClasses()) {
+        if (applicationConfig.isScanProviders() || applicationConfig.isScanResources())
+        {
             log.debug("scanning all classes for JAX-RS annotations");
 
             DeploymentStrategy deployment = (DeploymentStrategy) Component.getInstance("deploymentStrategy");
             AnnotationDeploymentHandler handler =
-                    (AnnotationDeploymentHandler)deployment.getDeploymentHandlers().get(AnnotationDeploymentHandler.NAME);
+                    (AnnotationDeploymentHandler) deployment.getDeploymentHandlers().get(AnnotationDeploymentHandler.NAME);
 
             annotatedProviderClasses = handler.getClasses().get(javax.ws.rs.ext.Provider.class.getName());
             annotatedResourceClasses = handler.getClasses().get(javax.ws.rs.Path.class.getName());
@@ -51,10 +55,12 @@
         log.debug("finding all Seam component classes");
         Map<Class, Component> seamComponents = new HashMap<Class, Component>();
         String[] applicationContextNames = Contexts.getApplicationContext().getNames();
-        for (String applicationContextName : applicationContextNames) {
-            if (applicationContextName.endsWith(".component")) {
+        for (String applicationContextName : applicationContextNames)
+        {
+            if (applicationContextName.endsWith(".component"))
+            {
                 Component seamComponent =
-                        (Component)Component.getInstance(applicationContextName, ScopeType.APPLICATION);
+                        (Component) Component.getInstance(applicationContextName, ScopeType.APPLICATION);
                 // TODO: This should consider EJB components/annotations on interfaces somehow?
                 seamComponents.put(seamComponent.getBeanClass(), seamComponent);
             }
@@ -65,73 +71,92 @@
     }
 
     // Load all provider classes, either scanned or through explicit configuration
-    protected void registerProviders(Map<Class, Component> seamComponents, Collection annotatedProviderClasses) {
+    protected void registerProviders(Map<Class, Component> seamComponents, Collection annotatedProviderClasses)
+    {
         Collection<Class> providerClasses = new HashSet<Class>();
-        try {
-            if (restApplicationConfig.isScanForProviderClasses() && annotatedProviderClasses != null)
+        try
+        {
+            if (applicationConfig.isScanProviders() && annotatedProviderClasses != null)
                 providerClasses.addAll(annotatedProviderClasses);
 
-            for (String s : new HashSet<String>(restApplicationConfig.getProviderClassNames()))
+            for (String s : new HashSet<String>(applicationConfig.getProviderClassNames()))
                 providerClasses.add(Reflections.classForName(s));
 
-        } catch (ClassNotFoundException ex) {
+        }
+        catch (ClassNotFoundException ex)
+        {
             log.error("error loading JAX-RS provider class: " + ex.getMessage());
         }
-        for (Class providerClass : providerClasses) {
+        for (Class providerClass : providerClasses)
+        {
             // Ignore built-in providers, we register them manually later
             if (providerClass.getName().startsWith("org.resteasy.plugins.providers")) continue;
 
             Component seamComponent = null;
             // Check if this is also a Seam component bean class
-            if (seamComponents.containsKey(providerClass)) {
+            if (seamComponents.containsKey(providerClass))
+            {
                 seamComponent = seamComponents.get(providerClass);
                 // Needs to be APPLICATION or STATELESS
                 if (!seamComponent.getScope().equals(ScopeType.APPLICATION) &&
-                    !seamComponent.getScope().equals(ScopeType.STATELESS)) {
+                        !seamComponent.getScope().equals(ScopeType.STATELESS))
+                {
                     log.warn("not registering as  provider Seam component, must be APPLICATION or STATELESS scoped: "
-                             + seamComponent.getName());
+                            + seamComponent.getName());
                     seamComponent = null;
                 }
             }
-            if (seamComponent != null) {
+            if (seamComponent != null)
+            {
                 log.debug("registering provider Seam component: " + seamComponent.getName());
-            } else {
+            }
+            else
+            {
                 log.debug("registering provider class: " + providerClass.getName());
             }
-            restApplicationConfig.addProviderClass(providerClass, seamComponent);
+            applicationConfig.addProviderClass(providerClass, seamComponent);
         }
-        if (restApplicationConfig.getProviderClasses().size() == 0 &&
-            !restApplicationConfig.isUseBuiltinProviders()) {
+        if (applicationConfig.getProviderClasses().size() == 0 &&
+                !applicationConfig.isUseBuiltinProviders())
+        {
             log.info("no RESTEasy provider classes registered");
         }
     }
 
     // Load all resource classes, either scanned or through explicit configuration
-    protected void registerResources(Map<Class, Component> seamComponents, Collection annotatedResourceClasses) {
+    protected void registerResources(Map<Class, Component> seamComponents, Collection annotatedResourceClasses)
+    {
         Collection<Class> resourceClasses = new HashSet<Class>();
-        try {
-            if (restApplicationConfig.isScanForResourceClasses() && annotatedResourceClasses != null)
+        try
+        {
+            if (applicationConfig.isScanResources() && annotatedResourceClasses != null)
                 resourceClasses.addAll(annotatedResourceClasses);
 
-            for (String s : new HashSet<String>(restApplicationConfig.getResourceClassNames()))
+            for (String s : new HashSet<String>(applicationConfig.getResourceClassNames()))
                 resourceClasses.add(Reflections.classForName(s));
 
-        } catch (ClassNotFoundException ex) {
+        }
+        catch (ClassNotFoundException ex)
+        {
             log.error("error loading JAX-RS resource class: " + ex.getMessage());
         }
-        for (Class<Object> resourceClass : resourceClasses) {
+        for (Class<Object> resourceClass : resourceClasses)
+        {
 
             Component seamComponent = null;
             // Check if this is also a Seam component bean class
-            if (seamComponents.containsKey(resourceClass)) {
+            if (seamComponents.containsKey(resourceClass))
+            {
                 seamComponent = seamComponents.get(resourceClass);
                 log.debug("registering resource Seam component: " + seamComponent.getName());
-            } else {
+            }
+            else
+            {
                 log.debug("registering resource class with JAX-RS default lifecycle: " + resourceClass.getName());
             }
-            restApplicationConfig.addResourceClass(resourceClass, seamComponent);
+            applicationConfig.addResourceClass(resourceClass, seamComponent);
         }
-        if (restApplicationConfig.getResourceClasses().size() == 0)
+        if (applicationConfig.getResourceClasses().size() == 0)
             log.info("no JAX-RS resource classes registered");
     }
 

Modified: trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyDispatcher.java
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyDispatcher.java	2008-07-14 11:30:32 UTC (rev 8457)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyDispatcher.java	2008-07-14 12:42:05 UTC (rev 8458)
@@ -11,6 +11,10 @@
 import org.resteasy.spi.*;
 
 /**
+ * An extended version of the RESTEasy dispatcher, configured on Seam application
+ * startup with a custom ApplicationConfig instance. Registers custom resource
+ * and provider lifecycle handlers.
+ *
  * @author Christian Bauer
  */
 @Name("org.jboss.seam.resteasy.dispatcher")
@@ -18,77 +22,100 @@
 @Startup(depends = "resteasyBootstrap")
 @AutoCreate
 @Install(classDependencies = "org.resteasy.Dispatcher")
-public class ResteasyDispatcher extends HttpServletDispatcher {
+public class ResteasyDispatcher extends HttpServletDispatcher
+{
 
     @In
-    RestApplicationConfig restApplicationConfig;
+    ApplicationConfig applicationConfig;
 
     @Logger
     Log log;
 
     @Create
-    public void onStartup() {
-        log.info("registering RESTEasy resources and providers");
+    public void onStartup()
+    {
+        log.debug("assigning registered RESTEasy resources and providers");
 
         ResteasyProviderFactory providerFactory = new ResteasyProviderFactory();
         ResteasyProviderFactory.setInstance(providerFactory); // This is really necessary
         setDispatcher(new Dispatcher(providerFactory));
 
-        getDispatcher().setLanguageMappings(restApplicationConfig.getLanguageMappings());
-        getDispatcher().setMediaTypeMappings(restApplicationConfig.getMediaTypeMappings());
+        getDispatcher().setLanguageMappings(applicationConfig.getLanguageMappings());
+        getDispatcher().setMediaTypeMappings(applicationConfig.getMediaTypeMappings());
 
         // Resource registration
         Registry registry = getDispatcher().getRegistry();
-        for (final Class resourceClass : restApplicationConfig.getResourceClasses()) {
-            final Component seamComponent = restApplicationConfig.getResourceClassComponent(resourceClass);
-            if (seamComponent != null) {
+        for (final Class resourceClass : applicationConfig.getResourceClasses())
+        {
+            final Component seamComponent = applicationConfig.getResourceClassComponent(resourceClass);
+            if (seamComponent != null)
+            {
                 // Seam component lookup when call is dispatched to resource
                 registry.addResourceFactory(
-                    new ResourceFactory() {
+                        new ResourceFactory()
+                        {
 
-                        private PropertyInjector propertyInjector;
+                            private PropertyInjector propertyInjector;
 
-                        public Class<?> getScannableClass() {
-                            return resourceClass;
-                        }
+                            public Class<?> getScannableClass()
+                            {
+                                return resourceClass;
+                            }
 
-                        public void registered(InjectorFactory factory) {
-                            this.propertyInjector = factory.createPropertyInjector(getScannableClass());
-                        }
+                            public void registered(InjectorFactory factory)
+                            {
+                                this.propertyInjector = factory.createPropertyInjector(getScannableClass());
+                            }
 
-                        public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory) {
-                            Object target = Component.getInstance(seamComponent.getName());
-                            propertyInjector.inject(request, response, target);
-                            return target;
+                            public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory)
+                            {
+                                Object target = Component.getInstance(seamComponent.getName());
+                                propertyInjector.inject(request, response, target);
+                                return target;
+                            }
+
+                            public void requestFinished(HttpRequest request, HttpResponse response, Object resource)
+                            {
+                            }
+
+                            public void unregistered()
+                            {
+                            }
                         }
-
-                        public void requestFinished(HttpRequest request, HttpResponse response, Object resource) {}
-                        public void unregistered() {}
-                    }
                 );
-            } else {
+            }
+            else
+            {
                 // JAX-RS default lifecycle
                 registry.addResourceFactory(new POJOResourceFactory(resourceClass));
             }
         }
 
         // Provider registration
-        if (restApplicationConfig.isUseBuiltinProviders()) {
+        if (applicationConfig.isUseBuiltinProviders())
+        {
             log.info("registering built-in RESTEasy providers");
             RegisterBuiltin.register(providerFactory);
         }
-        for (Class providerClass : restApplicationConfig.getProviderClasses()) {
-            Component seamComponent = restApplicationConfig.getProviderClassComponent(providerClass);
-            if (seamComponent != null) {
-                if (ScopeType.STATELESS.equals(seamComponent.getScope())) {
+        for (Class providerClass : applicationConfig.getProviderClasses())
+        {
+            Component seamComponent = applicationConfig.getProviderClassComponent(providerClass);
+            if (seamComponent != null)
+            {
+                if (ScopeType.STATELESS.equals(seamComponent.getScope()))
+                {
                     throw new RuntimeException(
-                        "Registration of STATELESS Seam components as RESTEasy providers not implemented!"
+                            "Registration of STATELESS Seam components as RESTEasy providers not implemented!"
                     );
-                } else if (ScopeType.APPLICATION.equals(seamComponent.getScope())) {
+                }
+                else if (ScopeType.APPLICATION.equals(seamComponent.getScope()))
+                {
                     Object providerInstance = Component.getInstance(seamComponent.getName());
                     providerFactory.registerProviderInstance(providerInstance);
                 }
-            } else {
+            }
+            else
+            {
                 // Just plain RESTEasy, no Seam component lookup or lifecycle
                 providerFactory.registerProvider(providerClass);
             }

Modified: trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java	2008-07-14 11:30:32 UTC (rev 8457)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/ResteasyResourceAdapter.java	2008-07-14 12:42:05 UTC (rev 8458)
@@ -27,37 +27,45 @@
 @Scope(ScopeType.APPLICATION)
 @Name("org.jboss.seam.resteasy.resourceAdapter")
 @BypassInterceptors
-public class ResteasyResourceAdapter extends AbstractResource {
+public class ResteasyResourceAdapter extends AbstractResource
+{
 
     public static final String RESTEASY_RESOURCE_BASEPATH = "/rest";
 
     @Override
-    public String getResourcePath() {
+    public String getResourcePath()
+    {
         return RESTEASY_RESOURCE_BASEPATH;
     }
 
     @Override
     public void getResource(final HttpServletRequest request, final HttpServletResponse response)
-            throws ServletException, IOException {
+            throws ServletException, IOException
+    {
 
         // Wrap this in Seam contexts
-        new ContextualHttpServletRequest(request) {
+        new ContextualHttpServletRequest(request)
+        {
             @Override
-            public void process() throws ServletException, IOException {
+            public void process() throws ServletException, IOException
+            {
 
                 ResteasyDispatcher dispatcher =
-                        (ResteasyDispatcher)Component.getInstance(ResteasyDispatcher.class);
-                if (dispatcher == null) {
+                        (ResteasyDispatcher) Component.getInstance(ResteasyDispatcher.class);
+                if (dispatcher == null)
+                {
                     throw new IllegalStateException("RESTEasy is not installed, check your classpath");
                 }
                 dispatcher.invoke(
-                    new HttpServletRequestWrapper(request) {
-                        // TODO: Strip out the /seam/resource/rest stuff
-                        public String getPathInfo() {
-                            return super.getPathInfo();
-                        }
-                    },
-                    response
+                        new HttpServletRequestWrapper(request)
+                        {
+                            // TODO: Strip out the /seam/resource/rest stuff
+                            public String getPathInfo()
+                            {
+                                return super.getPathInfo();
+                            }
+                        },
+                        response
                 );
             }
         }.run();

Added: trunk/src/resteasy/org/jboss/seam/resteasy/package-info.java
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/package-info.java	                        (rev 0)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/package-info.java	2008-07-14 12:42:05 UTC (rev 8458)
@@ -0,0 +1,4 @@
+ at Namespace("http://jboss.com/products/seam/resteasy")
+package org.jboss.seam.resteasy;
+
+import org.jboss.seam.annotations.Namespace;
\ No newline at end of file

Modified: trunk/src/resteasy/org/jboss/seam/resteasy/reasteasy-2.1.xsd
===================================================================
--- trunk/src/resteasy/org/jboss/seam/resteasy/reasteasy-2.1.xsd	2008-07-14 11:30:32 UTC (rev 8457)
+++ trunk/src/resteasy/org/jboss/seam/resteasy/reasteasy-2.1.xsd	2008-07-14 12:42:05 UTC (rev 8458)
@@ -1,12 +1,62 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
-           elementFormDefault="qualified"
-           targetNamespace="http://jboss.com/products/seam/resteasy"
-           xmlns:pdf="http://jboss.com/products/seam/resteasy"
-           xmlns:components="http://jboss.com/products/seam/components"
-           attributeFormDefault="unqualified">
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
+    targetNamespace="http://jboss.com/products/seam/resteasy" xmlns:resteasy="http://jboss.com/products/seam/resteasy"
+    xmlns:components="http://jboss.com/products/seam/components" attributeFormDefault="unqualified">
+
     <xs:import namespace="http://jboss.com/products/seam/components" schemaLocation="components-2.1.xsd"/>
 
-   <!-- TODO -->
+   <xs:element name="application-config">
+       <xs:annotation>
+           <xs:documentation>
+               An implementation of JAX-RS ApplicationConfig with additional properties for RESTEasy.
+           </xs:documentation>
+       </xs:annotation>
+       <xs:complexType mixed="true">
+          <xs:sequence>
+             <xs:element minOccurs="0" maxOccurs="1"
+                         name="provider-class-names" type="components:multiValuedProperty">
+                 <xs:annotation>
+                    <xs:documentation>
+                        List of provider classes.
+                    </xs:documentation>
+                 </xs:annotation>
+             </xs:element>
+             <xs:element minOccurs="0" maxOccurs="1"
+                         name="resource-class-names" type="components:multiValuedProperty">
+                 <xs:annotation>
+                    <xs:documentation>
+                        List of resource classes.
+                    </xs:documentation>
+                 </xs:annotation>
+             </xs:element>
+          </xs:sequence>
+          <xs:attributeGroup ref="components:attlist.component"/>
+          <xs:attributeGroup ref="pdf:attlist.application-config"/>
+       </xs:complexType>
+   </xs:element>
 
+   <xs:attributeGroup name="attlist.application-config">
+       <xs:attribute name="scan-providers" type="components:boolean">
+           <xs:annotation>
+               <xs:documentation>
+                   Enable automatic discovery of classes annoated with JAX-RS @Provider, defaults to 'true'.
+               </xs:documentation>
+           </xs:annotation>
+       </xs:attribute>
+      <xs:attribute name="scan-resources" type="components:boolean">
+          <xs:annotation>
+              <xs:documentation>
+                  Enable automatic discovery of classes annoated with JAX-RS @Path, defaults to 'true'.
+              </xs:documentation>
+          </xs:annotation>
+      </xs:attribute>
+      <xs:attribute name="use-builtin-providers" type="components:boolean">
+          <xs:annotation>
+              <xs:documentation>
+                  Enable RESTEasy built-in providers, defaults to 'true'.
+              </xs:documentation>
+          </xs:annotation>
+      </xs:attribute>
+   </xs:attributeGroup>
+
 </xs:schema>




More information about the seam-commits mailing list