Skip to content
This repository has been archived by the owner on Jan 9, 2018. It is now read-only.

Design for annotation based Actions #30

Open
trumpetinc opened this issue Feb 18, 2014 · 2 comments
Open

Design for annotation based Actions #30

trumpetinc opened this issue Feb 18, 2014 · 2 comments
Milestone

Comments

@trumpetinc
Copy link
Collaborator

I think it would be a good idea to start discussion what annotation based action specification might look like.

This may be controversial, but I thought I'd toss it out and see what you think:

I have been using JAX-RS lately, and I have to say that I really like it. I would almost go so far as to say that for RPC it may be more effective to just use a JAX-RS implementation with a bit of translation magic, than to try to do anything else. In this case, JAX-RS would run entirely inside the WAMP container (i.e. it isn't exposed to the servlet/J2EE container).

Here's what this would look like (using RESTEasy):

private static class HandleJaxRsCallAction implements CallAction{

    private final ResteasyDeployment deployment;

    public HandleJaxRsCallAction(ResteasyDeployment deployment) {
        this.deployment = deployment;
    }

    @Override
    public void execute(String sessionId, WampArguments args, CallResultSender sender) throws CallException,
            Exception {

        String type = args.nextObject(String.class);
        String url = args.nextObject(String.class);

        MockHttpRequest request = MockHttpRequest.create(type, url);

        MockHttpResponse response = new MockHttpResponse();

        deployment.getDispatcher().invoke(request, response);

        sender.sendResult(response.getStatus(), response.getContentAsString());
    }

}

Or we could just implement a completely new annotation system, or create one that is strongly modeled on JAX-RS, and maybe that is the correct way to do this. If we do go that route, then I think that the URL parsing capabilities of JAX-RS are a very good thing (they allow what is effectively chained operators without multiple round trips or having a huge list of method parameters):

https://my.server/users/123/accounts/5678#getDetails()

just looks a lot cleaner (and is a lot easier to write on the server side with JAX-RS sub-resources) than:

https://my.server#getAccountDetails(123, 5678)

I'm still fairly new to the WAMP thing, so I may be missing an important detail of how this is supposed to work - definitely let me know what you think.

@ghetolay
Copy link
Owner

You are talking about RESTful design. Wamp is a communication protocol and doesn't handle this level of architecture.RESTful is one possible design, but this is an end user choice.
Now you could create a WAMP-RS extension for that kind of things.

@ghetolay ghetolay added this to the JSR356 milestone Feb 19, 2014
@trumpetinc
Copy link
Collaborator Author

I think that I'm talking more about what URL format to use for remote procedure call URLs. The ability to use @PathParam in both JAX-RS and JSR356 is very useful. I think that we should carry this capability forward into jWAMP.

I'm pretty sure the only piece of this that is really RESTful is the use of sub-resources, and I agree that a WAMP-RS extension could be created that allows sub-resources to be built up from endpoint paths, etc...

Also, I think that an annotation to allow injection of values from the UserProperties collection (based on classname as the UserProperty key) will be important. Maybe @userproperty

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants