jax-rs-spec
  1. jax-rs-spec
  2. JAX_RS_SPEC-66

Programmatic @Path value providers/resolvers

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: ice box
    • Component/s: model api
    • Labels:
      None

      Description

      (Email from Guilherme Silveira, http://java.net/projects/jax-rs-spec/lists/jsr339-experts/archive/2011-03/message/90 )

      5. URI Building

      This is one that bothers me a lot. We should be writing OO code, not xml-oriented, not annotation-oriented, not string-oriented. So why so many annotations, strings and just one object? This is the refactor-friendly version of URI builder that we use in VRaptor so people can refactor code and things are still working:

      @Resource
      public class UserController {

      // inject dao
      public User show(long id)

      { return dao.load(id); }

      }

      @Resource
      public class AdminController {

      private final Result result;
      private final UserDao dao;

      // easy to mock, inject => easy to test
      public AdminController(Result result, UserDao dao)

      { this.result = result; this.dao = dao; }

      public void create(User created)

      { User created = dao.save(prototype); // refactor friendly + no URI hell result.redirectTo(UserController.class).show(created); }

      }

      Of course, if there is a @Path annotation on top of the method, the framework knows how to understand that. To do so we provide, again, everything configurable (and default versions):

      public interface PathResolver {
      String pathFor(ResourceMethod method);
      }
      public interface Proxifier {
      <T> T proxify(Class<T> type, MethodInvocation<? super T> handler);
      }

      This is the one that allows hypermedia resource generation in a refactor-friendly, non-annotation based way, i.e.:

      public class Basket implements HypermediaResource {

      public void configureRelations(RelationBuilder builder)

      { builder.relation("self").uses(BasketsController.class).show(id); builder.relation("payment").uses(PaymentsController.class).create(id, null); }

      }

        Activity

        Hide
        Marek Potociar added a comment -

        Changed subj. to better reflect the issue content.

        Show
        Marek Potociar added a comment - Changed subj. to better reflect the issue content.
        Hide
        Marek Potociar added a comment -

        I have created a new issue category to hold all programmatic modeling API suggestions and put the issue to the category for future reference.

        Unfortunately, we won't be able to address the topic as part of JAX-RS 2.0 due to the time limitations and the fact the topic is out of scope. Deferring the issue to a future release.

        Show
        Marek Potociar added a comment - I have created a new issue category to hold all programmatic modeling API suggestions and put the issue to the category for future reference. Unfortunately, we won't be able to address the topic as part of JAX-RS 2.0 due to the time limitations and the fact the topic is out of scope. Deferring the issue to a future release.
        Hide
        Marek Potociar added a comment -

        Deferring the issue to a future release.

        Show
        Marek Potociar added a comment - Deferring the issue to a future release.

          People

          • Assignee:
            Unassigned
            Reporter:
            robc
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: