...
Here is a very simple plugin :
Panel |
---|
Code Block |
---|
public class PluginA extends Plugin \{ @Override public void attachContext(Filter filter, Context context, Router router) \{ filter.setNext(new RestletA()); Route route = router.attach(getMetaInf().getUriPrefix() + "/\{param\}",filter); route.extractQuery("agent", "agent", true); \} @Override public String getAgent(Request request) \{ return (String) request.getAttributes().get("agent"); \} \} |
The RestletA that does the actual work is
Code Block |
---|
public class RestletA extends Restlet \{ public RestletA () \{ \} @Override public void handle(Request request, Response response) \{ System.out.println("RestletA: got a request "); System.out.println("Parameter A is " + request.getAttributes().get("param")); response.setStatus(Status.SUCCESS_OK); \} \} |
Note that the RestletA is completely oblivious to any security policy or the url prefix that is used to invoke it.
...
Code Block |
---|
<?xml version="1.0" ?>
<rest-service xmlns="http://www.sipfoundry.org/sipX/schema/xml/sipxrest-service-00-00">
<plugin-class>org.sipfoundry.sipxrest.testa.PluginA</plugin-class>
<security-level>LOCAL-AND-REMOTE</security-level>
<uri-prefix>/testplugin/a</uri-prefix>
<service-description>
This is test plugin A. You can invoke it using the URI
testplugin/a?agent=user1 where user1 is a valid user in your user database.
</service-description>
</rest-service>
|
...