Background: Apache Streams contains java interfaces which emulate social network REST APIs and implementations (some using Juneau Rest Proxy) for calling method on those APIs via java and transcribing native requests and responses to and from streams interoperability formats

Objective: Expose those interfaces / implementations via a hosted REST API, supporting an HTML serialization option, allowing a user to discover what methods are available, activate them, and view the results directly in the browser.

Some Relevant classes:

 

Proof of concept code : 

https://gist.github.com/steveblackmon/928396d08b0bde3dfbd601ad3d2200a5

 

Proof of concept interaction :

Failure seem to occur in PojoIntrospector.java

Line 131

Method m = p.getBeanContext().createSession().getClassMeta(o.getClass()).getPublicMethods().get(method);

m = null

because o.getClass() = java.util.LinkedHashMap$LinkedKeySet

where-as it seems that it should be org.apache.streams.twitter.api.Account.class

In fact 

p.getBeanContext().createSession().getClassMeta(org.apache.streams.twitter.api.Account.class).getPublicMethods().get(method);

finds 'settings' as expected.

 

  • No labels

1 Comment

  1. I see what's going on.

    This URL....

    http://localhost:8000/twitter/org.apache.streams.twitter.api.Account?invokeMethod=settings

    ...is mapping to this GET request that simply returns a list of strings...

    @RestMethod(name="GET", path="/{javaInterface}")
    public Collection<String> listMethods(@Path String javaInterface) throws Exception {
    	return getMethods(javaInterface).keySet();
    }

    So you're trying to invoke the settings() method on a collection of strings.

    You don't need the Introspectable converter at all in this case.  Just use the method below for method invocations....

    @RestMethod(name="POST", path="/{javaInterface}/{javaMethod}")
    public Object invoke(RestRequest req, @Path String javaInterface, @Path String javaMethod) throws Exception {

    e.g.

    HTTP POST http://localhost:8000/twitter/org.apache.streams.twitter.api.Account/settings

    or this is also possible since you have REST_allowMethodParam set to '*'...

    HTTP GET http://localhost:8000/twitter/org.apache.streams.twitter.api.Account/settings?Method=POST