public class HttpContextBuilder extends Object
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.
Modifier and Type | Field and Description |
---|---|
protected com.sun.net.httpserver.HttpContext |
boundContext |
protected ResteasyDeployment |
deployment |
protected ResteasyHttpHandler |
handler |
protected String |
path |
protected SecurityDomain |
securityDomain |
Constructor and Description |
---|
HttpContextBuilder() |
Modifier and Type | Method and 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
|
protected ResteasyDeployment deployment
protected String path
protected ResteasyHttpHandler handler
protected SecurityDomain securityDomain
protected com.sun.net.httpserver.HttpContext boundContext
public ResteasyDeployment getDeployment()
public void setDeployment(ResteasyDeployment deployment)
public String getPath()
public void setPath(String path)
path
- public SecurityDomain getSecurityDomain()
public void setSecurityDomain(SecurityDomain securityDomain)
securityDomain
- public com.sun.net.httpserver.HttpContext bind(com.sun.net.httpserver.HttpServer server)
public void cleanup()
Copyright © 2014. All Rights Reserved.