6 Replies Latest reply on May 13, 2008 9:31 AM by Eric H

    Feature idea for Seam: @Servlet annotation?

    Eric H Novice

      Here's an idea for a feature that I would like to see in Seam: an annotation to create servlets.  There's already a @Filter annotation, so my idea is to have something similar for Servlets.


      The reason for this: I would like to be able to use the full power of Seam components, SMPC, etc, within a Servlet.  Sure, Seam handles HTML output and PDF output.  But sometimes I want some other entirely different type of output, like maybe I want to create an RSS feed, or display an image, or dynamically generate a sound file, or various other things.


      Is this a reasonable idea?  How hard would it be to implement?  I might take a crack at it by looking at how @Filter works if this is a good idea.

        • 1. Re: Feature idea for Seam: @Servlet annotation?
          Joshua Jackson Master

          Why don't you create the patch and submit it to JIRA?

          • 2. Re: Feature idea for Seam: @Servlet annotation?
            Eric H Novice

            I may do it.  I'm first curious if the Seam devs have any opinions on if this is a desirable idea, or what the other potential complexities or problems with it are.  I don't know much about how Seam works under the hood.  In my current view, I don't see how this would be much different from the @Filter annotation implementation, so unless someone tells me that this is a pointless idea or there's some other problem, I'm going to go ahead and do it by basing it on how @Filter works.

            • 3. Re: Feature idea for Seam: @Servlet annotation?
              Shane Bryzak Master

              By all means submit this as a feature request in JIRA.  It seems to be something that would be useful for many people.

              • 4. Re: Feature idea for Seam: @Servlet annotation?
                Eric H Novice

                Ok.  I'm not the only one then.  I'll write the patch and submit it.  My company has already signed up as a JBoss contributor so we can submit the code.

                • 5. Re: Feature idea for Seam: @Servlet annotation?
                  Nicklas Karlsson Master

                  Sure, could be useful.


                  As a side note, I didn't even know it was possible to do dynamic servlets (or have I misunderstood the feature)? I though it was deployment-stuff coming soon(tm) to the servlet speces(?)


                  But since no-one has objected, I won't stand in your way :-)

                  • 6. Re: Feature idea for Seam: @Servlet annotation?
                    Eric H Novice

                    Within Servlet 2.5 (the current version) there is no dynamic servlet deployment, at least not that I could see.  I looked at the ServletContext API and there's nothing like a mapServlet(String path, Servlet servlet) method that would be needed for real dynamic deployment.


                    HOWEVER, it's not a problem.  In a typical Seam environment, the Seam servlet is mapped to *.seam.  Ok, cool.  I can have the Seam Servlet remember to call some user-supplied Servlet with the @Servlet annotation on it if it matches some criteria.  The annoyance here is that then all the Servlets will have to end in .seam in their URLs.  But that's not such a problem because you could put another mapping in web.xml, and also you could go ahead and use URLrewriter to change the visible URLs anyway.


                    So from the Servlet side of things this will work, and it looks like I can get Seam to do its stuff also.  It will take me a couple of days to do this (I have other higher priority stuff to do also).