Class HttpContextBuilder

java.lang.Object
org.jboss.resteasy.plugins.server.sun.http.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 $
  • Field Details

  • Constructor Details

    • HttpContextBuilder

      public HttpContextBuilder()
  • Method Details

    • getDeployment

      public ResteasyDeployment getDeployment()
    • setDeployment

      public void setDeployment(ResteasyDeployment deployment)
    • getPath

      public String getPath()
    • setPath

      public void setPath(String path)
      Path to bind context
      Parameters:
      path -
    • getSecurityDomain

      public SecurityDomain getSecurityDomain()
    • setSecurityDomain

      public void setSecurityDomain(SecurityDomain securityDomain)
      Will turn on Basic Authentication
      Parameters:
      securityDomain -
    • bind

      public HttpContext bind(HttpServer server)
    • cleanup

      public void cleanup()