Class HttpContextBuilder


  • public class HttpContextBuilder
    extends Object
    Helper class to create a ResteasyDeployment and bind it to an HttpContext of an HttpServer. Setting the SecurityDomain will turn on Basic Authentication. Right now, only BasicAuthentication is supported. HttpContext.getAttributes() data is available within Providers and Resources by injecting a ResteasyConfiguration interface
         HttpServer httpServer = HttpServer.create(new InetSocketAddress(port), 10);
         contextBuilder = new HttpContextBuilder();
         contextBuilder.getDeployment().getActualResourceClasses().add(SimpleResource.class);
         HttpContext context = contextBuilder.bind(httpServer);
         context.getAttributes().put("some.config.info", "42");
         httpServer.start();
    
         contextBuilder.cleanup();
         httpServer.stop(0);
     
    Create your HttpServer the way you want then use the org.jboss.resteasy.plugins.server.sun.http.HttpContextBuilder to initialize Resteasy and bind it to an HttpContext. The HttpContext attributes are available by injecting in a org.jboss.resteasy.spi.ResteasyConfiguration interface using @Context within your provider and resource classes.
    Author:
    Bill Burke* @version $Revision: 1 $