Loading ...
Sorry, an error occurred while loading the content.
 

REST implementation

Expand Messages
  • msd
    I had the following (newbie) question about REST 1) Assume I have a URL http://www.creditcompany.com/CreditApplications to allow the caller access to Credit
    Message 1 of 3 , May 22, 2005
      I had the following (newbie) question about REST

      1) Assume I have a URL
      http://www.creditcompany.com/CreditApplications to
      allow
      the caller access to Credit Application data.

      What are the components I would need to actually
      implement the service in J2EE ?

      My understanding is that I would need a (REST) servlet
      with implementations of GET,POST,PUT, DELETE which
      would locate the resource (CreditApplicationCollection
      in the case of a list of CreditApplications) and call
      the appropriate method on it. The method will return
      XML data that will link to more data (individual
      Credit Applications)

      Is this correct ? Are a CreditApplication and a
      CreditApplicationCollection different resources ?
      (different business objects ??)

      Would greatly appreciate it if somebody could very
      briefly explain the flow / sequence for an actual J2EE
      implementation using J2EE pattern terminology (Front
      Controller, Web Service Broker, Business Delegate,
      Session Facade, Business Object ???.
      Which J2EE patterns are applicable for a REST
      implementation ?

      Thanks in Advance !

      Makarand

      __________________________________________________
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail.yahoo.com
    • Vincent D Murphy
      On Sun, 22 May 2005 06:04:52 -0700 (PDT), msd ... Start with a servlet which dispatches on the path and method of the request (there are
      Message 2 of 3 , Jun 1, 2005
        On Sun, 22 May 2005 06:04:52 -0700 (PDT), "msd" <mad_date@...>
        said:
        > What are the components I would need to actually
        > implement the service in J2EE ?

        Start with a servlet which dispatches on the
        path and method of the request (there are two
        variables there, so you're looking at a table
        lookup or a nasty if statement).

        > My understanding is that I would need a (REST) servlet
        > with implementations of GET,POST,PUT, DELETE which
        > would locate the resource (CreditApplicationCollection
        > in the case of a list of CreditApplications) and call
        > the appropriate method on it.

        The actual request handlers can be methods in any class
        you want, just call them from the servlet. It would
        make sense to use a class per resource type, with
        methods for the HTTP methods, i.e. GET, POST, etc.

        > The method will return
        > XML data that will link to more data (individual
        > Credit Applications)

        Good.

        > Is this correct ? Are a CreditApplication and a
        > CreditApplicationCollection different resources ?
        > (different business objects ??)

        This is a good approach. One of the things I don't
        like about MVC web frameworks (like Rails) is how
        they encourage you to use one controller for both
        the collection and the resources it contains. I
        think it makes sense to split them apart.

        > Would greatly appreciate it if somebody could very
        > briefly explain the flow / sequence for an actual J2EE
        > implementation using J2EE pattern terminology (Front
        > Controller, Web Service Broker, Business Delegate,
        > Session Facade, Business Object ???.

        > Which J2EE patterns are applicable for a REST
        > implementation ?

        None of them... I guess you could call the dispatcher
        a Front Controller if you want.

        Don't get hung up on J2EE and patterns, you can get
        everything you want done with just a servlet and some
        POJOs.
      • R. Mark Volkmann
        ... I wrote an article that may interest you if you re going to implement REST servers with a Java servlet. It is at
        Message 3 of 3 , Jun 1, 2005
          Quoting Vincent D Murphy <vdm@...>:

          > On Sun, 22 May 2005 06:04:52 -0700 (PDT), "msd" <mad_date@...>
          > said:
          > > What are the components I would need to actually
          > > implement the service in J2EE ?
          >
          > Start with a servlet which dispatches on the
          > path and method of the request

          I wrote an article that may interest you if you're going to implement REST
          servers with a Java servlet. It is at
          http://www.ociweb.com/jnb/jnbNov2004.html.

          --
          R. Mark Volkmann
          Partner, Object Computing, Inc.
        Your message has been successfully submitted and would be delivered to recipients shortly.