Package org.jboss.resteasy.plugins.server.sun.http

## 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 Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected com.sun.net.httpserver.HttpContext` | `boundContext` |
    `protected ResteasyDeployment` | `deployment` |
    `protected ResteasyHttpHandler` | `handler` |
    `protected String` | `path` |
    `protected SecurityDomain` | `securityDomain` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `HttpContextBuilder()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `com.sun.net.httpserver.HttpContext` | `bind​(com.sun.net.httpserver.HttpServer server)` |
    `void` | `cleanup()` |
    `ResteasyDeployment` | `getDeployment()` |
    `String` | `getPath()` |
    `SecurityDomain` | `getSecurityDomain()` |
    `void` | `setDeployment​(ResteasyDeployment deployment)` |
    `void` | `setPath​(String path)` | Path to bind context
    `void` | `setSecurityDomain​(SecurityDomain securityDomain)` | Will turn on Basic Authentication

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### deployment

          protected ResteasyDeployment deployment

    - #### path

          protected String path

    - #### handler

          protected ResteasyHttpHandler handler

    - #### securityDomain

          protected SecurityDomain securityDomain

    - #### boundContext

          protected com.sun.net.httpserver.HttpContext boundContext

  - ### Constructor Detail

    - #### HttpContextBuilder

          public HttpContextBuilder()

  - ### Method Detail

    - #### 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 com.sun.net.httpserver.HttpContext bind​(com.sun.net.httpserver.HttpServer server)

    - #### cleanup

          public void cleanup()