本文整理汇总了Java中org.mortbay.http.HttpServer类的典型用法代码示例。如果您正苦于以下问题:Java HttpServer类的具体用法?Java HttpServer怎么用?Java HttpServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpServer类属于org.mortbay.http包,在下文中一共展示了HttpServer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setupServer
import org.mortbay.http.HttpServer; //导入依赖的package包/类
private void setupServer() throws Exception
{
this.server = new HttpServer();
SocketListener listener = new SocketListener();
listener.setPort(PORT);
this.server.addListener(listener);
HttpContext context = new HttpContext();
context.setContextPath("/");
ServletHandler servletHandler = new ServletHandler();
context.addHandler(servletHandler);
// Map a servlet onto the container
ServletHolder holder =
servletHandler.addServlet("JrpipServlet", "/JrpipServlet", "com.gs.jrpip.server.JrpipServlet");
holder.put("serviceInterface.Echo", "com.gs.jrpip.Echo");
holder.put("vmBoundServiceClass.Echo", "com.gs.jrpip.EchoImpl");
holder.setInitOrder(10);
this.server.addContext(context);
this.server.start();
this.servlet = (JrpipServlet) holder.getServlet();
}
开发者ID:goldmansachs,项目名称:jrpip,代码行数:25,代码来源:VmBoundServiceTest.java
示例2: setUpHttpServer
import org.mortbay.http.HttpServer; //导入依赖的package包/类
private void setUpHttpServer() throws Exception {
server = new HttpServer();
SocketListener listener = new SocketListener();
listener.setPort(configuration.getPort());
server.addListener(listener);
ServletHttpContext servletContext = new ServletHttpContext();
servletContext.setContextPath("jsunit");
servletContext.setResourceBase(configuration.getResourceBase().toString());
servletContext.addServlet("JSP", "*.jsp", JspServlet.class.getName());
servletContext.addHandler(new ResourceHandler());
ConfigurationManager.clearConfigurationProviders();
ConfigurationManager.addConfigurationProvider(new XmlConfigurationProvider(xworkXmlName()));
com.opensymphony.webwork.config.Configuration.set("webwork.action.extension", "");
for (String servletName : servletNames())
addWebworkServlet(servletContext, servletName);
server.addContext(servletContext);
if (Monitor.activeCount() == 0)
Monitor.monitor();
}
开发者ID:BradNeuberg,项目名称:purple-include,代码行数:25,代码来源:AbstractJsUnitServer.java
示例3: main
import org.mortbay.http.HttpServer; //导入依赖的package包/类
public static void main(String[] args) {
// Sample HTTP server using jetty
try {
HttpServer svr = new HttpServer();
svr.addListener(new InetAddrPort(80));
ResourceHandler resourceHandler = new ResourceHandler();
File root = new File("http_root");
ServletHttpContext cx = new ServletHttpContext();
cx.setContextPath("");
cx.addHandler(resourceHandler);
cx.setResourceBase(root.getAbsolutePath());
// common servlets
cx.addServlet("Check", "/Check", EpubCheckServlet.class
.getName());
svr.addContext(cx);
svr.start();
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:jcdarwin,项目名称:epubcheck-web,代码行数:23,代码来源:SampleServer.java
示例4: getContext
import org.mortbay.http.HttpServer; //导入依赖的package包/类
private static HttpContext getContext(HttpServer httpServer, String host, String path) {
HttpContext contexts[] = httpServer.getContexts();
for (int i = 0; i < contexts.length; i++) {
HttpContext context = contexts[i];
String contextPath = context.getContextPath();
//System.out.print("{" + contextPath + "}");
if (contextPath.equals(path) || contextPath.equals(path + "/*")) {
String[] vhosts = context.getVirtualHosts();
for (int j = 0; j < vhosts.length; j++) {
if (vhosts[j].equals(host)) {
return context;
}
}
}
}
return null;
}
开发者ID:thinkberg,项目名称:snipsnap,代码行数:18,代码来源:ApplicationLoader.java
示例5: setupServerWithHandler
import org.mortbay.http.HttpServer; //导入依赖的package包/类
protected void setupServerWithHandler(
HttpHandler handler,
SecurityConstraint constraint,
UserRealm realm) throws Exception
{
this.port = (int) (Math.random() * 10000.0 + 10000.0);
this.jrpipUrl = "http://localhost:" + this.port + "/JrpipServlet";
this.server = new HttpServer();
SocketListener listener = new SocketListener();
listener.setPort(this.port);
this.server.addListener(listener);
HttpContext context = new HttpContext();
context.setContextPath("/");
if (realm != null)
{
context.setRealm(realm);
}
if (constraint != null)
{
context.addSecurityConstraint("/", constraint);
}
if (handler != null)
{
context.addHandler(handler);
}
ServletHandler servletHandler = new ServletHandler();
context.addHandler(servletHandler);
ServletHolder holder = servletHandler.addServlet("JrpipServlet", "/JrpipServlet", "com.gs.jrpip.server.JrpipServlet");
holder.put("serviceInterface.Echo", "com.gs.jrpip.Echo");
holder.put("serviceClass.Echo", "com.gs.jrpip.EchoImpl");
this.addCustomConfiguration(holder);
holder.setInitOrder(10);
this.server.addContext(context);
this.server.start();
this.servlet = (JrpipServlet) holder.getServlet();
}
开发者ID:goldmansachs,项目名称:jrpip,代码行数:45,代码来源:JrpipTestCase.java
示例6: addContext
import org.mortbay.http.HttpServer; //导入依赖的package包/类
public static void addContext(HttpServer server, String strContext, String host, String path, String strWebContext, String strServerContext) {
if (strWebContext == null) strWebContext = "./web";
if (strServerContext == null) strServerContext = "./server";
HttpContext context = new HttpContext();
context.setContextPath(strContext);
context.addWelcomeFile("index.cfm");
if ( host != null && !host.isEmpty() )
context.addVirtualHost(host);
server.addContext(context);
// Create a servlet container
ServletHandler servlets = new ServletHandler();
context.addHandler(servlets);
// Map a servlet onto the container
ServletHolder cfml = servlets.addServlet("CFMLServlet", "*.cfc/*,*.cfm/*,*.cfml/*,*.cfc,*.cfm,*.cfml", "lucee.debug.loader.servlet.CFMLServlet");
cfml.setInitOrder(0);
cfml.setInitParameter("lucee-server-directory", strServerContext);
// Lucee REST Servlet
ServletHolder rest = servlets.addServlet("RESTServlet", "/rest/*", "lucee.debug.loader.servlet.RESTServlet");
rest.setInitOrder(0);
strWebContext += path;
context.setResourceBase(strWebContext);
context.addHandler(new ResourceHandler());
}
开发者ID:lucee,项目名称:Lucee4,代码行数:33,代码来源:RunAsJavaApplication.java
示例7: findHost
import org.mortbay.http.HttpServer; //导入依赖的package包/类
private static HttpServer findHost(Collection servers, String host, String port) {
host = (host == null ? "" : host);
//System.out.println("{" + host + ":" + port + "}");
Iterator it = servers.iterator();
while (it.hasNext()) {
HttpServer server = (HttpServer) it.next();
HttpListener listener[] = server.getListeners();
for (int i = 0; i < listener.length; i++) {
String listenerHost = listener[i].getHost();
listenerHost = (listenerHost == null || listenerHost.equals(InetAddrPort.__0_0_0_0) ? "" : listenerHost);
String listenerPort = "" + listener[i].getPort();
if (port != null) {
//System.out.print("[" + listenerHost + ":" + listenerPort);
if (listenerHost.equals(host) && listenerPort.equals(port)) {
//System.out.println("!]");
return server;
}
} else {
//System.out.print("[" + listenerHost);
if (listenerHost.equals(host)) {
System.out.print("!]");
return server;
}
}
//System.out.print("]");
}
}
return null;
}
开发者ID:thinkberg,项目名称:snipsnap,代码行数:32,代码来源:ApplicationLoader.java
示例8: start
import org.mortbay.http.HttpServer; //导入依赖的package包/类
protected static void start(int port, String articleTitlePath)
throws Exception {
// Create the log.
QuickLog log = new QuickLog();
AddLinksProxyServlet.setSharedLog(log);
TemplateServlet.setSharedLog(log);
// Create the word ranker.
String pathToWordFrequencyFile = "resource-root/word-frequency.txt";
Ranker ranker = new Ranker(pathToWordFrequencyFile);
// Create the page data store.
PageDataStore pageDataStore = new PageDataStore(ranker,
articleTitlePath);
// Create the page linker.
Linker linker = new Linker(pageDataStore);
AddLinksProxyServlet.setSharedLinker(linker);
GetPageDataAjaxServlet.setSharedLinker(linker);
JsInclusionLinkerServlet.setSharedLinker(linker);
// Set up the example HTML.
TemplateServlet.setSharedExampleHtmlDescription(Linker.getExampleHtmlDescription());
String exampleBeforeHtml = Linker.getExampleHtml();
TemplateServlet.setSharedExampleBeforeHtml(exampleBeforeHtml);
String exampleAfterHtml = linker
.addLinksToHtmlFragmentText(exampleBeforeHtml);
TemplateServlet.setSharedExampleAfterHtml(exampleAfterHtml);
// Run level 2 tests.
Tester tester = new Tester("L2TEST");
tester.runTests(pageDataStore);
// Create the server.
HttpServer server = new HttpServer();
// Default is no virtual host.
String host = null;
HttpContext context = server.getContext(host, "/");
context.setRequestLog(new NCSARequestLog("jetty.log"));
ServletHandler servletHandler = new ServletHandler();
servletHandler.addServlet("Add Links", "/servlet/add-links",
AddLinksProxyServlet.class.getName());
servletHandler.addServlet("Get Page Data", "/servlet/get-page-data",
GetPageDataAjaxServlet.class.getName());
servletHandler.addServlet("Get Page Data JSON",
"/servlet/get-page-data-json", JsInclusionLinkerServlet.class
.getName());
servletHandler.addServlet("Template", "*.html", TemplateServlet.class
.getName());
servletHandler.addServlet("XPI", "/extension/golimojo.xpi",
GolimojoXpiServlet.class.getName());
servletHandler.addServlet("Shutdown", "/servlet/shutdown",
ShutdownServlet.class.getName());
context.addHandler(servletHandler);
context.setResourceBase("web-root");
context.addHandler(new ResourceHandler());
context.addHandler(new DumpHandler());
context.addHandler(new NotFoundHandler());
InetAddrPort address = new InetAddrPort(port);
server.addListener(address);
server.start();
}
开发者ID:cbartley,项目名称:golimojo,代码行数:68,代码来源:Server.java
示例9: _main
import org.mortbay.http.HttpServer; //导入依赖的package包/类
public static void _main(String[] args)
throws Exception {
// Create the server
HttpServer server = new HttpServer();
int port = DEFAULT_PORT;
String strWebContext = "./web";
String strServerContext="./server";
if (args.length > 0) {
port = Integer.parseInt(args[0]);
}
if (args.length > 1) {
strWebContext = args[1];
}
if (args.length > 2) {
strServerContext = args[2];
}
// Create a port listener
SocketListener listener = new SocketListener();
listener.setPort(port);
server.addListener(listener);
String host = null;
// Create a context
File webxml = new File(strServerContext + "/web.xml");
if (webxml.exists()) {
System.err.println("not supported atm");
//addWebXmlContext(server, "/", host, "/", strWebContext, strServerContext);
} else {
addContext(server, "/", host, "/", strWebContext, strServerContext);
}
//addContext(server,"/susi/","localhost","/jm/",null,null);
server.start();
if ( host != null && !host.isEmpty() )
DesktopUtil.launchBrowser( host, port, false );
}
开发者ID:lucee,项目名称:Lucee4,代码行数:43,代码来源:RunAsJavaApplication.java
示例10: getServer
import org.mortbay.http.HttpServer; //导入依赖的package包/类
protected HttpServer getServer() {
return server;
}
开发者ID:rometools,项目名称:rome,代码行数:4,代码来源:AtomClientServerTest.java
注:本文中的org.mortbay.http.HttpServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论