dev@glassfish.java.net

Exposing CLIs via REST

From: Jason Lee <jason.d.lee_at_oracle.com>
Date: Thu, 08 Sep 2011 14:58:28 -0500

Currently, to expose a CLI command via the REST interface, we've managed
a couple of data structures in the REST module. For 3.2/4.0, we'd like
to move that to an annotation-based approach. In the 3.2 planning, we
detailed that information here:
http://wikis.sun.com/display/GlassFish/32RestInterfaceOnePager

I just committed a slight change, though. We have renamed
@RestAttachments/_at_RestAttachment (meant to indicate that we were
attaching the command to a point in the REST resource tree) to the
clearer @RestEndpoints/_at_RestEndpoint. Their use is fairly simple:

    @RestEndpoints({
         @RestEndpoint(configBean=Config.class,
             opType=OpType.POST,
             description="Synchronize-realm-from-config",
             path="synchronize-realm-from-config",
             params={
                 @RestParam(name="target", value="$parent")
             })
    })
    public class SynchronizeRealmFromConfig implements AdminCommand {

This will create, for example, the endpoint
http://localhost:4848/management/domain/configs/config/server-config/synchronize-realm-from-config.
Using this command requires the use of POST.

The wiki details a few other annotations that we've support for sometime
now (the CRUD framework of Jerome's), so I would suggest reading through
those as well if you're not familiar with them. The wiki page is
currently out-of-date, but I'll get it updated as soon as I can resolve
my authentication issue.

If you have any questions, please feel free to contact me or Mitesh.

-- 
Jason Lee
Senior Member of Technical Staff
GlassFish REST API / Administration Console
Oracle Corporation
Phone +1 405-216-3193
Blog http://blogs.steeplesoft.com