programmatic rest

tim clapp <[email protected]>
Newsgroups gmane.comp.java.openejb.user
Message-ID <[email protected]>
I'd like to create a restful endpoint, in the fashion described here https://tomee.apache.org/tomee-8.0/examples/simple-rest.html, in a programmatic way that is idiomatic to TomEE.

For example, instead of annotating a method like this below, to bind the method to an http endpoint, I'd like to be able to programmatically create the binding....

    @PUT
    @Path("orders/invoice/{id}")
    @Produces({MediaType.APPLICATION_XML})
    @Lock(LockType.READ)
    public Response DoSomething()
{         ...     }
 

Is such a thing possible ?

How do I tie into the underlying objects TomEE manages so that I can "register" a new http endpoint in the same sort of fashion as I do above via annotations ?


-----------------------package com.bigfancy;


@Startup
@Singleton
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Lock(LockType.READ)
public class PublicAPI {
    private static final Logger LOG = LogManager.getLogger(PublicAPI.class);
    private static final Marker GMARKER = MarkerManager.getMarker("public-api");

    @Context UriInfo uriInfo;
    @Context HttpHeaders httpHeaders;
    @Context Request request;
    @Context SecurityContext securityContext;
    @Context Providers providers;
    @Context HttpServletRequest httpServletRequest;
    @Resource SessionContext sessionContext;




    public PublicAPI() {
        super();
        LOG.info("constructing public api");
    }


    @PostConstruct
    public void init() {
        // instead of defining the orders(..) method below....
        // programmatically create the binding here...
    }

    @Destroy
    public void destroy() {
        LOG.info("destroying public api");
    }

    @POST
    @Path("orders/invoice/{id}")
    @Consumes({MediaType.WILDCARD})
    @Produces({MediaType.WILDCARD})
    public Response orders(
          @HeaderParam("xyz")
          @Required(true)
          final String xyz
    )
    {
        return null
    }
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.