Without diving deep into CXF and TomEE code, you can't programmatically add a new endpoint, but you really don't have to either. I would also advise against this, as you're be coding against a custom implementation that likely will break your upgrade path.
If I were given this task, the most efficient, the fastest executing, and safest way would be to use @PathParam, @QueryParam, @MatrixParam, @CookieParam, @FormParam, or @HeaderParam with wildcard matches. See here: https://docs.oracle.com/javaee/7/api/javax/ws/rs/package-summary.html and here: https://mkyong.com/tutorials/jax-rs-tutorials/ cheers, -Jonathan On Mon, Apr 17, 2023 at 9:28 PM tim clapp <[email protected]> wrote: > > 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 > } > } > -- Jonathan | [email protected] Pessimists, see a jar as half empty. Optimists, in contrast, see it as half full. Engineers, of course, understand the glass is twice as big as it needs to be.
