http://issues.jabsorb.org/show_bug.cgi?id=65

           Summary: Support for annotations as a way to register exposed
                    methods
           Product: jabsorb
           Version: trunk
            Status: NEW
          Severity: enhancement
          Priority: medium
         Component: server
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


Created an attachment (id=37)
 --> (http://issues.jabsorb.org/attachment.cgi?id=37)
A patch to Jabsorb 1.3.1 that implement support of annotations.

In Jabsorb 1.3.1, exposed methods are registred through
JSONRPCBridge.registerObject(Object key, Object o) or
JSONRPCBridge.registerObject(Object key, Object o, Class interfaceClass).

These mechanisms don't allow dynamic discovery of RPC methods which can be
useful when the JSON-RPC servlet is initialized from external classes or
plugins.

The attached patch implements support for annotations (a new feature of Java
1.5) as a way to register exposed methods.

One can simply annotate the RPC methods he wants to expose, and later register
the methods in Jabsorb with JSONRPCBridge.registerObject(Object key, Object o,
Annotation annotationClass).

For instance:

* RPCMethod.java:

import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Inherited
public @interface RPCMethod {
        /**
         * Contains a short description of the purpose of the service. 
         */
        public String value() default "";
}

* A sample class with an annotated method:

public class MyClass {
   @RPCMethod("This is a sample method")
   public String sample(Vector<String> param)
   {
       ...
       return "test";
   }
}

* Example of registration:

MyClass o = new MyClass();
JSONRPCBridge.getGlobalBridge().registerObject(o.getClass().getSimpleName(), o,
RPCMethod.class);


The patch alters JSONRPCBridge (in particular, it extracts the subclass
ObjectInstance) and ClassAnalyser and shouldn't break any current behaviour.

I'd be happy to discuss and futher improve this patch if needed.


-- 
Configure bugmail: http://issues.jabsorb.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
You are the assignee for the bug.

_______________________________________________
Jabsorb-dev mailing list
[email protected]
http://lists.jabsorb.org/mailman/listinfo/jabsorb-dev

Reply via email to