protected static void startRestEasy(Class<?>... classes) throws Exception { server = new TJWSEmbeddedJaxrsServer(); server.setPort(PORT); server.start(); Registry registry = server.getDeployment().getRegistry(); ResteasyProviderFactory factory = server.getDeployment().getDispatcher().getProviderFactory(); if (classes != null) for (Class<?> clazz : classes) registry.addPerRequestResource(clazz); factory.addExceptionMapper(TMUnavailableMapper.class); factory.addExceptionMapper(TransactionStatusMapper.class); factory.addExceptionMapper(HttpResponseMapper.class); factory.addExceptionMapper(NotFoundMapper.class); }
public ResourceInvoker getInvoker(HttpRequest request) throws Failure { logger.debug("PathInfo: " + request.getUri().getPath()); if (!request.isInitial()) { throw new InternalServerErrorException( request.getUri().getPath() + " is not initial request. Its suspended and retried. Aborting."); } ResourceInvoker invoker = registry.getResourceInvoker(request); if (invoker == null) { throw new NotFoundException( "Unable to find JAX-RS resource associated with path: " + request.getUri().getPath()); } return invoker; }